Python-unittest

Python 的 unittest 框架中,TextTestRunner有个参数verbosity(见官方文档)。看过很多次,但我一直没搞清楚它的用法和取值。

verbosity参数可以控制输出的错误报告的详细程度,只有 3 个取值:

0 (quiet): 只显示执行的用例的总数和全局的执行结果。
1 (default): 默认值,显示执行的用例的总数和全局的执行结果,并对每个用例的执行结果(成功 T 或失败 F)有个标注。
2 (verbose): 显示执行的用例的总数和全局的执行结果,并输出每个用例的详细的执行结果。
也可以使用命令行参数--quiet 或--verbose代替verbosity 参数的 0 或 1,传递给runner。


问题:python 报错:Empty suite

原因:
1.类名用Test命名
2.代码中使用了main函数调用类中的内容
所以解决办法:只要不满足上面的某一条件就行

本博客仅仅记录我自己遇见过的bug,仅仅用于个人备查。
如果不是很明确,请见谅。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Python Appium unittest is a testing framework used to automate mobile application testing using Python programming language. It is built on top of the unittest module and provides a set of methods and assertions to test mobile applications. To use Python Appium unittest, you need to have Appium installed on your machine and a mobile device or emulator to test your application on. You also need to have the Appium Python Client installed in your Python environment. Here is an example of a Python Appium unittest script: ``` import unittest from appium import webdriver class TestApp(unittest.TestCase): def setUp(self): desired_caps = { 'platformName': 'Android', 'deviceName': 'Android Emulator', 'appPackage': 'com.example.myapp', 'appActivity': 'MainActivity' } self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps) def tearDown(self): self.driver.quit() def test_login(self): email_field = self.driver.find_element_by_id('email') email_field.send_keys('testuser@example.com') password_field = self.driver.find_element_by_id('password') password_field.send_keys('password123') login_button = self.driver.find_element_by_id('login_button') login_button.click() assert 'Welcome' in self.driver.page_source if __name__ == '__main__': unittest.main() ``` In this example, we are testing a login functionality of an Android application. We first set up the desired capabilities for our test, which include the platform name, device name, app package, and app activity. We then initialize the Appium webdriver with these capabilities. In the `test_login` method, we find the email and password fields and enter test data. We then find the login button and click on it. Finally, we assert that the word 'Welcome' is present in the page source after successful login. To run this test, you can simply execute the script in your terminal using the command `python test_app.py`.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值