@unittest.skip doesn't print anything in Python <= 3.7

6 views
Skip to first unread message

אורי

unread,
Feb 11, 2021, 3:24:51 PM2/11/21
to pywe...@googlegroups.com
Hi,
  
https://stackoverflow.com/questions/66161394/unittest-skip-doesnt-print-anything-in-python-3-7

We are using Django with unittest. Some tests are skipped with the @unittest.skip decorator. But if I run the tests with Python 3.6 or 3.7, I get a number of tests passed (Ran 993 tests / OK), and if I run the same tests with Python 3.8, I get the same number of tests but with some tests skipped (Ran 993 tests / OK (skipped=4)). I would like to know if the same tests were also skipped with Python 3.6 and 3.7, or only with Python 3.8? And why do I get the skipped output only with Python 3.8? And is the number 993 including the skipped tests or not including them? Is one of the outputs incorrect? Because it doesn't make sense that the output is different for different versions of Python and I don't understand the reason for this difference. I didn't find it documented in the documentation.

Our code is open source, and you can see for example a skipped test here.

Update: I added 4 more tests with the decorator @unittest.skip. When I run all the tests with Python 3.8, I get this output: Ran 997 tests / OK (skipped=8) (with an s for every skipped test, like before). But if I run the tests with Python 3.6 or 3.7, I get this output: Ran 997 tests / OK and there are no s in the output, like before (I get 997 dots). Although I have 4 more tests than before.

The tests I added raise an exception, so if they would not be skipped they would fail.

I think the skipped tests are skipped in all Python versions, but in Python 3.6 and 3.7 there is no output about them being skipped. Is it a bug?

Shai Berger

unread,
Feb 11, 2021, 5:01:47 PM2/11/21
to pywe...@googlegroups.com
I answered on SO, but to cut things short -- skips are reported
correctly on Python 3.7, when you use the @unittest.skip(reason)
decorator and not just @unittest.skip

אורי

unread,
Feb 11, 2021, 11:02:15 PM2/11/21
to pywe...@googlegroups.com
Thank you!


--
You received this message because you are subscribed to the Google Groups "PyWeb-IL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyweb-il+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pyweb-il/20210212000143.003df52c.shai%40platonix.com.
Reply all
Reply to author
Forward
0 new messages