-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_stats.py
40 lines (30 loc) · 879 Bytes
/
test_stats.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
30
31
32
33
34
35
36
37
38
39
40
import pytest
from stats import get_all_line_counts, create_stats_report
EXPECTED_OUTPUT = """
Basic statistics:
- count : 186
- min : 6
- max : 337
- mean : 43.74
Population variance:
- pstdev : 43.04
- pvariance : 1852.39
Estimated variance for sample:
- count : 93.00
- stdev : 30.24
- variance : 914.36
"""
@pytest.fixture
def report():
return create_stats_report()
def test_get_all_line_counts():
counts = list(get_all_line_counts())
# total number of test files / bites
assert len(counts) == 186
# all elements should be ints
assert all(isinstance(c, int) for c in counts)
# total lines of test code written
assert sum(counts) == 8135
@pytest.mark.parametrize("line", EXPECTED_OUTPUT.strip().splitlines())
def test_create_stats_report(report, line):
assert line in report