-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
executable file
·24 lines (20 loc) · 888 Bytes
/
tests.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
import io, sys, pytest, os, re, mock
@pytest.mark.it("Declare a function called 'is_odd' as lambda")
def test_declare_variable():
path = os.path.dirname(os.path.abspath(__file__))+'/app.py'
with open(path, 'r') as content_file:
content = content_file.read()
regex = re.compile(r"is_odd(\s*)=(\s*)lambda")
assert bool(regex.search(content)) == True
@pytest.mark.it('The function is_odd must exist')
def test_for_callable(capsys):
import app as app
assert callable(app.is_odd)
@pytest.mark.it('The function is_odd must receive one number and return True if the number is odd or False otherwise')
def test_for_integer(capsys):
import app as app
assert app.is_odd(3) == True
@pytest.mark.it('We tested the function with 2 and the result was not False')
def test_for_integer2(capsys):
import app as app
assert app.is_odd(2) == False