You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -119,13 +119,14 @@ Let's have a look at how this works.
119
119
120
120
Similar to how fixtures are defined, the `@pytest.mark.parametrize` line is a decorator, letting pytest know that this is a parametrized test.
121
121
122
-
- The first argument is a tuple, a list of the names of the parameters you want to use in your test. For example
123
-
`("p1x, p2y, p2x, p2y, p3x, p3y, expected")` means that we will use the parameters `p1x`, `p1y`, `p2x`, `p2y`, `p3x`, `p3y` and `expected` in our test.
122
+
- The first argument is a string listing the names of the parameters you want to use in your test. For example
123
+
`"p1x, p2y, p2x, p2y, p3x, p3y, expected"` means that we will use the parameters `p1x`, `p1y`, `p2x`, `p2y`, `p3x`, `p3y` and `expected` in our test.
124
124
125
-
- The second argument is a list of `pytest.param` objects. Each `pytest.param` object is a tuple of the values you want to test, with an optional `id` argument to give a name to the test.
126
-
For example, `pytest.param(0, 0, 2, 0, 1, 1.7320, 6, id="Equilateral triangle")` means that we will test the function with the parameters `0, 0, 2, 0, 1, 1.7320, 6` and give it the name "Equilateral triangle".
125
+
- The second argument is a list of `pytest.param` objects. Each `pytest.param` object contains the values you want to test, with an optional `id` argument to give a name to the test.
127
126
128
-
(note that if the test fails you will see the id in the output, so it's useful to give them meaningful names to help you understand what went wrong.)
127
+
For example, `pytest.param(0, 0, 2, 0, 1, 1.732, 1.732, id="Equilateral triangle")` means that we will test the function with the parameters `0, 0, 2, 0, 1, 1.732, 1.732` and give it the name "Equilateral triangle".
128
+
129
+
Note that if the test fails you will see the id in the output, so it's useful to give them meaningful names to help you understand what went wrong.
129
130
130
131
- The test function will be run once for each set of parameters in the list.
131
132
@@ -135,7 +136,7 @@ This is a much more concise way to write tests for functions that need to be tes
135
136
136
137
::::::::::::::::::::::::::::::::::::: challenge
137
138
138
-
## Challenge - Practice with Parametrization
139
+
## Practice with Parametrization
139
140
140
141
Add the following function to `advanced/advanced_calculator.py` and write a parametrized test for it in `tests/test_advanced_calculator.py` that tests the function with a range of different inputs
0 commit comments