From fff148324fbbf14f82f33fe5b76f4d3ff40f86f0 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Sun, 21 Dec 2014 18:10:52 +0100 Subject: [PATCH] change test_arithmetic to be use with pytest. Add setup in test_expression --- test/test_arithmetic.py | 30 +++++++++++------------------- test/test_expression.py | 5 +++-- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/test/test_arithmetic.py b/test/test_arithmetic.py index f5cb2d6..3805958 100644 --- a/test/test_arithmetic.py +++ b/test/test_arithmetic.py @@ -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() diff --git a/test/test_expression.py b/test/test_expression.py index 3afceed..6955335 100644 --- a/test/test_expression.py +++ b/test/test_expression.py @@ -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, "+"])