"git@developer.sourcefind.cn:OpenDAS/mmcv.git" did not exist on "a4dc2a72abc9cbcd9d898c6efc1a37fa21558a78"
Commit f2c44e35 authored by Jeremy Reizenstein's avatar Jeremy Reizenstein Committed by Facebook GitHub Bot
Browse files

update test_build for robustness

Summary: Change cyclic deps test to be independent of test discovery order. Also let it work without plotly.

Reviewed By: nikhilaravi

Differential Revision: D30669614

fbshipit-source-id: 2eadf3f8b56b6096c5466ce53b4f8ac6df27b964
parent a9b0d50b
...@@ -118,17 +118,19 @@ class TestBuild(unittest.TestCase): ...@@ -118,17 +118,19 @@ class TestBuild(unittest.TestCase):
# Check each module of pytorch3d imports cleanly, # Check each module of pytorch3d imports cleanly,
# which may fail if there are import cycles. # which may fail if there are import cycles.
# First check the setup of the test. If any of pytorch3d with unittest.mock.patch.dict(sys.modules):
# was already imported the test would be pointless. for module in list(sys.modules):
for module in sys.modules: # If any of pytorch3d is already imported,
self.assertFalse(module.startswith("pytorch3d"), module) # the test would be pointless.
if module.startswith("pytorch3d"):
root_dir = get_pytorch3d_dir() / "pytorch3d" sys.modules.pop(module, None)
for module_file in root_dir.glob("**/*.py"):
if module_file.stem == "__init__": root_dir = get_pytorch3d_dir() / "pytorch3d"
continue for module_file in root_dir.glob("**/*.py"):
relative_module = str(module_file.relative_to(root_dir))[:-3] if module_file.stem in ("__init__", "plotly_vis"):
module = "pytorch3d." + relative_module.replace("/", ".") continue
with self.subTest(name=module): relative_module = str(module_file.relative_to(root_dir))[:-3]
with unittest.mock.patch.dict(sys.modules): module = "pytorch3d." + relative_module.replace("/", ".")
importlib.import_module(module) with self.subTest(name=module):
with unittest.mock.patch.dict(sys.modules):
importlib.import_module(module)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment