-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENT-4252: Migrate from nose to pytest
* Card ID: ENT-4252 This commit replaces nosetests with pytest as a test suite. The DBus tests have been disabled, because they fail when not run under nosetests, and will have to be fixed before they are enabled again. They can be selected manually by using the '-m dbus' flag.
- Loading branch information
Showing
34 changed files
with
193 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,4 @@ | ||
[run] | ||
branch = True | ||
source = subscription_manager | ||
rct | ||
rhsm | ||
rhsm_debug | ||
content_plugins | ||
[report] | ||
include = src/* | ||
source = src/ | ||
command_line = -m pytest test/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
*.so | ||
*.o | ||
.idea* | ||
.pytest_cache | ||
*.coverage | ||
.ropeproject | ||
*.cov2emacs.log | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[pytest] | ||
addopts = | ||
# Non-registered markers raise errors | ||
--strict-markers | ||
# Start with tests that failed last time, --ff | ||
--failed-first | ||
# Show extra summary for (f)ailed, (E)rror, (s)kipped and (w)arnings | ||
-rfEsw | ||
# Mark some tests not to be run | ||
-m "not dbus and not functional" | ||
markers = | ||
dbus: subscription-manager tests for DBus. | ||
slow: subscription-manager tests that may be slower than the rest. | ||
zypper: subscription-manager tests for the Zypper package manager. | ||
functional: subscription-manager functional tests. | ||
timeout = 5 | ||
testpaths = | ||
test/ | ||
required_plugins = | ||
pytest-randomly | ||
pytest-timeout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,32 @@ | ||
from __future__ import print_function, division, absolute_import | ||
|
||
import os | ||
import pathlib | ||
import sys | ||
from typing import Callable, List | ||
|
||
from . import rhsm_display | ||
rhsm_display.set_display() | ||
|
||
# Hijack sys.path, so we don't have to use 'PYTHONPATH=src/' prefix | ||
rootdir = pathlib.Path(__file__).parent.parent | ||
sys.path.insert(0, str(rootdir / "src")) | ||
|
||
import pytest | ||
|
||
subman_marker_dbus = pytest.mark.dbus | ||
subman_marker_functional = pytest.mark.functional | ||
subman_marker_zypper = pytest.mark.zypper | ||
subman_marker_slow = pytest.mark.slow | ||
# This allows us to set higher timeout limit for tests that are known to be slow | ||
subman_marker_slow_timeout = pytest.mark.timeout(40) | ||
|
||
|
||
def subman_marker_needs_envvars(*envvars: List[str]) -> Callable: | ||
"""Skip test if one or more environment variables are missing.""" | ||
missing_vars: List[str] = [v for v in envvars if v not in os.environ] | ||
skip_func: Callable = pytest.mark.skipif( | ||
missing_vars, | ||
reason=f"Missing environment variables {', '.join(missing_vars)}." | ||
) | ||
return skip_func |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.