-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_fixtures.py
More file actions
30 lines (20 loc) · 798 Bytes
/
test_fixtures.py
File metadata and controls
30 lines (20 loc) · 798 Bytes
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
import pytest
# Marked to pytest as a fixture function
@pytest.fixture
def data_set():
return (-111, -33.3, -5, 0, 0.67, 12, 25.02, 100, 'abc')
# Exercise 1 # add together all the positive numbers in an iterable, and return the total
def positive_numbers_sum(numbers):
total = 0
for n in numbers:
if n > 0:
total += n
return total
# # Exercise 2 # Test function that includes fixture function data set in the parameter
def test_positive_numbers_sum(data_set):
assert positive_numbers_sum(data_set) == 147.69
# Test function #
# running 'pytest test_fixtures.py' in git bash folder
# Test FAILED # Why?
# TypeError: '>' not supported between instances of 'str' and 'int'
# String data (non-numberic values) in the tuple return cause the error