~allenap/maas/rpc-give-shared-secret-to-accepted-cluster

« back to all changes in this revision

Viewing changes to src/maastesting/fixtures.py

  • Committer: Tarmac
  • Author(s): Gavin Panella
  • Date: 2013-10-07 11:08:54 UTC
  • mfrom: (1640.1.19 str-to-unicode)
  • Revision ID: tarmac-20131007110854-s1668mwrifrg94y6
[r=jtv][bug=][author=allenap] Try to lessen the burden of working with byte and unicode strings in Python 2.x.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
    unicode_literals,
10
10
    )
11
11
 
 
12
str = None
 
13
 
12
14
__metaclass__ = type
13
15
__all__ = [
14
16
    "DisplayFixture",
15
17
    "LoggerSilencerFixture",
16
18
    "ProxiesDisabledFixture",
17
19
    "SSTFixture",
 
20
    "TempDirectory",
18
21
    ]
19
22
 
20
23
import logging
24
27
    PIPE,
25
28
    Popen,
26
29
    )
 
30
import sys
27
31
 
 
32
import fixtures
28
33
from fixtures import (
29
34
    EnvironmentVariableFixture,
30
35
    Fixture,
31
 
    TempDir,
32
36
    )
33
37
from sst.actions import (
34
38
    start,
135
139
        self.useFixture(EnvironmentVariableFixture("https_proxy"))
136
140
 
137
141
 
138
 
class TempWDFixture(TempDir):
 
142
class TempDirectory(fixtures.TempDir):
 
143
    """Create a temporary directory, ensuring Unicode paths."""
 
144
 
 
145
    def setUp(self):
 
146
        super(TempDirectory, self).setUp()
 
147
        if isinstance(self.path, bytes):
 
148
            encoding = sys.getfilesystemencoding()
 
149
            self.path = self.path.decode(encoding)
 
150
 
 
151
 
 
152
class TempWDFixture(TempDirectory):
139
153
    """Change the current working directory into a temp dir.
140
154
 
141
155
    This will restore the original WD and delete the temp directory on cleanup.