Skip to content

Commit

Permalink
Improve testing of exit status.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Jul 15, 2018
1 parent 7d87b42 commit 8610709
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 9 deletions.
1 change: 1 addition & 0 deletions .pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
33 changes: 33 additions & 0 deletions .pytest_cache/v/cache/nodeids
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[
"tests/test_inform.py::test_grove",
"tests/test_inform.py::test_billfold",
"tests/test_inform.py::test_wring",
"tests/test_inform.py::test_fabricate",
"tests/test_inform.py::test_cartwheel",
"tests/test_inform.py::test_pardon",
"tests/test_inform.py::test_possess",
"tests/test_inform.py::test_unbuckle",
"tests/test_inform.py::test_franc",
"tests/test_utilities.py::test_debug",
"tests/test_utilities.py::test_indent",
"tests/test_utilities.py::test_conjoin",
"tests/test_utilities.py::test_cull",
"tests/test_utilities.py::test_fmt",
"tests/test_utilities.py::test_render",
"tests/test_utilities.py::test_plural",
"tests/test_utilities.py::test_full_stop",
"tests/test_utilities.py::test_os_error",
"tests/test_utilities.py::test_is_str",
"tests/test_utilities.py::test_is_iterable",
"tests/test_utilities.py::test_is_collection",
"tests/test_utilities.py::test_color",
"tests/test_utilities.py::test_join",
"tests/test_utilities.py::test_columns",
"tests/test_utilities.py::test_stream_policy",
"tests/test_utilities.py::test_exits",
"tests/test_utilities.py::test_error",
"tests/test_utilities.py::test_prog_name",
"tests/test_utilities.py::test_informer_attributes",
"tests/test_utilities.py::test_logging",
"tests/test_utilities.py::test_muting"
]
3 changes: 3 additions & 0 deletions .teneya.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Invoked as 'test.doctests.py' on Sunday, 15 July 2018 at 1:05:49 AM.
Initializing ...
teneya error: data.in: file not found.
2 changes: 1 addition & 1 deletion inform/inform.py
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ def done(self, exit=True):
self.logfile.close()
self.logfile = None
if exit:
sys.exit()
sys.exit(0)
else:
return

Expand Down
3 changes: 3 additions & 0 deletions tests/.pytest_cache/v/cache/lastfailed
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test_inform.py::test_pardon": true
}
11 changes: 11 additions & 0 deletions tests/.pytest_cache/v/cache/nodeids
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
"test_inform.py::test_grove",
"test_inform.py::test_billfold",
"test_inform.py::test_wring",
"test_inform.py::test_fabricate",
"test_inform.py::test_cartwheel",
"test_inform.py::test_pardon",
"test_inform.py::test_possess",
"test_inform.py::test_unbuckle",
"test_inform.py::test_franc"
]
21 changes: 14 additions & 7 deletions tests/test_inform.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ def test_cartwheel():

def test_pardon():
with messenger() as (msg, stdout, stderr, logfile):
try:
terminate()
assert False
except SystemExit as e:
assert e.args == (0,)

try:
raise Error('hey now!', culprit='nutz', extra='foo')
assert False
Expand All @@ -183,25 +189,26 @@ def test_pardon():
try:
err.terminate()
assert False
except SystemExit:
assert True
except SystemExit as e:
assert e.args == (1,)

try:
done()
assert False
except SystemExit:
assert True
except SystemExit as e:
assert e.args == (0,)

try:
terminate()
assert False
except SystemExit:
assert True
except SystemExit as e:
assert e.args == (1,)

try:
terminate_if_errors()
assert False
except SystemExit:
except SystemExit as e:
assert e.args == (1,)
assert True

def test_possess():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def callback():
status = {}
with pytest.raises(SystemExit) as exception:
done()
assert exception.value.args == ()
assert exception.value.args == (0,)
assert status.get('called') == True
captured = capsys.readouterr()
assert captured[0] == ''
Expand Down

0 comments on commit 8610709

Please sign in to comment.