initial commit with 2024 materials
This commit is contained in:
commit
6fdfdbb8b7
66 changed files with 102457 additions and 0 deletions
28
testing_project/demos/test_parametrize.py
Normal file
28
testing_project/demos/test_parametrize.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import pytest
|
||||
|
||||
|
||||
def test_for_loop_simple():
|
||||
cases = [1, 2, 3]
|
||||
for a in cases:
|
||||
assert a > 0
|
||||
|
||||
|
||||
@pytest.mark.parametrize('a', [1, 2, 3])
|
||||
def test_parametrize_simple(a):
|
||||
# This test will be run 3 times, with a=1, a=2, and a=3
|
||||
assert a > 0
|
||||
|
||||
|
||||
def test_for_loop_multiple():
|
||||
cases = [(1, 'hi', 'hi'), (2, 'no', 'nono')]
|
||||
for a, b, expected in cases:
|
||||
result = b * a
|
||||
assert result == expected
|
||||
|
||||
|
||||
@pytest.mark.parametrize('a, b, expected', [(1, 'hi', 'hi'), (2, 'no', 'nono')])
|
||||
def test_parametrize_multiple(a, b, expected):
|
||||
# This test will be run 2 times, with a=1, b='hi', expected='hi'
|
||||
# and a=2, b='no', expected='nono'
|
||||
result = b * a
|
||||
assert result == expected
|
Loading…
Add table
Add a link
Reference in a new issue