当前位置:网站首页>Pytest configuration file
Pytest configuration file
2022-06-26 10:18:00 【Xiaojing, who likes dumplings】
pytest Profile profile
pytest.ini yes pytest Primary profile for , You can change pytest Default behavior of
How to configure pytest
Change the default command line options
For some common command line parameters , such as -v,-s, Regular use , But I don't want to repeat the input , Can be in pytest.ini Of documents addopts To set up
[pytest]
addopts=-v -s
Sign up for spelling mistakes
We can customize tags to manage test cases , For example, the smoke test case is marked as @pytest.mark.smoke, You can register tags in the configuration file to avoid spelling mistakes , The unregistered tag will prompt warning
makers The format is line list
[pytest]
addopts=-v -s
markers=
smoke
regession
Appoint pytest The minimum version of
minversion=3.0
Appoint pytest Ignore some directories
norecurse
Specify test directory
Use testpaths Appoint pytest Which directory to access
Only in pytest When no file directory parameter or test case identifier is specified , This option is enabled
Change test search rules
pytest Standard test search rules :
- Start with one or more directories , You can specify a file name or directory name on the command line , If not specified , Use the current directory
- Recursively query the test modules under this directory and all subdirectories
- The test module is named test_.py or _test.py The file of
- Find in the test module to test_ Function name at the beginning
- Find a name to Test Initial class , among , First, filter out the contents __init__ Class of function , Find the class with test_ Class side at the beginning
You can change the search rules in the configuration file
python_classes Change the search rules for the class
python_classes=Test TestSuite
python_files Change the default search rules for files
python_files=test_test check
python_functions Change the rules for testing functions and methods
python_functions=test_* check_*
[pytest]
addopts=-v -s
markers=
smoke
regession
python_classes=Test* Suite*
python_files=test_* *_test check_*
python_functions=test_* check_*
To configure log
log_file=…/log/log.txt
log_file_level=INFO
log_file_format= %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
log_file Is to output the log to a file
log_cli_level
log_cli_format
log_cli_date_format
Output the log to the console
[pytest]
addopts=-v -s
markers=
smoke
regession
python_classes=Test* Suite*
python_files=test_* *_test check_*
python_functions=test_* check_*
log_file=../log/log.txt
log_file_level=INFO
log_file_format= %(asctime)s %(levelname)s %(message)s
log_date_format = %Y-%m-%d %H:%M:%S
Source code :
def my_add(x,y):
print("test2")
Log.info("test2")
return x+y
Test code :
def test_add_threee():
result=my_add(3,4)
assert result==7
Please refer to the official website for details :link.
边栏推荐
- 【LeetCode】59. Spiral matrix II
- Use of exec series functions (EXECL, execlp, execle, execv, execvp)
- MySQL项目8总结
- Nested recyclerview in nestedscrollview automatically slides to the bottom after switching
- WGCLOUD的web ssh服务端口是多少
- Blog article index summary -- Software Engineering
- MySQL第五章总结
- Retrofit common request methods and comments, post, get heard file upload
- 904. 水果成篮
- String class intern() method and string constant pool
猜你喜欢
Redis master-slave replication in win10 system
方法区里面有什么——class文件、class文件常量池、运行时常量池
Software testing - how to select the appropriate orthogonal table
Small example of SSM project, detailed tutorial of SSM integration
Detailed explanation of winsorflow quantum installation process
904. fruit baskets
Configuration internationale
定制拦截器
國際化配置
What is the web SSH service port of wgcloud
随机推荐
1. 两数之和(LeetCode题目)
How to change the QR code material color of wechat applet
Blog post index summary --c #
Svn command
什么是僵尸网络
Meaning of go runtime
利用foreach循环二维数组
Some problems to be considered when designing technical implementation scheme
Nested recyclerview in nestedscrollview automatically slides to the bottom after switching
Crawler related articles collection: pyppeter, burpsuite
The basis of C language grammar -- factoring by function applet
如何更改微信小程序二维码物料颜色
What is LSP
Why do some functions in the go standard library have only signatures but no function bodies?
调用api接口生成不同颜色的微信小程序二维码
[sans titre]
【无标题】
Extracting public fragments from thymeleaf
【Leetcode】76. 最小覆盖子串
Mysql database operation commands (constantly updated)