Last active
August 29, 2015 14:04
-
-
Save lukeorland/6b34533137fe3b48bf49 to your computer and use it in GitHub Desktop.
When I was looking into this issue: https://github.com/nose-devs/nose2/issues/215 I discovered some naming/behavior inconsistency between the "classmethod setUp", "setUp", and "classmethod setUpClass"
This file contains hidden or 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
| """ | |
| run with: | |
| nose2 test_nose2_unittest_layers --plugin nose2.plugins.layers --layer-reporter --verbose | |
| """ | |
| import time | |
| import unittest | |
| class Layer1(object): | |
| @classmethod | |
| def setUp(cls): | |
| """ | |
| This is run once per class like the unittest setUpClass | |
| (https://docs.python.org/2/library/unittest.html#unittest.TestCase.setUpClass) | |
| not once per test method like the unittest setUp | |
| (https://docs.python.org/2/library/unittest.html#unittest.TestCase.setUp) | |
| TODO: what's up with that? | |
| """ | |
| time.sleep(1) | |
| print("1 second elapsed") | |
| time.sleep(1) | |
| print("2 seconds elapsed") | |
| class Layer2(Layer1): | |
| @classmethod | |
| def setUp(cls): | |
| """ | |
| This is run once per class like the unittest setUpClass | |
| (https://docs.python.org/2/library/unittest.html#unittest.TestCase.setUpClass) | |
| not once per test method like the unittest setUp | |
| (https://docs.python.org/2/library/unittest.html#unittest.TestCase.setUp) | |
| TODO: what's up with that? | |
| """ | |
| time.sleep(1) | |
| print("3 second elapsed") | |
| time.sleep(1) | |
| print("4 seconds elapsed") | |
| class TestCaseLayer1(unittest.TestCase): | |
| layer = Layer1 | |
| def test_truth(self): | |
| assert True | |
| def test_truth2(self): | |
| assert True | |
| class TestCaseLayer2(TestCaseLayer1): | |
| layer = Layer2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment