Bug 1280326 - Stop monkeypatching os.path.exists; r?ted
MockedOpen monkeypatches os.path.exists. Changes to MockedOpen
since this test code was written have made it more robust
making the extra monkeypatching in the test not necessary.
This change may not fix the test failure reported in the bug.
But at least it makes the test code simpler.
MozReview-Commit-ID: BnUr08leope
--- a/dom/bindings/mozwebidlcodegen/test/test_mozwebidlcodegen.py
+++ b/dom/bindings/mozwebidlcodegen/test/test_mozwebidlcodegen.py
@@ -244,39 +244,30 @@ class TestWebIDLCodegenManager(unittest.
fh.write('# Original content')
fh.flush()
mod = imp.load_source('mozwebidlcodegen.fakemodule', fh.name)
mod.__file__ = fake_path
args = self._get_manager_args()
m1 = WebIDLCodegenManager(**args)
with MockedOpen({fake_path: '# Original content'}):
- old_exists = os.path.exists
try:
- def exists(p):
- if p == fake_path:
- return True
- return old_exists(p)
-
- os.path.exists = exists
-
result = m1.generate_build_files()
l = len(result.inputs)
with open(fake_path, 'wt') as fh:
fh.write('# Modified content')
m2 = WebIDLCodegenManager(**args)
result = m2.generate_build_files()
self.assertEqual(len(result.inputs), l)
result = m2.generate_build_files()
self.assertEqual(len(result.inputs), 0)
finally:
- os.path.exists = old_exists
del sys.modules['mozwebidlcodegen.fakemodule']
def test_copy_input(self):
"""Ensure a copied .webidl file is handled properly."""
# This test simulates changing the type of a WebIDL from static to
# preprocessed. In that scenario, the original file still exists but
# it should no longer be consulted during codegen.