Bug 1280326 - Stop monkeypatching os.path.exists; r?ted draft
authorGregory Szorc <gps@mozilla.com>
Fri, 24 Jun 2016 13:41:49 -0700
changeset 381231 fa8b05b872dc0cf925a0c8cd0b5c2dd864326843
parent 381119 939ecc4e9d055c263633cbe276bfb634a68fe4c5
child 381232 9780899f67a1c14f6864f756370c677b84456573
push id21439
push userbmo:gps@mozilla.com
push dateFri, 24 Jun 2016 20:50:29 +0000
reviewersted
bugs1280326
milestone50.0a1
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
dom/bindings/mozwebidlcodegen/test/test_mozwebidlcodegen.py
--- 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.