stop chdir

This commit is contained in:
meejah 2017-09-12 11:53:37 -06:00
parent 9375056b61
commit 263a3f43c1
2 changed files with 21 additions and 5 deletions

View File

@ -94,7 +94,7 @@ class RunDaemonizeTests(unittest.TestCase):
def setUp(self):
# no test should change our working directory
self._working = os.path.abspath(os.path.curdir)
self._working = os.path.abspath('.')
d = super(RunDaemonizeTests, self).setUp()
self._reactor = patch('twisted.internet.reactor')
self._twistd = patch('allmydata.scripts.tahoe_daemonize.twistd')
@ -108,10 +108,12 @@ class RunDaemonizeTests(unittest.TestCase):
d = super(RunDaemonizeTests, self).tearDown()
for cm in [self._reactor, self._twistd]:
cm.__exit__(None, None, None)
self.assertEqual(
self._working,
os.path.abspath(os.path.curdir),
)
# Note: if you raise an exception (e.g. via self.assertEqual
# or raise RuntimeError) it is apparently just ignored and the
# test passes anyway...
if self._working != os.path.abspath('.'):
print("WARNING: a test just changed the working dir; putting it back")
os.chdir(self._working)
return d
def _placeholder_nodetype(self, nodetype):

View File

@ -860,6 +860,20 @@ class FakeServerTracker:
class EncodingParameters(GridTestMixin, unittest.TestCase, SetDEPMixin,
ShouldFailMixin):
def setUp(self):
d = super(EncodingParameters, self).setUp()
self._curdir = os.path.abspath(os.path.curdir)
return d
def tearDown(self):
d = super(EncodingParameters, self).tearDown()
self.assertEqual(
os.path.abspath(os.path.curdir),
self._curdir,
)
return d
def find_all_shares(self, unused=None):
"""Locate shares on disk. Returns a dict that maps
server to set of sharenums.