Skip to content

Commit

Permalink
fix: move tmp module to test file
Browse files Browse the repository at this point in the history
  • Loading branch information
jemmyshin committed Nov 25, 2022
1 parent 8072d53 commit 4dcffab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 0 additions & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ def tmpfile(tmpdir):
return tmpdir / tmpfile


@pytest.fixture()
def tmpmodule(tmpdir):
tmpfile = f'package.py'
with open(tmpdir / tmpfile, 'w') as f:
f.write("raise ImportError")
return tmpdir / tmpfile


@pytest.fixture(scope='session')
def event_loop(request):
"""
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ def test_no_suppress_other_exception():
raise Exception


def test_path_importer(tmpmodule):
def test_path_importer(tmpdir):
tmpmodule = f'package.py'
with open(tmpdir / tmpmodule, 'w') as f:
f.write("raise ImportError")

from jina.importer import PathImporter
with pytest.raises(ImportError):
PathImporter.add_modules(tmpmodule)
PathImporter.add_modules(tmpdir / tmpmodule)
with pytest.raises(FileNotFoundError):
PathImporter.add_modules('some_package.py')

0 comments on commit 4dcffab

Please sign in to comment.