Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #478 from stefanholek/334-subtest-support
Subtest support
- Loading branch information
Showing
10 changed files
with
501 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
nose2/tests/functional/support/scenario/subtests/test_subtests.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import unittest | ||
|
||
|
||
class Case(unittest.TestCase): | ||
|
||
def test_subtest_success(self): | ||
for i in range(3): | ||
with self.subTest(i=i): | ||
self.assertTrue(i < 3) | ||
|
||
def test_subtest_failure(self): | ||
for i in range(6): | ||
with self.subTest(i=i): | ||
self.assertEqual(i%2, 0) | ||
|
||
def test_subtest_error(self): | ||
for i in range(3): | ||
with self.subTest(i=i): | ||
raise RuntimeError(i) | ||
|
||
@unittest.expectedFailure | ||
def test_subtest_expected_failure(self): | ||
for i in range(6): | ||
with self.subTest(i=i): | ||
self.assertEqual(i%2, 0) | ||
|
||
def test_subtest_message(self): | ||
for i in range(6): | ||
with self.subTest('msg', i=i): | ||
self.assertEqual(i%2, 0) |
Oops, something went wrong.