This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calculator(object): | |
def __init__(self): | |
self._last_answer = 0.0 | |
@property | |
def last_answer(self): | |
return self._last_answer | |
def add(self, a, b): | |
self._last_answer = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from com.automationpanda.example.calc import Calculator | |
NUMBER_1 = 3.0 | |
NUMBER_2 = 2.0 | |
FAILURE = 'incorrect value' | |
class CalculatorTest(unittest.TestCase): | |
def setUp(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if __name__ == '__main__': | |
import xmlrunner | |
unittest.main( | |
testRunner=xmlrunner.XMLTestRunner(output='test-reports'), | |
failfast=False, | |
buffer=False, | |
catchbreak=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(a, b): | |
""" | |
Adds two numbers. | |
>>> add(3, 2) | |
5 | |
""" | |
return a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Calculator(object): | |
def __init__(self): | |
self._last_answer = 0.0 | |
@property | |
def last_answer(self): | |
return self._last_answer | |
def add(self, a, b): | |
self._last_answer = a + b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The ``com.automationpanda.example.calc_class`` module | |
===================================================== | |
>>> from com.automationpanda.example.calc_class import Calculator | |
>>> calc = Calculator() | |
>>> calc.add(3, 2) | |
5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add pytest options here | |
[pytest] | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def add(a, b): | |
return a + b | |
def subtract(a, b): | |
return a - b | |
def multiply(a, b): | |
return a * b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_divide_by_zero(): | |
with pytest.raises(ZeroDivisionError) as e: | |
divide(NUMBER_1, 0) | |
assert "division by zero" in str(e.value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@pytest.mark.parametrize("a,b,expected", [ | |
(NUMBER_1, NUMBER_2, NUMBER_1), | |
(NUMBER_2, NUMBER_1, NUMBER_1), | |
(NUMBER_1, NUMBER_1, NUMBER_1), | |
]) | |
def test_maximum(a, b, expected): | |
assert maximum(a, b) == expected | |
@pytest.mark.parametrize("a,b,expected", [ |
OlderNewer