From 42e7de418c4715e941b6fd8e4f9556ecc305fb3d Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Fri, 16 Jun 2023 04:49:02 -0700 Subject: [PATCH] fix test_build internal Summary: Make test work in isolation, and when run internally make it not try the sqlalchemy files. Reviewed By: shapovalov Differential Revision: D46352513 fbshipit-source-id: 7417a25d7a5347d937631c9f56ae4e3242dd622e --- tests/implicitron/test_build.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/implicitron/test_build.py b/tests/implicitron/test_build.py index f382fb1e..646497f5 100644 --- a/tests/implicitron/test_build.py +++ b/tests/implicitron/test_build.py @@ -5,6 +5,7 @@ # LICENSE file in the root directory of this source tree. import importlib +import os import sys import unittest import unittest.mock @@ -25,16 +26,23 @@ class TestBuild(unittest.TestCase): if module.startswith("pytorch3d"): sys.modules.pop(module, None) + # torchvision seems to cause problems if re-imported, + # so make sure it has been imported here. + import torchvision.utils # noqa + root_dir = get_pytorch3d_dir() / "pytorch3d" # Exclude opengl-related files, as Implicitron is decoupled from opengl # components which will not work without adding a dep on pytorch3d_opengl. + ignored_modules = ( + "__init__", + "plotly_vis", + "opengl_utils", + "rasterizer_opengl", + ) + if os.environ.get("FB_TEST", False): + ignored_modules += ("orm_types", "sql_dataset", "sql_dataset_provider") for module_file in root_dir.glob("**/*.py"): - if module_file.stem in ( - "__init__", - "plotly_vis", - "opengl_utils", - "rasterizer_opengl", - ): + if module_file.stem in ignored_modules: continue relative_module = str(module_file.relative_to(root_dir))[:-3] module = "pytorch3d." + relative_module.replace("/", ".")