change test_arithmetic to be use with pytest. Add setup in

test_expression
This commit is contained in:
Lafrite 2014-12-21 18:10:52 +01:00
parent a38ba53577
commit fff148324f
2 changed files with 14 additions and 21 deletions

View File

@ -2,34 +2,26 @@
# encoding: utf-8 # encoding: utf-8
import unittest
from pymath import arithmetic from pymath import arithmetic
class TestArithmetic(unittest.TestCase): def test_gcd_commu():
"""Testing functions from pymath.arithmetic""" assert arithmetic.gcd(3, 15) == arithmetic.gcd(15,3)
def test_gcd_commu(self): def test_gcd1():
self.assertEqual(arithmetic.gcd(3, 15), arithmetic.gcd(15,3)) assert arithmetic.gcd(3, 15) == 3
def test_gcd1(self): def test_gcd2():
self.assertEqual(arithmetic.gcd(3, 15), 3) assert arithmetic.gcd(14, 21) == 7
def test_gcd2(self): def test_gcd_prem():
self.assertEqual(arithmetic.gcd(14, 21), 7) assert arithmetic.gcd(14, 19) == 1
def test_gcd_prem(self): def test_gcd_neg():
self.assertEqual(arithmetic.gcd(14, 19), 1) assert arithmetic.gcd(3, -15) == 3
assert arithmetic.gcd(-3, -15) == -3
def test_gcd_neg(self):
self.assertEqual(arithmetic.gcd(3, -15), 3)
self.assertEqual(arithmetic.gcd(-3, -15), -3)
if __name__ == '__main__':
unittest.main()

View File

@ -11,11 +11,12 @@ from pymath.generic import first_elem
from pymath.render import txt, tex from pymath.render import txt, tex
Expression.set_render(txt)
class TestExpression(unittest.TestCase): class TestExpression(unittest.TestCase):
"""Testing functions from pymath.expression""" """Testing functions from pymath.expression"""
def setup(self):
Expression.set_render(txt)
def test_init_from_str(self): def test_init_from_str(self):
exp = Expression("2 + 3") exp = Expression("2 + 3")
self.assertEqual(exp.postfix_tokens, [2, 3, "+"]) self.assertEqual(exp.postfix_tokens, [2, 3, "+"])