Skip to content

Commit cb8d108

Browse files
committed
unittest: Add test for environment isolation.
1 parent a7b2f63 commit cb8d108

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

python-stdlib/unittest/test_unittest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from test_unittest_isolated import global_context
23

34

45
class TestUnittestAssertions(unittest.TestCase):
@@ -142,6 +143,11 @@ def testInner():
142143
else:
143144
self.fail("Unexpected success was not detected")
144145

146+
def test_NotChangedByOtherTest(self):
147+
global global_context
148+
assert global_context is None
149+
global_context = True
150+
145151

146152
if __name__ == "__main__":
147153
unittest.main()
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import unittest
2+
3+
4+
global_context = None
5+
6+
7+
class TestUnittestIsolated(unittest.TestCase):
8+
def test_NotChangedByOtherTest(self):
9+
global global_context
10+
assert global_context is None
11+
global_context = True
12+
13+
14+
if __name__ == "__main__":
15+
unittest.main()

0 commit comments

Comments
 (0)