- Notifications
You must be signed in to change notification settings - Fork 244
/
Copy pathtest.py
29 lines (25 loc) · 1.03 KB
/
test.py
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
importio, sys, os, pytest, re
path=os.path.dirname(os.path.abspath(__file__))+'/app.py'
@pytest.mark.it("Concatenate both lists. Remember the odd list comes first")
deftest_odd_even(capsys, app):
importapp
captured=capsys.readouterr()
assert"[85, 59, 37, 25, 5, 81, 41, 55, 4, 80, 64, 66, 20, 64, 22, 76, 76, 96, 2, 68]\n"incaptured.out
@pytest.mark.it("Use the for loop")
deftest_for_loop():
withopen(path, 'r') ascontent_file:
content=content_file.read()
regex=re.compile(r"for(\s)")
assertbool(regex.search(content)) ==True
@pytest.mark.it("Use an if statement")
deftest_if():
withopen(path, 'r') ascontent_file:
content=content_file.read()
regex=re.compile(r"if(\s)")
assertbool(regex.search(content)) ==True
@pytest.mark.it('You should create a function named sort_odd_even')
deftest_variable_exists(app):
try:
app.sort_odd_even
exceptAttributeError:
raiseAttributeError("The function 'sort_odd_even' should exist on app.py")