Skip to content

Commit a8fe866

Browse files
author
krsm
committed
added code related to pytest parameters
1 parent bc9eef4 commit a8fe866

File tree

9 files changed

+84
-7
lines changed

9 files changed

+84
-7
lines changed

.idea/General-Python.iml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 35 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Unitests/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- coding: utf-8 -*-
2+
# to be treated as a python package
3+
4+

Unitests/pystest_stdy/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# -*- coding: utf-8 -*-
2+
# to be treated as a python package
3+
4+

Unitests/pystest_stdy/math_file.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,7 @@ def calc_sum(a, b):
1212

1313
def calc_multiply(a, b):
1414
return a*b
15+
16+
17+
def calc_square(n):
18+
return n*n

Unitests/pystest_stdy/test_math.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33
44
Simple study related to pytest
55
6+
Use command line pytest -v to run tests
7+
68
"""
79

810
from Unitests.pystest_stdy import math_file
11+
import pytest
912

1013

1114
# first test
@@ -16,6 +19,19 @@ def test_calc_sum():
1619

1720
# second test
1821
def test_calc_multiply():
19-
total = math_file.calc_sum(4, 6)
22+
total = math_file.calc_multiply(4, 6)
2023
assert total == 24
2124

25+
26+
# third test
27+
@pytest.mark.parametrize("test_input, expected_output",
28+
[
29+
(5, 25),
30+
(9, 81),
31+
(10, 100),
32+
])
33+
def test_calc_square(test_input, expected_output):
34+
result = math_file.calc_square(test_input)
35+
assert result == expected_output
36+
37+

asyncio_stdy.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)