使用命令pip install pytest-sugar安装插件
E:\Programs\Python\Python_Pytest\TestScripts>pip install pytest-sugar
Collecting pytest-sugar
Downloading https://files.pythonhosted.org/packages/da/3b/f1e3c8830860c1df8f0e0f6713932475141210cfa021e362ca2774d2bf02/pytest_sugar-0.9.2-py2.py3-none-any.whl
Requirement already satisfied: pytest>=2.9 in c:\python37\lib\site-packages (from pytest-sugar) (4.5.0)
Collecting packaging>=14.1 (from pytest-sugar)
Downloading https://files.pythonhosted.org/packages/91/32/58bc30e646e55eab8b21abf89e353f59c0cc02c417e42929f4a9546e1b1d/packaging-19.0-py2.py3-none-any.whl
Collecting termcolor>=1.1.0 (from pytest-sugar)
Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Requirement already satisfied: atomicwrites>=1.0 in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (1.3.0)
Requirement already satisfied: wcwidth in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (0.1.7)
Requirement already satisfied: attrs>=17.4.0 in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (19.1.0)
Requirement already satisfied: six>=1.10.0 in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (1.12.0)
Requirement already satisfied: colorama; sys_platform == "win32" in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (0.4.1)
Requirement already satisfied: py>=1.5.0 in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (1.8.0)
Requirement already satisfied: setuptools in c:\users\davieyang\appdata\roaming\python\python37\site-packages (from pytest>=2.9->pytest-sugar) (41.0.1)
Requirement already satisfied: pluggy!=0.10,<1.0,>=0.9 in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (0.11.0)
Requirement already satisfied: more-itertools>=4.0.0; python_version > "2.7" in c:\python37\lib\site-packages (from pytest>=2.9->pytest-sugar) (7.0.0)
Collecting pyparsing>=2.0.2 (from packaging>=14.1->pytest-sugar)
Downloading https://files.pythonhosted.org/packages/dd/d9/3ec19e966301a6e25769976999bd7bbe552016f0d32b577dc9d63d2e0c49/pyparsing-2.4.0-py2.py3-none-any.whl (62kB)
100% |████████████████████████████████| 71kB 19kB/s
Building wheels for collected packages: termcolor
Building wheel for termcolor (setup.py) ... done
Stored in directory: C:\Users\davieyang\AppData\Local\pip\Cache\wheels\7c\06\54\bc84598ba1daf8f970247f550b175aaaee85f68b4b0c5ab2c6
Successfully built termcolor
Installing collected packages: pyparsing, packaging, termcolor, pytest-sugar
Successfully installed packaging-19.0 pyparsing-2.4.0 pytest-sugar-0.9.2 termcolor-1.1.0
E:\Programs\Python\Python_Pytest\TestScripts>pytest
Test session starts (platform: win32, Python 3.7.3, pytest 4.5.0, pytest-sugar 0.9.2)
rootdir: E:\Programs\Python\Python_Pytest\TestScripts
plugins: xdist-1.29.0, timeout-1.3.3, sugar-0.9.2, repeat-0.8.0, instafail-0.4.1, forked-1.0.2, allure-pytest-2.6.3
collecting ...
test_asserts.py ✓ 6% ▋
test_asserts.py ✓✓ 12% █▎
test_asserts.py ✓✓✓ 18% █▊
――――――――――――――――――――――――――――――――――――――――――test_add4――――――――――――――――――――――――――――――――――――――――
def test_add4():
> assert add(17,22) >= 50
E assert 39 >= 50
E + where 39 = add(17, 22)
test_asserts.py:34: AssertionError
test_asserts.py ⨯ 24% ██▍
test_asserts.py ⨯✓ 29% ██▉
test_asserts.py ⨯✓✓ 35% ███▌
――――――――――――――――――――――――――――――――――――――― test_true――――――――――――――――――――――――――――――――――――――――――
def test_true():
> assert not is_prime(7)
E assert not True
E + where True = is_prime(7)
test_asserts.py:65: AssertionError
test_asserts.py ⨯ 41% ████▎
test_fixture1.py ✓ 47% ████
test_fixture1.py ✓✓ 53% ████
█▍
test_fixture2.py ✓ 59% ████
test_fixture2.py ✓✓ 65% ████
██▌
test_one.py ✓ 71% ████
███▏
―――――――――――――――――――――――――――――――――――― test_not_equal ―――――――――――――――――――――――――――――――――――――――
def test_not_equal():
> assert (1, 2, 3) == (3, 2, 1)
E assert (1, 2, 3) == (3, 2, 1)
E At index 0 diff: 1 != 3
E Use -v to get the full diff
test_one.py:9: AssertionError
test_one.py ⨯ 76% █████
██▋
test_two.py ✓ 82% ████
test_two.py ✓✓ 88% ████
test_two.py ✓✓✓ 94% ███
test_two.py ✓✓✓✓ 100% ███
███████
==================================== warnings summary ===================================
c:\python37\lib\site-packages\_pytest\mark\structures.py:324
c:\python37\lib\site-packages\_pytest\mark\structures.py:324: PytestUnknownMarkWarning: Unknown pytest.mark.run_these_cases - is this a typo? You can register custom mar
ks to avoid this warning - for details, see https://docs.pytest.org/en/latest/mark.html
PytestUnknownMarkWarning,
-- Docs: https://docs.pytest.org/en/latest/warnings.html
Results (0.47s):
14 passed
3 failed
- test_asserts.py:33 test_add4
- test_asserts.py:64 test_true
- test_one.py:8 test_not_equal