Created
December 22, 2019 10:42
-
-
Save sprytnyk/6a898b7a3363e63160b6612e60df4693 to your computer and use it in GitHub Desktop.
An example of pytest output that shows doctests and unittests failures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==================================================================== test session starts ===================================================================== | |
platform linux -- Python 3.6.9, pytest-5.3.2, py-1.8.0, pluggy-0.13.1 | |
rootdir: /home/vald/Projects/personal/doctests_discovery | |
collected 4 items | |
tests/test_models.py . [ 25%] | |
tests/test_package_doctests.py F [ 50%] | |
tests/test_views.py .F [100%] | |
========================================================================== FAILURES ========================================================================== | |
_____________________________________________________________________ test_doctest_suit ______________________________________________________________________ | |
def test_doctest_suit(): | |
test_suit = unittest.TestSuite() | |
test_suit.addTest(doctest.DocTestSuite(models)) | |
test_suit.addTest(doctest.DocTestSuite(views)) | |
# There are 3 different levels of a verbosity parameter: | |
# 0 (quiet): you just get the total numbers of tests executed and the global result | |
# 1 (default): you get the same plus a dot for every successful test or a F for every failure | |
# 2 (verbose): you get the help string of every test and the result | |
runner = unittest.TextTestRunner(verbosity=2).run(test_suit) | |
> assert not runner.failures | |
E assert not [(dummy_model (app.models), 'Traceback (most recent call last):\n File "/home/vald/.pyenv/versions/3.6.9/lib/python3....w[0]>", line 1, in <module>\n view(1)\n TypeError: view() takes 0 positional arguments but 1 was given\n\n')] | |
E + where [(dummy_model (app.models), 'Traceback (most recent call last):\n File "/home/vald/.pyenv/versions/3.6.9/lib/python3....w[0]>", line 1, in <module>\n view(1)\n TypeError: view() takes 0 positional arguments but 1 was given\n\n')] = <unittest.runner.TextTestResult run=3 errors=0 failures=2>.failures | |
tests/test_package_doctests.py:18: AssertionError | |
-------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------- | |
dummy_model (app.models) | |
Doctest: app.models.dummy_model ... FAIL | |
util (app.views) | |
Doctest: app.views.util ... ok | |
view (app.views) | |
Doctest: app.views.view ... FAIL | |
====================================================================== | |
FAIL: dummy_model (app.models) | |
Doctest: app.models.dummy_model | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/home/vald/.pyenv/versions/3.6.9/lib/python3.6/doctest.py", line 2199, in runTest | |
raise self.failureException(self.format_failure(new.getvalue())) | |
AssertionError: Failed doctest test for app.models.dummy_model | |
File "/home/vald/Projects/personal/doctests_discovery/app/models.py", line 1, in dummy_model | |
---------------------------------------------------------------------- | |
File "/home/vald/Projects/personal/doctests_discovery/app/models.py", line 4, in app.models.dummy_model | |
Failed example: | |
dummy_model() | |
Expected: | |
False | |
Got: | |
True | |
====================================================================== | |
FAIL: view (app.views) | |
Doctest: app.views.view | |
---------------------------------------------------------------------- | |
Traceback (most recent call last): | |
File "/home/vald/.pyenv/versions/3.6.9/lib/python3.6/doctest.py", line 2199, in runTest | |
raise self.failureException(self.format_failure(new.getvalue())) | |
AssertionError: Failed doctest test for app.views.view | |
File "/home/vald/Projects/personal/doctests_discovery/app/views.py", line 1, in view | |
---------------------------------------------------------------------- | |
File "/home/vald/Projects/personal/doctests_discovery/app/views.py", line 4, in app.views.view | |
Failed example: | |
view(1) | |
Exception raised: | |
Traceback (most recent call last): | |
File "/home/vald/.pyenv/versions/3.6.9/lib/python3.6/doctest.py", line 1330, in __run | |
compileflags, 1), test.globs) | |
File "<doctest app.views.view[0]>", line 1, in <module> | |
view(1) | |
TypeError: view() takes 0 positional arguments but 1 was given | |
---------------------------------------------------------------------- | |
Ran 3 tests in 0.003s | |
FAILED (failures=2) | |
____________________________________________________________________ test_dummy_unit_test ____________________________________________________________________ | |
def test_dummy_unit_test(): | |
> assert False | |
E assert False | |
tests/test_views.py:9: AssertionError | |
================================================================ 2 failed, 2 passed in 0.06s ================================================================= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment