diff --git a/run_tests.py b/run_tests.py old mode 100644 new mode 100755 index 39675c6..24114b6 --- a/run_tests.py +++ b/run_tests.py @@ -1,9 +1,7 @@ #!/usr/bin/env python import os -from os.path import dirname, join, abspath import sqlite3 import sys -import os import re @@ -95,16 +93,21 @@ def main(): # Statically check if ``package_name`` is installed outside of the repo. # To do this, we make a copy of PYTHONPATH, remove the repodir, and use # ubelt to check to see if ``package_name`` can be resolved to a path. - temp_path = list(map(abspath, sys.path)) - if repo_dir in temp_path: - temp_path.remove(repo_dir) + temp_path = [pathlib.Path(p).resolve() for p in sys.path] + _resolved_repo_dir = repo_dir.resolve() + if _resolved_repo_dir in temp_path: + temp_path.remove(_resolved_repo_dir) + print(f'[run_tests] Searching for installed version of {package_name}.') modpath = ub.modname_to_modpath(package_name, sys_path=temp_path) if modpath is not None: # If it does, then import it. This should cause the installed version # to be used on further imports even if the repo_dir is in the path. print(f'[run_tests] Using installed version of {package_name}') - module = ub.import_module_from_path(modpath, index=0) - print(f'[run_tests] Installed module = {module!r}') + print(f'[run_tests] modpath={modpath}') + modpath_contents = list(pathlib.Path(modpath).glob('*')) + print(f'[run_tests] modpath_contents = {ub.urepr(modpath_contents, nl=1)}') + # module = ub.import_module_from_path(modpath, index=0) + # print(f'[run_tests] Installed module = {module!r}') else: print(f'[run_tests] No installed version of {package_name} found') @@ -113,12 +116,9 @@ def main(): os.chdir(test_dir) testdir_contents = list(pathlib.Path(test_dir).glob('*')) - modpath_contents = list(pathlib.Path(modpath).glob('*')) - pyproject_fpath = join(repo_dir, 'pyproject.toml') + pyproject_fpath = repo_dir / 'pyproject.toml' print(f'[run_tests] pyproject_fpath = {pyproject_fpath}') - print(f'[run_tests] modpath={modpath}') print(f'[run_tests] test_dir={test_dir}') - print(f'[run_tests] modpath_contents = {ub.urepr(modpath_contents, nl=1)}') print(f'[run_tests] testdir_contents = {ub.urepr(testdir_contents, nl=1)}') pytest_args = [