Skip to content

Commit b32b84b

Browse files
Add minimial testing of __main__ module
1 parent e7102e8 commit b32b84b

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

tests/test_main.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""tests/test_main.py.
2+
3+
Basic testing of hug's `__main__` module
4+
5+
Copyright (C) 2016 Timothy Edmund Crosley
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
8+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
9+
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
10+
to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or
13+
substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
16+
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
18+
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
19+
OTHER DEALINGS IN THE SOFTWARE.
20+
21+
"""
22+
import pytest
23+
24+
25+
def test_main(capsys):
26+
"""Main module should be importable, but should raise a SystemExit after CLI docs print"""
27+
with pytest.raises(SystemExit):
28+
from hug import __main__

0 commit comments

Comments
 (0)