#๐ doctest not showing failed tests, or passed tests
18 messages ยท Page 1 of 1 (latest)
@leaden trout
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
You probably need to turn on the "verbose" mode.
Maybe the IDE wasn't recognised it's a test
couldn't find anything of that sort
hm
If you're going to use ... in the expected output you need to annotate the test slightly, example:
>>> rowtype #doctest: +ELLIPSIS
<function named_row_tuple.<locals>.factory at ...>
You need the #doctest: stuff.
Re the verbose setting, here's me doctesting a module:
CSS[~/hg/css-ebooks(hg:ebooks)]fleet2*> doctest cs.csvutils
+ exec env-dev doctest cs.csvutils
+ exec python3 -c 'import doctest; import cs.csvutils; doctest.testmod(cs.csvutils)'
CSS[~/hg/css-ebooks(hg:ebooks)]fleet2*> doctest -v cs.csvutils
+ exec env-dev doctest -v cs.csvutils
+ exec python3 -c 'import doctest; import cs.csvutils; doctest.testmod(cs.csvutils)' -v
Trying:
rowtype, rows = csv_import(['a, b', '1,2', '3,4'], class_name='Example_AB')
Expecting nothing
ok
Trying:
rowtype #doctest: +ELLIPSIS
Expecting:
<function named_row_tuple.<locals>.factory at ...>
ok
Trying:
list(rows)
Expecting:
[Example_AB(a='1', b='2'), Example_AB(a='3', b='4')]
ok
Trying:
rowtype, rows = csv_import(['1,2', '3,4'], class_name='Example_DEFG', column_names=['D E', 'F G '])
Expecting nothing
ok
Trying:
list(rows)
Expecting:
[Example_DEFG(d_e='1', f_g='2'), Example_DEFG(d_e='3', f_g='4')]
ok
4 items had no tests:
cs.csvutils
cs.csvutils.csv_reader
cs.csvutils.csv_writerow
cs.csvutils.xl_import
1 items passed all tests:
5 tests in cs.csvutils.csv_import
5 tests in 5 items.
5 passed and 0 failed.
Test passed.
CSS[~/hg/css-ebooks(hg:ebooks)]fleet2*>
My environment is different to your IDE, but see the second run used the -v option for doctest?
... and ran this incantation: python3 -c 'import doctest; import cs.csvutils; doctest.testmod(cs.csvutils)' -v
There are nothing wrong with the doctest, just the missing PyCharm gui which show when running a test
Basically PyCharm read the output of the test and parse it to nice display
do you know how I can re enable that?
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.