Skip to content

Commit

Permalink
Clean up test output (#20)
Browse files Browse the repository at this point in the history
* Introduce mocker to selectively supress logger output
* Re-order functional assertion to catch bad executions early
  • Loading branch information
pcmxgti authored Feb 4, 2020
1 parent 996045a commit 55e61b6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pydocstyle==3.0.0
pyroma
pytest
pytest-env
pytest-mock
pytest-ordering
semver
tox
4 changes: 2 additions & 2 deletions tests/functional_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ def test_package_exists():
def test_version(package_version, package_regex, runnable):
"""Check if the package version is the same when running in different ways."""
proc = run_process(runnable)
match = re.match(package_regex, proc['stdout'])
local_version = match.group('version')
assert not proc['stderr']
assert proc['exit_status'] == 0
match = re.match(package_regex, proc['stdout'])
local_version = match.group('version')
assert package_version == local_version


Expand Down
5 changes: 3 additions & 2 deletions tests/unit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_process_arguments(valid_settings, invalid_settings):

@pytest.mark.skipif(sys.version_info[:2] == (3, 5),
reason="ConfigParser bug, see https://bugs.python.org/issue29623")
def test_process_ini_file(tmpdir, valid_settings, invalid_settings):
def test_process_ini_file(tmpdir, valid_settings, invalid_settings, mocker):
"""Test whether ini config elements are correctly set in settings.*."""
from tokendito import helpers, settings
# Create a mock config file
Expand All @@ -180,7 +180,8 @@ def test_process_ini_file(tmpdir, valid_settings, invalid_settings):

# Ensure we fail if the section is not found
with pytest.raises(SystemExit) as err:
helpers.process_ini_file(path, 'expected_failure')
mocker.patch('logging.error')
helpers.process_ini_file(path, 'pytest_expected_failure')
# assert err.type == SystemExit
assert err.value.code == 2

Expand Down

0 comments on commit 55e61b6

Please sign in to comment.