diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04d2ab9..eb80118 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,7 +10,7 @@ jobs: max-parallel: 4 matrix: # Up to date compatibility matrix - python-version: [2.7, 3.5, 3.6, 3.7, 3.8] + python-version: [3.7, 3.8, 3.9, "3.10"] os: [ubuntu-latest, windows-latest] steps: @@ -20,8 +20,6 @@ jobs: with: python-version: ${{ matrix.python-version }} - name: Install dependencies - env: - DJANGO_VERSION: ${{ matrix.django-version }} run: | python -m pip install --upgrade pip make testenv diff --git a/Makefile b/Makefile index 77d627f..de73690 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ testenv: pip install -e . test: - nosetests --with-coverage --cover-erase --cover-branches --cover-package=clinto clinto/tests/* + pytest --cov=clinto --cov-config=.coveragerc clinto/tests/* coverage report --omit='clinto/tests*' coverage xml --omit='clinto/tests*' diff --git a/clinto/parsers/argparse_.py b/clinto/parsers/argparse_.py index be3cec3..a2bad59 100644 --- a/clinto/parsers/argparse_.py +++ b/clinto/parsers/argparse_.py @@ -337,7 +337,27 @@ def extract_parser(self): try: ast_source = source_parser.parse_source_file(self.script_path) python_code = source_parser.convert_to_python(list(ast_source)) + f.write(six.b(""" +import builtins +from types import ModuleType + +class DummyModule(ModuleType): + def __getattr__(self, key): + return None + __all__ = [] # support wildcard imports + +def tryimport(name, globals={}, locals={}, fromlist=[], level=-1): + try: + return realimport(name, globals, locals, fromlist, level) + except (ImportError, ModuleNotFoundError): + return DummyModule(name) + +realimport, builtins.__import__ = builtins.__import__, tryimport +""")) f.write(six.b("\n".join(python_code))) + f.write(six.b(""" +builtins.__import__ = realimport +""")) f.seek(0) module = imp.load_source("__main__", f.name) except Exception: diff --git a/requirements.txt b/requirements.txt index 4cd1c0f..3650850 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ coveralls -nose +pytest +pytest-cov diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 2a37a14..0000000 --- a/tox.ini +++ /dev/null @@ -1,5 +0,0 @@ -[tox] -envlist = py27,py35,py36 -[testenv] -deps=nose -commands=nosetests