Ahoj, jak tohohle docilili v ucebnici, ze na jednom radku maji py.test --pdb a o nekolik radku nize teprve test/calculate_test.py, dale co do tohoto souboru vlozit, aby byl vystup testu jako ten jejich. Dekuju moc
output: #test file code enclosed lower
$ py.test --pdb #if write this, will not result lines under
================================================================
= test session starts
================================================================
platform darwin -- Python 2.7.5 -- pytest-2.5.1
collected 2 items
test/calculate_test.py .F
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>> traceback
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
self = <test.calculate_test.TestCalculate
testMethod=test_add_method_returns_correct_result>
>
E
def test_add_method_returns_correct_result(self):
raise Exception()
Exception
test/calculate_test.py:11: Exception
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>> entering PDB
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>
/Users/username/workspace/python_testing/test/calculate_test.py(11)
test_add_method_returns_correct_result()
-> raise Exception()
(Pdb)
code of calculate_test.py :
import unittest
from app.calculate import Calculate
class TestCalculate(unittest.TestCase):
def setUp(self):
self.calc = Calculate()
def test_add_method_returns_correct_result(self):
"""
For this example you must remove the type restricitons placed on
the 'add' method in Calculate.
"""
print 'Hello'
self.assertEqual(4, self.calc.add(2, 2))
self.assertAlmostEquals(1, 1)
def test_add_method_raises_typeerror_if_not_ints(self):
self.assertRaises(TypeError, self.calc.add, "H", "I")
if __name__ == '__main__':
unittest.main()