r/Python • • Sep 15 '15

Ask microsoft to include Python in Windows by default

https://windows.uservoice.com/forums/265757-windows-feature-suggestions/suggestions/6693586-ship-python-3-and-python-2-with-windows-10
1.2k Upvotes

329 comments sorted by

View all comments

Show parent comments

7

u/alicedu06 Sep 15 '15

Pytest only uses the assert keyword while still providing very detailed information about the test during a failure.

To report the additional informations about a failure witout the need for self.assertStuff method, pytest has to do deep introspection, inspect frames, etc. This is not your day to day Python.

3

u/fireflash38 Sep 15 '15

For more info: http://pybites.blogspot.ca/2011/07/behind-scenes-of-pytests-new-assertion.html

Quick explanation: it rewrites your test modules so that it only executes assertion code once, but will still dump nice output about the values at the time of the assert.

1

u/erewok Sep 15 '15

I ran into something weird recently with some threaded code and tests in Python. This was in a huge, messy codebase, so I initially didn't even know the function getting called (inside the one I was testing) was threaded.

I tried to do time.sleep(0) and other hacks to debug, but nothing worked, except for one thing: if I made it so that my test methods that cared about the threaded result ran 1st, 3rd, 5th,etc out of all the test methods, I could see the threaded calls happening. I think this was due to quirks in py.test, but I'm unsure.

Do you happen to know where I can find out more about py.test and threaded code?

1

u/alicedu06 Nov 05 '15

Nope, as I never encountered such a problem. I don't use threads, I use non blocking event loops.