Skip to content

Commit 1658a4b

Browse files
committedFeb 2, 2020
adding chap4 code
1 parent 3c555c8 commit 1658a4b

File tree

5 files changed

+45
-2
lines changed

5 files changed

+45
-2
lines changed
 

‎chapter4/Makefile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
install:
2+
pip install --upgrade pip &&\
3+
pip install -r requirements.txt
4+
5+
test:
6+
python -m pytest -vv test_hello.py
7+
8+
9+
lint:
10+
pylint --disable=R,C hello.py
11+
12+
all: install lint test

‎chapter4/hello.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
def toyou():
2-
return "hi"
1+
def toyou(x):
2+
return f"hi {x}"
3+
4+
5+
def add(x):
6+
return x + 1
7+
8+
9+
def subtract(x):
10+
return x - 1

‎chapter4/requirements.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pylint
2+
pytest
3+
black

‎chapter4/test_hello.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from hello import toyou, add, subtract
2+
3+
4+
def setup_function(function):
5+
print(f" Running Setup: {function.__name__}")
6+
function.x = 10
7+
8+
9+
def teardown_function(function):
10+
print(f" Running Teardown: {function.__name__}")
11+
del function.x
12+
13+
14+
### Run to see failed test
15+
#def test_hello_add():
16+
# assert add(test_hello_add.x) == 12
17+
18+
def test_hello_subtract():
19+
assert subtract(test_hello_subtract.x) == 9

‎requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pytest
33
pytest-cov
44
jupyter
55
click
6+
devml

0 commit comments

Comments
 (0)
Please sign in to comment.