Commit f51ea5e3 authored by Taddeus Kroes's avatar Taddeus Kroes

Applied pep8 to unit tests.

parent c7a9125f
...@@ -44,10 +44,10 @@ class RulesTestCase(unittest.TestCase): ...@@ -44,10 +44,10 @@ class RulesTestCase(unittest.TestCase):
try: try:
for i, exp in enumerate(rewrite_chain[:-1]): for i, exp in enumerate(rewrite_chain[:-1]):
self.assertMultiLineEqual(str(rewrite(exp)), self.assertMultiLineEqual(str(rewrite(exp)),
str(rewrite_chain[i+1])) str(rewrite_chain[i + 1]))
except AssertionError: # pragma: nocover except AssertionError: # pragma: nocover
print 'rewrite failed: "%s" -> "%s"' \ print 'rewrite failed: "%s" -> "%s"' \
% (str(exp), str(rewrite_chain[i+1])) % (str(exp), str(rewrite_chain[i + 1]))
print 'rewrite chain index: %d' % i print 'rewrite chain index: %d' % i
print 'rewrite chain: ---' print 'rewrite chain: ---'
......
...@@ -7,9 +7,4 @@ from tests.parser import ParserWrapper ...@@ -7,9 +7,4 @@ from tests.parser import ParserWrapper
class TestException(unittest.TestCase): class TestException(unittest.TestCase):
def test_raise(self): def test_raise(self):
try: self.assertRaises(RuntimeError, ParserWrapper(Parser).run, ['raise'])
ParserWrapper(Parser).run(['raise'])
except RuntimeError:
return
raise AssertionError('Expected raised RuntimeError!') # pragma: nocover
...@@ -93,12 +93,13 @@ class TestRulesNumerics(RulesTestCase): ...@@ -93,12 +93,13 @@ class TestRulesNumerics(RulesTestCase):
self.assertEqual(multiply_numerics(i3 * f2, (i3, f2, 3, 2.0)), 6.0) self.assertEqual(multiply_numerics(i3 * f2, (i3, f2, 3, 2.0)), 6.0)
self.assertEqual(multiply_numerics(f3 * f2, (f3, f2, 3.0, 2.0)), 6.0) self.assertEqual(multiply_numerics(f3 * f2, (f3, f2, 3.0, 2.0)), 6.0)
self.assertEqualNodes(multiply_numerics(a * i3 * i2 * b, (i3, i2, 3, 2)), self.assertEqualNodes(multiply_numerics(a * i3 * i2 * b,
a * 6 * b) (i3, i2, 3, 2)), a * 6 * b)
def test_multiply_numerics_negation(self): def test_multiply_numerics_negation(self):
l1_neg, l2 = root = tree('-1 * 2') l1_neg, l2 = root = tree('-1 * 2')
self.assertEqualNodes(multiply_numerics(root, (l1_neg, l2, -1, 2)), -l2) self.assertEqualNodes(multiply_numerics(root, (l1_neg, l2, -1, 2)),
-l2)
root, l6 = tree('1 - 2 * 3,6') root, l6 = tree('1 - 2 * 3,6')
l1, neg = root l1, neg = root
......
...@@ -103,7 +103,8 @@ class TestRulesPowers(RulesTestCase): ...@@ -103,7 +103,8 @@ class TestRulesPowers(RulesTestCase):
a, p, q = tree('a,p,q') a, p, q = tree('a,p,q')
n0, n1 = root = a ** p * a ** q n0, n1 = root = a ** p * a ** q
self.assertEqualNodes(add_exponents(root, (n0, n1, a, p, q)), a ** (p + q)) self.assertEqualNodes(add_exponents(root, (n0, n1, a, p, q)),
a ** (p + q))
def test_subtract_exponents(self): def test_subtract_exponents(self):
a, p, q = tree('a,p,q') a, p, q = tree('a,p,q')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment