pytest在pycharm中运行与CMD命令运行区别一
pycharm下运行这段代码是如图1.1所示:
python
import pytest
class Test01():
def test_a(self):
print('aaaa')
assert 'a' == 'a'
def test_b(self):
print('bbbb')
assert 'b' == 'b'
class Test02():
def test_c(self):
print('cccc')
assert 'c' == 'c'
def test_d(self):
print('dddd')
assert 'd' == 'd'
if __name__ == '__main__':
pytest.main(["-s", "./test_11_11.py::Test02"])
图1.1

在CMD下运行是符合预期的。具体操作步骤如下:
图1.2
