FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-by-example/tests/case.py at main · ulcuber/python-by-example · GitHub
ulcuber
python-by-example
Repository navigation
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-by-example
/
tests
/
case.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
43 lines (34 loc) · 1.1 KB
Breadcrumbs
python-by-example
/
tests
/
case.py
Copy path
File metadata and controls
43 lines (34 loc) · 1.1 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"Base test case"
import
importlib
import
io
import
sys
import
unittest
class
TestCase
(
unittest
.
TestCase
):
"Common set up"
target
=
None
@
classmethod
def
setUpClass
(
cls
):
try
:
exercise
=
int
(
""
.
join
(
filter
(
str
.
isdigit
,
cls
.
__name__
)))
cls
.
target
=
importlib
.
import_module
(
f"src.exercise
{
exercise
}
"
)
except
ModuleNotFoundError
as
not_found
:
raise
unittest
.
SkipTest
(
f"Exercise
{
exercise
}
not implemented yet"
)
from
not_found
if
not
cls
.
target
.
main
:
raise
unittest
.
SkipTest
(
f"Exercise
{
exercise
}
has no main method"
)
@
classmethod
def
tearDownClass
(
cls
):
cls
.
target
=
None
def
setUp
(
self
)
->
None
:
self
.
output
=
io
.
StringIO
()
sys
.
stdout
=
self
.
output
return
super
().
setUp
()
def
tearDown
(
self
)
->
None
:
sys
.
stdout
=
sys
.
__stdout__
return
super
().
tearDown
()
def
assert_output
(
self
,
output
:
str
)
->
None
:
"""
Asserts captured output equal to argument string
"""
self
.
assertEqual
(
self
.
output
.
getvalue
(),
output
)
Back
|
FazBrowse Home
|
New Git URL