Skip to content

Commit

Permalink
changed path inserting
Browse files Browse the repository at this point in the history
run tests from anywhere without specifying PYTHONPATH
  • Loading branch information
zcqian committed Aug 19, 2021
1 parent c714d31 commit f396b85
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/local_web_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install PyTest
run: pip install pytest
- name: Run App Tests
run: PYTHONPATH=../.. pytest test_local.py
run: pytest test_local.py
working-directory: src/tests/app
services:
Elasticsearch:
Expand Down
7 changes: 6 additions & 1 deletion src/tests/app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
Config file to run tests for MyVariant.info
"""
import os as _os
import sys as _sys
import importlib.util as _imp_util

CONFIG_FILE_NAME = "config_web.py"

# find the path of the config file
_cfg_path = _os.path.abspath(_os.path.join(_os.path.curdir, CONFIG_FILE_NAME))
_cur_dir = _os.path.dirname(_os.path.realpath(__file__))
_cfg_path = _os.path.abspath(_os.path.join(_cur_dir, CONFIG_FILE_NAME))
while True:
if _os.path.exists(_cfg_path):
break
Expand All @@ -31,6 +33,9 @@
if not _k.startswith('_'):
globals()[_k] = _v

# insert module import path
_sys.path.insert(0, _os.path.dirname(_cfg_path))

# cleanup
del CONFIG_FILE_NAME

Expand Down

0 comments on commit f396b85

Please sign in to comment.