Skip to content

Commit

Permalink
Run test_hub in its own interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
fmassa committed Sep 18, 2019
1 parent dd33f5e commit d762d7a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ install:
script:
- pytest --cov-config .coveragerc --cov torchvision --cov $TV_INSTALL_PATH test
- pytest test/test_hub.py

after_success:
# Necessary to run coverage combine to rewrite paths from
Expand Down
16 changes: 7 additions & 9 deletions test/test_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@ def sum_of_model_parameters(model):
SUM_OF_PRETRAINED_RESNET18_PARAMS = -12703.99609375


@unittest.skipIf('torchvision' in sys.modules,
'TestHub must start without torchvision imported')
class TestHub(unittest.TestCase):
@classmethod
def setUpClass(cls):
# Only run this check ONCE before all tests start.
# - If torchvision is imported before all tests start, e.g. we might find _C.so
# which doesn't exist in downloaded zip but in the installed wheel.
# - After the first test is run, torchvision is already in sys.modules due to
# Python cache as we run all hub tests in the same python process.
if 'torchvision' in sys.modules:
raise RuntimeError('TestHub must start without torchvision imported')
# Only run this check ONCE before all tests start.
# - If torchvision is imported before all tests start, e.g. we might find _C.so
# which doesn't exist in downloaded zip but in the installed wheel.
# - After the first test is run, torchvision is already in sys.modules due to
# Python cache as we run all hub tests in the same python process.

def test_load_from_github(self):
hub_model = hub.load(
Expand Down

0 comments on commit d762d7a

Please sign in to comment.