diff --git a/test/__init__.py b/test/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/test/conftest.py b/test/conftest.py index c95e25c6ce8af247f6e92ea9f5a8d633500d5d50..1721bed6508d9c4dc0c5bae84a604a5f0b0df53a 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -14,11 +14,9 @@ import inventory_provider from inventory_provider.tasks import worker from inventory_provider import config -TEST_DATA_DIRNAME = os.path.realpath(os.path.join( - inventory_provider.__path__[0], - "..", - "test", - "data")) +TEST_DATA_DIRNAME = os.path.join( + os.path.dirname(__file__), + "data") _bootstrap_semaphore = threading.Semaphore() @@ -43,7 +41,7 @@ def data_config_filename(): "api": "ims_api", "username": "ims_username", "password": "ims_password" - }, + }, "managed-routers": "bogus url", "unmanaged-interfaces": [ { @@ -224,10 +222,10 @@ NETIFACES_TEST_DATA_STRING = """{ def mocked_netifaces(mocker): s = NETIFACES_TEST_DATA_STRING for k, v in { - 'AF_INET': netifaces.AF_INET, - 'AF_INET6': netifaces.AF_INET6, - 'AF_LINK': netifaces.AF_LINK - }.items(): + 'AF_INET': netifaces.AF_INET, + 'AF_INET6': netifaces.AF_INET6, + 'AF_LINK': netifaces.AF_LINK + }.items(): s = s.replace('{%s}' % k, str(v)) data = ast.literal_eval(s) mocker.patch('netifaces.interfaces', lambda: data.keys()) diff --git a/test/test_junos_devices_query.py b/test/test_junos_devices_query.py index c22657d9f50841b5961de3dd92b398b03aeef83f..b1ef7ee2b1691c056eb139e163b52d8c977a0866 100644 --- a/test/test_junos_devices_query.py +++ b/test/test_junos_devices_query.py @@ -2,13 +2,10 @@ import os import responses -import inventory_provider from inventory_provider import juniper TEST_DATA_FILENAME = os.path.realpath(os.path.join( - inventory_provider.__path__[0], - '..', - 'test', + os.path.dirname(__file__), 'data', 'netdash-alldevices.txt')) diff --git a/tox.ini b/tox.ini index 869caf127d265a85be95bca984c1df81a0a1983d..5f3a77c48df6405ee89e60dc609701836610d7bf 100644 --- a/tox.ini +++ b/tox.ini @@ -5,20 +5,21 @@ envlist = py36 exclude = venv,.tox,build max-line-length = 120 +[coverage:run] +concurrency = multiprocessing,thread + [testenv] passenv = TEST_OPSDB_HOSTNAME,TEST_OPSDB_DBNAME,TEST_OPSDB_USERNAME,TEST_OPSDB_PASSWORD deps = - coverage + pytest-xdist + pytest-cov flake8 -r requirements.txt #install_command = pip install --pre --extra-index-url http://pip.geant.net/ --trusted-host pip.geant.net {opts} {packages} commands = coverage erase - coverage run --source inventory_provider -m pytest {posargs} - coverage xml - coverage html - coverage report --fail-under 80 + pytest -n auto --cov inventory_provider --cov-fail-under=80 --cov-report html --cov-report xml --cov-report term -p no:checkdocs flake8 sphinx-build -M html docs/source docs/build