GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — gh-127221: Add colour to unittest output by hugovk · Pull Request #127223 · python/cpython Conversation
|
| Before | After | pytest |
|---|---|---|
|
|
|
| Mode | Before | After | pytest |
|---|---|---|---|
| Regular |
|
|
|
| Verbose |
|
|
|
import unittest class TestThings(unittest.TestCase): def test_pass(self): self.assertTrue(True) def test_fail(self): self.assertTrue(False) def test_error(self): raise Exception("Manually raised exception") def test_pass2(self): self.assertEqual(1, 1) @unittest.skip("demonstrating skipping") def test_skip(self): self.fail("shouldn't happen") class ExpectedFailureTestCase(unittest.TestCase): @unittest.expectedFailure def test_fail(self): self.assertEqual(1, 0, "broken") @unittest.expectedFailure def test_pass(self): self.assertEqual(1, 1, "not broken") if __name__ == "__main__": unittest.main()
| Mode | Before | After | pytest |
|---|---|---|---|
| Regular |
|
|
|
| Verbose |
|
|
|
import unittest class DoSubTest(unittest.TestCase): def test_subtest(self): """Test with subtest""" for i in range(0, 4): with self.subTest(i=i): if i == 2: raise Exception("Manually raised exception") self.assertEqual(i % 2, 0) if __name__ == "__main__": unittest.main()
| Mode | Before | After | pytest |
|---|---|---|---|
| Regular |
|
|
|
| Verbose |
|
|
|
📚 Documentation preview 📚: https://cpython-previews--127223.org.readthedocs.build/
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Looks good, I see you're taking some inspiration from pytest, but I had to zoom in all the way to be able to read the text. :) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
You can click the images to open them full size. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Well, I wanted to compare the images so I had to zoom in to see the difference. Maybe we could only show the comparison between pytest? The uncoloured images don't add much value. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This is great!! With the coloured tracebacks as well, though, I sort-of feel like there might be a bit too much colour now when tests fail. It feels slightly overwhelming!
What about making only the "ERROR"/"FAIL"/"UNEXPECTED SUCCESS" lines coloured red, and not the ======= line above or the ------- below?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
e18da3e to
d01272f
Compare
| self.assertTrue(test.doCleanups()) | ||
| self.assertEqual(cleanups, [(2, (), {}), (1, (1, 2, 3), dict(four='hello', five='goodbye'))]) | ||
|
|
||
| @force_not_colorized |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
we have to apply this decorator to so many methods that I almost wonder if it's worth having a custom metaclass that automatically adds it to each method on the class... or we could not use the @force_not_colorized decorator, and instead duplicate the logic in setUp and tearDown methods on the TestCleanup class here.
Neither feels ideal; it might be that what you have now is in fact best!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Nice, that looks great to me now! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
How about swapping the rows and columns in the table? It makes the text better readable: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
To be clear @nineteendo, this is a comment on the table in Hugo's PR description rather than the code he's changing in this PR, correct? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Correct, with 3 images on the same row I can't read the text without zooming in. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I see. @hugovk, do you think we should add a link to the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Yeah, good idea. Something like 5a1de7c? Let's also add it to |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I like the idea. But, I personally feel like it is still a bit too colorful. Right now almost nothing is white.
One more idea: can you please test this with the white theme as well?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Kirill Podoprigora <[email protected]>
Co-authored-by: Kirill Podoprigora <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.