diff options
| author | Ned Batchelder <ned@nedbatchelder.com> | 2015-08-29 07:57:50 -0400 | 
|---|---|---|
| committer | Ned Batchelder <ned@nedbatchelder.com> | 2015-08-29 07:57:50 -0400 | 
| commit | cd8525502a6f40a99b1b5c5423c0cc8ec15fcf3b (patch) | |
| tree | 42fea4dcec75553844fcbfbb275e21b404c74c76 /tests/test_testing.py | |
| parent | dc025f2e9cd0dfe1c39bf8c62eed451ef7cad256 (diff) | |
| download | python-coveragepy-git-cd8525502a6f40a99b1b5c5423c0cc8ec15fcf3b.tar.gz | |
Add an explicit test of EnvironmentAwareMixin
Diffstat (limited to 'tests/test_testing.py')
| -rw-r--r-- | tests/test_testing.py | 27 | 
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/test_testing.py b/tests/test_testing.py index 39c711ba..80f0646b 100644 --- a/tests/test_testing.py +++ b/tests/test_testing.py @@ -10,8 +10,9 @@ import sys  from coverage.backunittest import TestCase  from coverage.backward import to_bytes +from coverage.test_helpers import EnvironmentAwareMixin, TempDirMixin -from tests.coveragetest import TempDirMixin, CoverageTest +from tests.coveragetest import CoverageTest  class TestingTest(TestCase): @@ -63,6 +64,30 @@ class TempDirMixinTest(TempDirMixin, TestCase):          self.assertEqual(text, to_bytes("tabblo: «ταБЬℓσ»")) +class EnvironmentAwareMixinTest(EnvironmentAwareMixin, TestCase): +    """Tests of test_helpers.EnvironmentAwareMixin.""" + +    def test_setting_and_cleaning_env_vars(self): +        # The before state. +        home = os.environ["HOME"] +        self.assertNotEqual(home, "Is where the heart is") +        self.assertNotIn("XYZZY_PLUGH", os.environ) + +        # Change the environment. +        self.set_environ("HOME", "Is where the heart is") +        self.set_environ("XYZZY_PLUGH", "Vogon") + +        self.assertEqual(os.environ["HOME"], "Is where the heart is") +        self.assertEqual(os.environ["XYZZY_PLUGH"], "Vogon") + +        # Do the clean ups early. +        self.doCleanups() + +        # The environment should be restored. +        self.assertEqual(os.environ["HOME"], home) +        self.assertNotIn("XYZZY_PLUGH", os.environ) + +  class CoverageTestTest(CoverageTest):      """Test the methods in `CoverageTest`."""  | 
