Parcourir la source

Applied pep8 to unit tests.

Taddeus Kroes il y a 14 ans
Parent
commit
f51ea5e32c

+ 2 - 2
tests/rulestestcase.py

@@ -44,10 +44,10 @@ class RulesTestCase(unittest.TestCase):
         try:
             for i, exp in enumerate(rewrite_chain[:-1]):
                 self.assertMultiLineEqual(str(rewrite(exp)),
-                                          str(rewrite_chain[i+1]))
+                                          str(rewrite_chain[i + 1]))
         except AssertionError:  # pragma: nocover
             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: ---'
 

+ 2 - 2
tests/test_calc.py

@@ -12,11 +12,11 @@ class TestCalc(unittest.TestCase):
                 == N('+', L(1), L(4))
 
     def test_basic_on_exp(self):
-        expressions = [('4',   L(4)),
+        expressions = [('4', L(4)),
                        ('3+4', L(3) + L(4)),
                        ('3-4', L(3) + -L(4)),
                        ('3/4', L(3) / L(4)),
-                       ('-4',  -L(4)),
+                       ('-4', -L(4)),
                        ('3^4', N('^', L(3), L(4))),
                        ('(2)', L(2))]
 

+ 1 - 6
tests/test_exception.py

@@ -7,9 +7,4 @@ from tests.parser import ParserWrapper
 
 class TestException(unittest.TestCase):
     def test_raise(self):
-        try:
-            ParserWrapper(Parser).run(['raise'])
-        except RuntimeError:
-            return
-
-        raise AssertionError('Expected raised RuntimeError!') # pragma: nocover
+        self.assertRaises(RuntimeError, ParserWrapper(Parser).run, ['raise'])

+ 4 - 3
tests/test_rules_numerics.py

@@ -93,12 +93,13 @@ class TestRulesNumerics(RulesTestCase):
         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.assertEqualNodes(multiply_numerics(a * i3 * i2 * b, (i3, i2, 3, 2)),
-                              a * 6 * b)
+        self.assertEqualNodes(multiply_numerics(a * i3 * i2 * b,
+                              (i3, i2, 3, 2)), a * 6 * b)
 
     def test_multiply_numerics_negation(self):
         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')
         l1, neg = root

+ 2 - 1
tests/test_rules_powers.py

@@ -103,7 +103,8 @@ class TestRulesPowers(RulesTestCase):
         a, p, q = tree('a,p,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):
         a, p, q = tree('a,p,q')