Skip to content

Commit

Permalink
Added tox.ini and fix unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
schaefi committed Feb 26, 2024
1 parent e3c0206 commit 7b2c121
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 2 deletions.
5 changes: 4 additions & 1 deletion tests/test_obs_img_utils_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from obs_img_utils.exceptions import PackageVersionExceptionOBS


class TestAPI(object):
class TestAPI:
def setup(self):
self.downloader = OBSImageUtil(
'https://provo-mirror.opensuse.org/repositories/',
Expand All @@ -33,6 +33,9 @@ def setup(self):
target_directory='tests/data'
)

def setup_method(self, cls):
self.setup()

def test_version_compare(self):
result = self.downloader._version_compare('1.0', '2.0', '<=')
assert result
Expand Down
2 changes: 1 addition & 1 deletion tests/test_obs_img_utils_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def test_image_download(
'apparmor-parser\n'
'\n'
'2.12.2\n'
'lp150.6.14.1\n'
'\n'
'n\n'
'y\n'
'GPL\n'
Expand Down
52 changes: 52 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[tox]
minversion = 3.3.0
isolated_build = True
skip_missing_interpreters = True
skipsdist = True
envlist =
unit_py3,
check


[testenv]
whitelist_externals =
/bin/bash
basepython =
check: python3
unit_py3: python3
envdir =
check: {toxworkdir}/3
unit_py3: {toxworkdir}/3
passenv =
*
usedevelop = True
deps =
-r requirements-dev.txt


# Unit Test run with basepython set to 3.x
[testenv:unit_py3]
skip_install = True
usedevelop = True
setenv =
PYTHONPATH={toxinidir}/tests
PYTHONUNBUFFERED=yes
WITH_COVERAGE=yes
passenv =
*
deps = {[testenv]deps}
commands =
python3 setup.py develop
py.test --no-cov-on-fail --cov=obs_img_utils \
--cov-report=term-missing --cov-fail-under=90 --cov-config .coveragerc



# Source code quality/integrity check
[testenv:check]
deps = {[testenv]deps}
skip_install = True
usedevelop = True
commands =
flake8 --statistics -j auto --count {toxinidir}/obs_img_utils
flake8 --statistics -j auto --count {toxinidir}/tests

0 comments on commit 7b2c121

Please sign in to comment.