unittest: Add test for environment isolation.

pull/488/head
Andrew Leech 2022-05-03 16:10:12 +10:00
rodzic a7b2f63117
commit cb8d108ac1
2 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -1,4 +1,5 @@
import unittest import unittest
from test_unittest_isolated import global_context
class TestUnittestAssertions(unittest.TestCase): class TestUnittestAssertions(unittest.TestCase):
@ -142,6 +143,11 @@ class TestUnittestAssertions(unittest.TestCase):
else: else:
self.fail("Unexpected success was not detected") self.fail("Unexpected success was not detected")
def test_NotChangedByOtherTest(self):
global global_context
assert global_context is None
global_context = True
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

Wyświetl plik

@ -0,0 +1,15 @@
import unittest
global_context = None
class TestUnittestIsolated(unittest.TestCase):
def test_NotChangedByOtherTest(self):
global global_context
assert global_context is None
global_context = True
if __name__ == "__main__":
unittest.main()