From 263a3f43c151248968071ce93c2fbd57455d428c Mon Sep 17 00:00:00 2001 From: meejah Date: Tue, 12 Sep 2017 11:53:37 -0600 Subject: [PATCH] stop chdir --- src/allmydata/test/cli/test_daemonize.py | 12 +++++++----- src/allmydata/test/test_upload.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/allmydata/test/cli/test_daemonize.py b/src/allmydata/test/cli/test_daemonize.py index 653cc72f0..3853054e4 100644 --- a/src/allmydata/test/cli/test_daemonize.py +++ b/src/allmydata/test/cli/test_daemonize.py @@ -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): diff --git a/src/allmydata/test/test_upload.py b/src/allmydata/test/test_upload.py index b118357bc..74ed51c28 100644 --- a/src/allmydata/test/test_upload.py +++ b/src/allmydata/test/test_upload.py @@ -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.