wtsi-npg / npg_conda

NPG Conda recipes and tools
1 stars 15 forks source link

Rewrite automation test script in python #264

Closed mksanger closed 3 years ago

kjsanger commented 3 years ago

What's the best way to run these locally? I've tried cding to gitlab_test and running pytest:

gitlab_test$ pytest
================================================================= test session starts =================================================================
platform linux -- Python 3.8.3, pytest-5.4.1, py-1.9.0, pluggy-0.13.1
rootdir: /home/keith/dev/work/cloud/npg_conda/tools/automation/gitlab_test, inifile: pytest.ini, testpaths: tests
plugins: it-0.1.4
collected 0 items / 2 errors                                                                                                                          

======================================================================= ERRORS ========================================================================
_______________________________________________________ ERROR collecting tests/channel_test.py ________________________________________________________
ImportError while importing test module '/home/keith/dev/work/cloud/npg_conda/tools/automation/gitlab_test/tests/channel_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/channel_test.py:6: in <module>
    from channel import Channel
E   ModuleNotFoundError: No module named 'channel'
_______________________________________________________ ERROR collecting tests/package_test.py ________________________________________________________
ImportError while importing test module '/home/keith/dev/work/cloud/npg_conda/tools/automation/gitlab_test/tests/package_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/package_test.py:5: in <module>
    from conda.cli.python_api import Commands, run_command
E   ModuleNotFoundError: No module named 'conda'
=============================================================== short test summary info ===============================================================
ERROR tests/channel_test.py
ERROR tests/package_test.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================== 2 errors in 0.08s ==================================================================
mksanger commented 3 years ago

What's the best way to run these locally? I've tried cding to gitlab_test and running pytest:

I'll add something to make this more clear, it needs to be run as a module, python -m pytest. That adds gitlab_test to the path.

kjsanger commented 3 years ago

There's a few lines longer than PEP8 would like (PEP 8: E501 line too long (89 > 79 characters))

kjsanger commented 3 years ago

Fails with No module named 'networkx' so needs requirements fo that too.

kjsanger commented 3 years ago

Fails with No module named 'networkx' so needs requirements fo that too.

kjsanger commented 3 years ago
gitlab_test$ python -m pytest .
================================================================= test session starts =================================================================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: /home/keith/dev/work/cloud/npg_conda/tools/automation/gitlab_test, configfile: pytest.ini
plugins: mock-3.6.1
collected 6 items / 1 error / 5 selected                                                                                                              

======================================================================= ERRORS ========================================================================
___________________________________________________________ ERROR collecting gitlab_test.py ___________________________________________________________
gitlab_test.py:34: in <module>
    args = parser.parse_args()
/home/keith/.local/miniconda/envs/npg_conda/lib/python3.9/argparse.py:1821: in parse_args
    self.error(msg % ' '.join(argv))
/home/keith/.local/miniconda/envs/npg_conda/lib/python3.9/argparse.py:2575: in error
    self.exit(2, _('%(prog)s: error: %(message)s\n') % args)
/home/keith/.local/miniconda/envs/npg_conda/lib/python3.9/argparse.py:2562: in exit
    _sys.exit(status)
E   SystemExit: 2
------------------------------------------------------------------- Captured stderr -------------------------------------------------------------------
usage: __main__.py [-h] [-b BUILD_DIR] [-c CHANGES] [-p PROD_CHANNEL]
                   [-d DEVEL_CHANNEL]
__main__.py: error: unrecognized arguments: .
================================================================== warnings summary ===================================================================
../../../../../../../.local/miniconda/envs/npg_conda/lib/python3.9/site-packages/conda/_vendor/auxlib/_vendor/five.py:49
  /home/keith/.local/miniconda/envs/npg_conda/lib/python3.9/site-packages/conda/_vendor/auxlib/_vendor/five.py:49: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    from imp import reload                  # noqa

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=============================================================== short test summary info ===============================================================
ERROR gitlab_test.py - SystemExit: 2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================= 1 warning, 1 error in 0.70s =============================================================
mksanger commented 3 years ago

gitlab_test$ python -m pytest .

I didn't mean to edit it... without the . should work, including that makes it try to run gitlab_test.py, which obviously fails due to not having any arguments. Any ideas for a name for that script that doesn't include the word test?