~lutostag/ubuntu/trusty/maas/1.5.4+keystone

« back to all changes in this revision

Viewing changes to src/maastesting/tests/test_fixtures.py

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2013-03-04 11:49:44 UTC
  • mto: This revision was merged to the branch mainline in revision 25.
  • Revision ID: package-import@ubuntu.com-20130304114944-azcvu9anlf8mizpa
Tags: upstream-1.3+bzr1452+dfsg
ImportĀ upstreamĀ versionĀ 1.3+bzr1452+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from fixtures import EnvironmentVariableFixture
18
18
from maastesting.factory import factory
19
 
from maastesting.fixtures import ProxiesDisabledFixture
 
19
from maastesting.fixtures import (
 
20
    ProxiesDisabledFixture,
 
21
    TempWDFixture,
 
22
    )
20
23
from maastesting.testcase import TestCase
21
24
 
22
25
 
42
45
            self.assertNotIn("https_proxy", os.environ)
43
46
        # On exit, http_proxy is restored.
44
47
        self.assertEqual(https_proxy, os.environ.get("https_proxy"))
 
48
 
 
49
 
 
50
class TestTempWDFixture(TestCase):
 
51
 
 
52
    def test_changes_dir_and_cleans_up(self):
 
53
        orig_cwd = os.getcwd()
 
54
        with TempWDFixture() as temp_wd:
 
55
            new_cwd = os.getcwd()
 
56
            self.assertTrue(os.path.isdir(temp_wd.path))
 
57
            self.assertNotEqual(orig_cwd, new_cwd)
 
58
            self.assertEqual(new_cwd, temp_wd.path)
 
59
        final_cwd = os.getcwd()
 
60
        self.assertEqual(orig_cwd, final_cwd)
 
61
        self.assertFalse(os.path.isdir(new_cwd))