Merge branch 'unittest' into polynom

This commit is contained in:
Lafrite 2014-12-21 18:11:45 +01:00
commit 09ceb07f41
2 changed files with 14 additions and 21 deletions

View File

@ -2,34 +2,26 @@
# encoding: utf-8
import unittest
from pymath import arithmetic
class TestArithmetic(unittest.TestCase):
"""Testing functions from pymath.arithmetic"""
def test_gcd_commu():
assert arithmetic.gcd(3, 15) == arithmetic.gcd(15,3)
def test_gcd_commu(self):
self.assertEqual(arithmetic.gcd(3, 15), arithmetic.gcd(15,3))
def test_gcd1():
assert arithmetic.gcd(3, 15) == 3
def test_gcd1(self):
self.assertEqual(arithmetic.gcd(3, 15), 3)
def test_gcd2():
assert arithmetic.gcd(14, 21) == 7
def test_gcd2(self):
self.assertEqual(arithmetic.gcd(14, 21), 7)
def test_gcd_prem():
assert arithmetic.gcd(14, 19) == 1
def test_gcd_prem(self):
self.assertEqual(arithmetic.gcd(14, 19), 1)
def test_gcd_neg():
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
Expression.set_render(txt)
class TestExpression(unittest.TestCase):
"""Testing functions from pymath.expression"""
def setup(self):
Expression.set_render(txt)
def test_init_from_str(self):
exp = Expression("2 + 3")
self.assertEqual(exp.postfix_tokens, [2, 3, "+"])