Skip to content

Commit 7fde5fd

Browse files
committed
Move imports outside of test method code
PEP8 specifies that imports should be put at the top of a Python file: https://peps.python.org/pep-0008/#imports
1 parent 9922f5b commit 7fde5fd

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

_episodes/22-scaling-up-unit-testing.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ the `test_daily_mean_zeros()` and `test_daily_mean_integers()`
3838
into a single test function:
3939

4040
~~~
41+
from inflammation.models import daily_mean
42+
4143
@pytest.mark.parametrize(
4244
"test, expected",
4345
[
@@ -46,7 +48,6 @@ into a single test function:
4648
])
4749
def test_daily_mean(test, expected):
4850
"""Test mean function works for array of zeroes and positive integers."""
49-
from inflammation.models import daily_mean
5051
npt.assert_array_equal(daily_mean(np.array(test)), np.array(expected))
5152
~~~
5253
{: .language-python}
@@ -85,6 +86,8 @@ and adding more tests scales better as our code becomes more complex.
8586
>
8687
> > ## Solution
8788
> > ~~~
89+
> > from inflammation.models import daily_max
90+
> > from inflammation.models import daily_min
8891
> > ...
8992
> > @pytest.mark.parametrize(
9093
> > "test, expected",
@@ -95,7 +98,6 @@ and adding more tests scales better as our code becomes more complex.
9598
> > ])
9699
> > def test_daily_max(test, expected):
97100
> > """Test max function works for zeroes, positive integers, mix of positive/negative integers."""
98-
> > from inflammation.models import daily_max
99101
> > npt.assert_array_equal(daily_max(np.array(test)), np.array(expected))
100102
> >
101103
> >
@@ -108,7 +110,6 @@ and adding more tests scales better as our code becomes more complex.
108110
> > ])
109111
> > def test_daily_min(test, expected):
110112
> > """Test min function works for zeroes, positive integers, mix of positive/negative integers."""
111-
> > from inflammation.models import daily_min
112113
> > npt.assert_array_equal(daily_min(np.array(test)), np.array(expected))
113114
> > ...
114115
> > ~~~

0 commit comments

Comments
 (0)