Skip to content

Commit fba3503

Browse files
Merge pull request #33 from r1chardj0n3s/improve-test-coverage
Improve test coverage
2 parents 2e9db49 + 1268e7a commit fba3503

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
3838
- name: "Run tests"
3939
run: |
40-
# We currently require 94% test coverage and not 100% as this is the
40+
# We currently require 96% test coverage and not 100% as this is the
4141
# level that coverage was at when the CI restriction was introduced.
42-
pytest -s -vvv --cov-fail-under 94 --cov=pip_check_reqs/ --cov=tests tests/ --cov-report=xml
42+
pytest -s -vvv --cov-fail-under 96 --cov=pip_check_reqs/ --cov=tests tests/ --cov-report=xml
4343
4444
- name: "Upload coverage to Codecov"
4545
uses: "codecov/codecov-action@v1"

tests/test_common.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import collections
55
import logging
66
import os.path
7-
import sys
87

98
import pytest
109
import pretend
@@ -100,10 +99,6 @@ def test_find_imported_modules(monkeypatch, caplog, ignore_ham, ignore_hashlib,
10099
monkeypatch.setattr(common, 'pyfiles',
101100
pretend.call_recorder(lambda x: ['spam.py', 'ham.py']))
102101

103-
if sys.version_info[0] == 2:
104-
# py2 will find sys module but py3k won't
105-
expect.append('sys')
106-
107102
class FakeFile():
108103
contents = [
109104
'from os import path\nimport ast, hashlib',

tests/test_find_extra_reqs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
import pretend
99

10-
from pip_check_reqs import find_extra_reqs, common
10+
from pip_check_reqs import find_extra_reqs, common, __version__
1111

1212

1313
@pytest.fixture
@@ -90,7 +90,8 @@ def test_main_failure(monkeypatch, caplog, fake_opts):
9090

9191
with pytest.raises(SystemExit) as excinfo:
9292
find_extra_reqs.main()
93-
assert excinfo.value == 1
93+
94+
assert excinfo.value.code == 1
9495

9596
assert caplog.records[0].message == \
9697
'Extra requirements:'
@@ -108,7 +109,8 @@ def test_main_no_spec(monkeypatch, caplog, fake_opts):
108109

109110
with pytest.raises(SystemExit) as excinfo:
110111
find_extra_reqs.main()
111-
assert excinfo.value == 2
112+
113+
assert excinfo.value.code == 2
112114

113115
assert fake_opts.error.calls
114116

@@ -164,4 +166,5 @@ def test_main_version(monkeypatch, caplog, fake_opts):
164166

165167
with pytest.raises(SystemExit) as excinfo:
166168
find_extra_reqs.main()
167-
assert excinfo.value == 'version'
169+
170+
assert str(excinfo.value) == __version__

tests/test_find_missing_reqs.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import pytest
88
import pretend
99

10-
from pip_check_reqs import find_missing_reqs, common
10+
from pip_check_reqs import find_missing_reqs, common, __version__
1111

1212

1313
@pytest.fixture
@@ -85,7 +85,8 @@ def test_main_failure(monkeypatch, caplog, fake_opts):
8585

8686
with pytest.raises(SystemExit) as excinfo:
8787
find_missing_reqs.main()
88-
assert excinfo.value == 1
88+
89+
assert excinfo.value.code == 1
8990

9091
assert caplog.records[0].message == \
9192
'Missing requirements:'
@@ -103,7 +104,8 @@ def test_main_no_spec(monkeypatch, caplog, fake_opts):
103104

104105
with pytest.raises(SystemExit) as excinfo:
105106
find_missing_reqs.main()
106-
assert excinfo.value == 2
107+
108+
assert excinfo.value.code == 2
107109

108110
assert fake_opts.error.calls
109111

@@ -158,4 +160,5 @@ def test_main_version(monkeypatch, caplog, fake_opts):
158160

159161
with pytest.raises(SystemExit) as excinfo:
160162
find_missing_reqs.main()
161-
assert excinfo.value == 'version'
163+
164+
assert str(excinfo.value) == __version__

0 commit comments

Comments
 (0)