https://codereview.chromium.org/838253005/diff/90001/tools/telemetry/telemetry/util/cloud_storage_unittest.py
File tools/telemetry/telemetry/util/cloud_storage_unittest.py (right):
https://codereview.chromium.org/838253005/diff/90001/tools/telemetry/telemetry/util/cloud_storage_unittest.py#newcode36
tools/telemetry/telemetry/util/cloud_storage_unittest.py:36: stubs =
system_stub.Override(cloud_storage, ['open', 'subprocess'])
Okay, it turns out that the underlying problem is that you can't
override 'open' this way.
'open' is a built-in function, nor an imported module. So, when you
attempt to override it in system_stub, the first time you try to save
the old value, you call getattr(cloud_storage, 'open', None), and it
returns None (because open is not an attribute on cloud_storage).
system_stub.Override() saves the None away as the "original value", and
when you call stubs.Restore(), it *creates* an attribute in open that
shadows out the built-in name.
Then, down the road, when you end up calling open from inside
cloud_storage -- which happens when you call @unittest.skipUnless in
find_dependencies_unittest -- you end up trying to dereference None.
This is the bug in your CL (or, at least, the bug that your CL is
exposing).
Because the @unittest.skipUnless is evaluated when we construct the test
suite for the test, it isn't caught by the normal try/catch block we
wrap each unit test in; this is bug #1 in typ. We're probably tripping
over this now just because the ordering of tests between processes has
shifted and we happen to run the find_dependencies test after one of
these tests.
bug #2 in typ is that we're not propagating the stack trace back, making
it hard to see what the heck happened (though it would've been
nigh-impossible to figure out what happened from a log regardless).
I will fix the bugs in typ, but you will want to restructure your tests
and the code in cloud_storage as well.
https://codereview.chromium.org/838253005/