diff options
author | David Pursell <dpursell@google.com> | 2016-05-06 11:33:06 -0700 |
---|---|---|
committer | David Pursell <dpursell@google.com> | 2016-05-06 11:43:08 -0700 |
commit | 1c2354a5657d9b447eefc7162b62159f28d1f5cc (patch) | |
tree | 155ed32eca70773c0d09632513d0b6c7a9a087a8 | |
parent | 13b471eea12f44d5bbecb24ef93c6321f62e4d90 (diff) | |
download | bdk-1c2354a5657d9b447eefc7162b62159f28d1f5cc.tar.gz |
bdk: give StubOs.cwd a sane default.
util.GetProductDir() expects os.getcwd() to start with '/' or else it
may loop forever. This seems like a reasonable expectation (on Linux at
least) so adjust StubOs.cwd to comply.
This fixes an issue where in some cases climanager_unittest.BdkTest
would end up calling util.GetProductDir(), but a previous test had
replaced util.os with StubOs, leading to this infinite loop.
The real underlying problem is that manually monkey-patching over
imported modules is super unpredictable and brittle, but that will have
to be addressed in a larger test overhaul.
Bug: 28602169
Change-Id: I5eda7e55b704933272f97a4334d7a92d18a0f6fa
Test: `python test_runner.py`, with and without randomized test order.
-rw-r--r-- | cli/lib/test/stubs.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/cli/lib/test/stubs.py b/cli/lib/test/stubs.py index 45f5c7d..af49242 100644 --- a/cli/lib/test/stubs.py +++ b/cli/lib/test/stubs.py @@ -142,7 +142,7 @@ class StubOs(object): """Stubs for the os module.""" def __init__(self): - self.cwd = '' + self.cwd = '/' self.environ = {} self.pathsep = ':' self.should_makedirs = [] |