Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Internal refactorings required for *external* pytest-subtests plugin #4920
#1367 is about adding unittest subtest support to pytest. After long discussions, it was decided to introduce a new report type and new hook into pytest. After some experiments, I realized we only needed a few internal changes in order to support unittest subtests and a new
An external plugin is a better approach here IMO because it allows it make more frequent iterations on the details and mature outside of pytest's release cycle. After the plugin matures, we can consider introducing it into the core.
This PR showcases:
After reviews, I will remove the plugin files and rebase so we can merge it.
import unittest class T(unittest.TestCase): def test_foo(self): for i in range(5): with self.subTest('custom message', i=i): self.assertEqual(i % 2, 0) if __name__ == '__main__': unittest.main()
def test(subtests): for i in range(5): with subtests.test(msg='custom message', i=i): assert i % 2 == 0
@@ Coverage Diff @@ ## features #4920 +/- ## ============================================= - Coverage 95.84% 46.42% -49.42% ============================================= Files 113 113 Lines 25266 25284 +18 Branches 2495 2494 -1 ============================================= - Hits 24215 11737 -12478 - Misses 735 12923 +12188 - Partials 316 624 +308
You mean using
I guess one could also use the same tricks as