工作中遇到一个问题,想把串口字符COM6传入pytest测试文件中,翻阅了不少资料,把心得总结如下:
1, 是经过conftest.py文件传入,代码如下:
Suppose we want to write a test that depends on a command line option. Here is a basic pattern to achieve this:
# content of test_sample.py
def test_answer(cmdopt):
if cmdopt == "type1":
print ("first")
elif cmdopt == "type2":
print ("second"