Permalink
Browse files

Merge pull request #911 from toolforger/issue-2867-lambdify-raises

Issue 2867 lambdify raises
  • Loading branch information...
2 parents 6ad666b + 59e0af7 commit d2dd0674998187945c3db1a2b0b3a18d511fb4c8 @asmeurer asmeurer committed May 23, 2012
Showing with 967 additions and 835 deletions.
  1. +3 −3 sympy/assumptions/tests/test_query.py
  2. +5 −5 sympy/combinatorics/tests/test_permutations.py
  3. +3 −3 sympy/combinatorics/tests/test_prufer.py
  4. +5 −5 sympy/concrete/tests/test_products.py
  5. +4 −4 sympy/concrete/tests/test_sums_products.py
  6. +2 −2 sympy/core/tests/test_arit.py
  7. +3 −2 sympy/core/tests/test_assumptions.py
  8. +4 −4 sympy/core/tests/test_basic.py
  9. +6 −5 sympy/core/tests/test_containers.py
  10. +1 −1 sympy/core/tests/test_diff.py
  11. +17 −17 sympy/core/tests/test_evalf.py
  12. +2 −2 sympy/core/tests/test_expand.py
  13. +18 −15 sympy/core/tests/test_expr.py
  14. +4 −4 sympy/core/tests/test_facts.py
  15. +12 −12 sympy/core/tests/test_functions.py
  16. +6 −6 sympy/core/tests/test_logic.py
  17. +20 −19 sympy/core/tests/test_numbers.py
  18. +1 −1 sympy/core/tests/test_operations.py
  19. +2 −2 sympy/core/tests/test_relational.py
  20. +1 −1 sympy/core/tests/test_rules.py
  21. +8 −8 sympy/core/tests/test_sets.py
  22. +8 −8 sympy/core/tests/test_symbol.py
  23. +18 −16 sympy/core/tests/test_sympify.py
  24. +3 −3 sympy/core/tests/test_var.py
  25. +10 −10 sympy/functions/elementary/tests/test_miscellaneous.py
  26. +3 −3 sympy/functions/elementary/tests/test_piecewise.py
  27. +5 −5 sympy/functions/special/tests/test_delta_functions.py
  28. +1 −1 sympy/functions/special/tests/test_error_functions.py
  29. +3 −3 sympy/functions/special/tests/test_hyper.py
  30. +7 −7 sympy/functions/special/tests/test_spec_polynomials.py
  31. +25 −25 sympy/geometry/tests/test_geometry.py
  32. +10 −10 sympy/integrals/tests/test_integrals.py
  33. +1 −1 sympy/logic/tests/test_boolalg.py
  34. +3 −3 sympy/logic/tests/test_inference.py
  35. +4 −4 sympy/matrices/expressions/tests/test_indexing.py
  36. +15 −15 sympy/matrices/expressions/tests/test_matrix_exprs.py
  37. +2 −1 sympy/matrices/tests/test_immutable.py
  38. +1 −1 sympy/matrices/tests/test_interactions.py
  39. +113 −110 sympy/matrices/tests/test_matrices.py
  40. +11 −11 sympy/ntheory/tests/test_ntheory.py
  41. +2 −2 sympy/physics/quantum/tests/test_operatorset.py
  42. +1 −1 sympy/physics/quantum/tests/test_qubit.py
  43. +33 −33 sympy/physics/quantum/tests/test_spin.py
  44. +1 −1 sympy/physics/quantum/tests/test_state.py
  45. +4 −4 sympy/physics/tests/test_hydrogen.py
  46. +15 −15 sympy/polys/tests/test_densearith.py
  47. +8 −8 sympy/polys/tests/test_densebasic.py
  48. +8 −8 sympy/polys/tests/test_densetools.py
  49. +1 −1 sympy/polys/tests/test_distributedpolys.py
  50. +23 −23 sympy/polys/tests/test_domains.py
  51. +3 −3 sympy/polys/tests/test_factortools.py
  52. +8 −8 sympy/polys/tests/test_galoistools.py
  53. +1 −1 sympy/polys/tests/test_groebnertools.py
  54. +3 −3 sympy/polys/tests/test_monomialtools.py
  55. +9 −9 sympy/polys/tests/test_numberfields.py
  56. +5 −5 sympy/polys/tests/test_orthopolys.py
  57. +1 −1 sympy/polys/tests/test_partfrac.py
  58. +13 −13 sympy/polys/tests/test_polyclasses.py
  59. +3 −3 sympy/polys/tests/test_polyfuncs.py
  60. +30 −30 sympy/polys/tests/test_polyoptions.py
  61. +130 −130 sympy/polys/tests/test_polytools.py
  62. +5 −5 sympy/polys/tests/test_polyutils.py
  63. +6 −6 sympy/polys/tests/test_rootisolation.py
  64. +14 −14 sympy/polys/tests/test_rootoftools.py
  65. +4 −4 sympy/polys/tests/test_specialpolys.py
  66. +2 −2 sympy/polys/tests/test_sqfreetools.py
  67. +1 −1 sympy/printing/pretty/tests/test_pretty.py
  68. +1 −1 sympy/printing/tests/test_ccode.py
  69. +1 −1 sympy/printing/tests/test_fcode.py
  70. +1 −1 sympy/printing/tests/test_gtk.py
  71. +1 −1 sympy/printing/tests/test_lambdarepr.py
  72. +1 −1 sympy/printing/tests/test_latex.py
  73. +1 −1 sympy/printing/tests/test_mathml.py
  74. +1 −1 sympy/printing/tests/test_python.py
  75. +1 −1 sympy/printing/tests/test_repr.py
  76. +1 −1 sympy/printing/tests/test_str.py
  77. +5 −5 sympy/series/tests/test_limits.py
  78. +3 −3 sympy/series/tests/test_nseries.py
  79. +3 −3 sympy/series/tests/test_order.py
  80. +1 −1 sympy/series/tests/test_residues.py
  81. +3 −3 sympy/series/tests/test_series.py
  82. +6 −6 sympy/simplify/tests/test_epathtools.py
  83. +11 −9 sympy/simplify/tests/test_hyperexpand.py
  84. +4 −4 sympy/solvers/tests/test_inequalities.py
  85. +2 −2 sympy/solvers/tests/test_numeric.py
  86. +8 −8 sympy/solvers/tests/test_ode.py
  87. +3 −3 sympy/solvers/tests/test_pde.py
  88. +2 −2 sympy/solvers/tests/test_polysys.py
  89. +8 −8 sympy/solvers/tests/test_solvers.py
  90. +9 −9 sympy/stats/tests/test_continuous_rv.py
  91. +2 −2 sympy/stats/tests/test_finite_rv.py
  92. +4 −3 sympy/stats/tests/test_rv.py
  93. +1 −1 sympy/tensor/tests/test_index_methods.py
  94. +13 −13 sympy/tensor/tests/test_indexed.py
  95. +81 −13 sympy/utilities/pytest.py
  96. +2 −2 sympy/utilities/tests/test_autowrap.py
  97. +7 −7 sympy/utilities/tests/test_codegen.py
  98. +4 −4 sympy/utilities/tests/test_iterables.py
  99. +11 −11 sympy/utilities/tests/test_lambdify.py
  100. +61 −12 sympy/utilities/tests/test_pytest.py
@@ -1224,7 +1224,7 @@ class Prime2AskHandler(AskHandler):
def Number(expr, assumptions):
return True
register_handler('prime', Prime2AskHandler)
- raises(ValueError, 'ask(Q.prime(4))')
+ raises(ValueError, lambda: ask(Q.prime(4)))
remove_handler('prime', Prime2AskHandler)
class InconclusiveHandler(AskHandler):
@@ -1237,7 +1237,7 @@ def Number(expr, assumptions):
def test_key_extensibility():
"""test that you can add keys to the ask system at runtime"""
# make sure the key is not defined
- raises(AttributeError, "ask(Q.my_key(x))")
+ raises(AttributeError, lambda: ask(Q.my_key(x)))
class MyAskHandler(AskHandler):
@staticmethod
def Symbol(expr, assumptions):
@@ -1247,7 +1247,7 @@ def Symbol(expr, assumptions):
assert ask(Q.my_key(x+1)) == None
remove_handler('my_key', MyAskHandler)
del Q.my_key
- raises(AttributeError, "ask(Q.my_key(x))")
+ raises(AttributeError, lambda: ask(Q.my_key(x)))
def test_type_extensibility():
"""test that new types can be added to the ask system at runtime
@@ -195,8 +195,8 @@ def test_args():
assert p._array_form == [0, 3, 1, 2]
assert Permutation([0]) == Permutation((0, ))
assert Permutation([[0], [1]]) == Permutation(((0, ), (1, ))) == Permutation(((0, ), [1]))
- raises(ValueError, 'Permutation([[1, 2], [3]])') # 0, 1, 2 should be present
- raises(ValueError, 'Permutation([1, 2, 3])') # 0, 1, 2 should be present
- raises(ValueError, 'Permutation(0, 1, 2)') # enclosing brackets needed
- raises(ValueError, 'Permutation([1, 2], [0])') # enclosing brackets needed
- raises(ValueError, 'Permutation([[1, 2], 0])') # enclosing brackets needed on 0
+ raises(ValueError, lambda: Permutation([[1, 2], [3]])) # 0, 1, 2 should be present
+ raises(ValueError, lambda: Permutation([1, 2, 3])) # 0, 1, 2 should be present
+ raises(ValueError, lambda: Permutation(0, 1, 2)) # enclosing brackets needed
+ raises(ValueError, lambda: Permutation([1, 2], [0])) # enclosing brackets needed
+ raises(ValueError, lambda: Permutation([[1, 2], 0])) # enclosing brackets needed on 0
@@ -26,10 +26,10 @@ def test_prufer():
Prufer(tree).tree_repr == tree
Prufer(set(tree)).tree_repr == tree
- raises(ValueError, 'Prufer([[1, 2], [3, 4]])') # 0 is missing
+ raises(ValueError, lambda: Prufer([[1, 2], [3, 4]])) # 0 is missing
assert Prufer(*Prufer.edges([1, 2], [3, 4])).prufer_repr == [1, 3]
- raises(ValueError, 'Prufer.edges([1, 3], [3, 4])') # a broken tree but edges doesn't care
- raises(ValueError, 'Prufer.edges([1, 2], [5, 6])')
+ raises(ValueError, lambda: Prufer.edges([1, 3], [3, 4])) # a broken tree but edges doesn't care
+ raises(ValueError, lambda: Prufer.edges([1, 2], [5, 6]))
def test_round_trip():
def doit(t,b):
@@ -19,11 +19,11 @@ def test_simple_products():
assert isinstance(product(k**k, (k, 1, n)), Product)
- raises(ValueError, 'Product(n)')
- raises(ValueError, 'Product(n, k)')
- raises(ValueError, 'Product(n, k, 1)')
- raises(ValueError, 'Product(n, k, 1, 10)')
- raises(ValueError, 'Product(n, (k, 1))')
+ raises(ValueError, lambda: Product(n))
+ raises(ValueError, lambda: Product(n, k))
+ raises(ValueError, lambda: Product(n, k, 1))
+ raises(ValueError, lambda: Product(n, k, 1, 10))
+ raises(ValueError, lambda: Product(n, (k, 1)))
def test_multiple_products():
assert product(x, (n, 1, k), (k, 1, m)) == x**(m**2/2 + m/2)
@@ -228,8 +228,8 @@ def test_telescopic_sums():
def test_sum_reconstruct():
s = Sum(n**2, (n, -1, 1))
assert s == Sum(*s.args)
- raises(ValueError, 'Sum(x, x)')
- raises(ValueError, 'Sum(x, (x, 1))')
+ raises(ValueError, lambda: Sum(x, x))
+ raises(ValueError, lambda: Sum(x, (x, 1)))
def test_Sum_limit_subs():
assert Sum(a*exp(a), (a, -2, 2)) == Sum(a*exp(a), (a, -b, b)).subs(b, 2)
@@ -259,8 +259,8 @@ def test_Sum_interface():
assert Sum(0, (n, 0, 2)).doit() == 0
assert isinstance(Sum(0, (n, 0, oo)), Sum)
assert Sum(0, (n, 0, oo)).doit() == 0
- raises(ValueError, "Sum(1)")
- raises(ValueError, "summation(1)")
+ raises(ValueError, lambda: Sum(1))
+ raises(ValueError, lambda: summation(1))
def test_eval_diff():
assert Sum(x, (x, 1, 2)).diff(x) == 0
@@ -1395,7 +1395,7 @@ def test_float_int():
assert int(Add(1.2, -2, evaluate=False)) == int(1.2 - 2)
assert int(Add(1.2, +2, evaluate=False)) == int(1.2 + 2)
assert int(Add(1 + Float('.99999999999999999', ''), evaluate=False)) == 1
- raises(TypeError, 'float(x)')
- raises(TypeError, 'float(sqrt(-1))')
+ raises(TypeError, lambda: float(x))
+ raises(TypeError, lambda: float(sqrt(-1)))
assert int(12345678901234567890 + cos(1)**2 + sin(1)**2) == 12345678901234567891
@@ -455,7 +455,8 @@ def test_other_symbol():
assert x.is_integer == True
assert x.is_nonpositive == True
- raises(AttributeError, "x.is_real = False")
+ with raises(AttributeError):
+ x.is_real = False
def test_issue726():
"""catch: hash instability"""
@@ -576,4 +577,4 @@ def test_special_assumptions():
def test_inconsistent():
# cf. issues 2696 and 2446
- raises(InconsistentAssumptions, "Symbol('x', real=True, commutative=False)")
+ raises(InconsistentAssumptions, lambda: Symbol('x', real=True, commutative=False))
@@ -55,8 +55,8 @@ def test_subs():
assert b21.subs({b1: b2, b2: b1}) == Basic(b2, b2)
- raises(ValueError, "b21.subs('bad arg')")
- raises(ValueError, "b21.subs(b1, b2, b3)")
+ raises(ValueError, lambda: b21.subs('bad arg'))
+ raises(ValueError, lambda: b21.subs(b1, b2, b3))
def test_atoms():
assert b21.atoms() == set()
@@ -78,8 +78,8 @@ def test_xreplace():
assert Basic(b1, b2).xreplace({b1: b2, b2: b1}) == Basic(b2, b1)
assert Atom(b1).xreplace({b1: b2}) == Atom(b1)
assert Atom(b1).xreplace({Atom(b1): b2}) == b2
- raises(TypeError, 'b1.xreplace()')
- raises(TypeError, 'b1.xreplace([b1,b2])')
+ raises(TypeError, lambda: b1.xreplace())
+ raises(TypeError, lambda: b1.xreplace([b1,b2]))
def test_Singleton():
global instanciated
@@ -36,8 +36,8 @@ def test_Tuple_concatenation():
assert Tuple(1, 2) + Tuple(3, 4) == Tuple(1, 2, 3, 4)
assert (1, 2) + Tuple(3, 4) == Tuple(1, 2, 3, 4)
assert Tuple(1, 2) + (3, 4) == Tuple(1, 2, 3, 4)
- raises(TypeError, 'Tuple(1, 2) + 3')
- raises(TypeError, '1 + Tuple(2, 3)')
+ raises(TypeError, lambda: Tuple(1, 2) + 3)
+ raises(TypeError, lambda: 1 + Tuple(2, 3))
#the Tuple case in __radd__ is only reached when a subclass is involved
class Tuple2(Tuple):
@@ -89,7 +89,7 @@ def test_Dict():
d = Dict({x:1, y:2, z:3})
assert d[x] == 1
assert d[y] == 2
- raises(KeyError, 'd[2]')
+ raises(KeyError, lambda: d[2])
assert len(d) == 3
assert set(d.keys()) == set((x,y,z))
assert set(d.values()) == set((S(1),S(2),S(3)))
@@ -103,8 +103,9 @@ def test_Dict():
assert (Dict({x:1, y:2, z:3}) ==
Dict((x,1), (y,2), (z,3)))
- raises(TypeError, "Dict(((x,1), (y,2), (z,3)))")
- raises(NotImplementedError, "d[5] = 6") # assert immutability
+ raises(TypeError, lambda: Dict(((x,1), (y,2), (z,3))))
+ with raises(NotImplementedError):
+ d[5] = 6 # assert immutability
assert set(d.items()) == set((Tuple(x,S(1)), Tuple(y,S(2)), Tuple(z,S(3))))
assert set(d) == set([x,y,z])
@@ -9,7 +9,7 @@ def test_diff():
assert pi.diff(x) is S.Zero
assert x.diff(x, 0) == x
assert (x**2).diff(x, 2, x) == 0
- raises(ValueError, 'x.diff(1, x)')
+ raises(ValueError, lambda: x.diff(1, x))
a = Symbol("a")
b = Symbol("b")
@@ -164,7 +164,7 @@ def test_evalf_bugs():
def test_evalf_integer_parts():
a = floor(log(8)/log(2) - exp(-1000), evaluate=False)
b = floor(log(8)/log(2), evaluate=False)
- raises(PrecisionExhausted, "a.evalf()")
+ raises(PrecisionExhausted, lambda: a.evalf())
assert a.evalf(chop=True) == 3
assert a.evalf(maxn=500) == 2
assert b.evalf() == 3
@@ -184,24 +184,24 @@ def test_evalf_trig_zero_detection():
assert abs(t) < 1e-100
assert t._prec < 2
assert a.evalf(chop=True) == 0
- raises(PrecisionExhausted, "a.evalf(strict=True)")
+ raises(PrecisionExhausted, lambda: a.evalf(strict=True))
def test_evalf_divergent_series():
- raises(ValueError, 'Sum(1/n, (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum(n/(n**2+1), (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum((-1)**n, (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum((-1)**n, (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum(n**2, (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum(2**n, (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum((-2)**n, (n, 1, oo)).evalf()')
- raises(ValueError, 'Sum((2*n+3)/(3*n**2+4), (n,0, oo)).evalf()')
- raises(ValueError, 'Sum((0.5*n**3)/(n**4+1),(n,0,oo)).evalf()')
+ raises(ValueError, lambda: Sum(1/n, (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum(n/(n**2+1), (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum((-1)**n, (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum((-1)**n, (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum(n**2, (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum(2**n, (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum((-2)**n, (n, 1, oo)).evalf())
+ raises(ValueError, lambda: Sum((2*n+3)/(3*n**2+4), (n,0, oo)).evalf())
+ raises(ValueError, lambda: Sum((0.5*n**3)/(n**4+1),(n,0,oo)).evalf())
def test_evalf_py_methods():
assert abs(float(pi+1) - 4.1415926535897932) < 1e-10
assert abs(complex(pi+1) - 4.1415926535897932) < 1e-10
assert abs(complex(pi+E*I) - (3.1415926535897931+2.7182818284590451j)) < 1e-10
- raises(TypeError, "float(pi+x)")
+ raises(TypeError, lambda: float(pi+x))
def test_evalf_power_subs_bugs():
assert (x**2).evalf(subs={x:0}) == 0
@@ -214,7 +214,7 @@ def test_evalf_power_subs_bugs():
assert (0**x).evalf(subs={x:0}) == 1
def test_evalf_arguments():
- raises(TypeError, 'pi.evalf(method="garbage")')
+ raises(TypeError, lambda: pi.evalf(method="garbage"))
def test_implemented_function_evalf():
from sympy.utilities.lambdify import implemented_function
@@ -302,10 +302,10 @@ def test_scaled_zero():
a, b = (([1], 1, 100, 1), -1)
assert scaled_zero(100, -1) == (a, b)
assert scaled_zero(a) == (1, 1, 100, 1)
- raises(ValueError, 'scaled_zero(scaled_zero(100))')
- raises(ValueError, 'scaled_zero(100, 2)')
- raises(ValueError, 'scaled_zero(100, 0)')
- raises(ValueError, 'scaled_zero((1, 5, 1, 3))')
+ raises(ValueError, lambda: scaled_zero(scaled_zero(100)))
+ raises(ValueError, lambda: scaled_zero(100, 2))
+ raises(ValueError, lambda: scaled_zero(100, 0))
+ raises(ValueError, lambda: scaled_zero((1, 5, 1, 3)))
def test_chop_value():
for i in range(-27, 28):
@@ -62,8 +62,8 @@ def test_expand_modulus():
assert ((x + sqrt(2)*y)**11).expand(modulus=11) == x**11 + 10*sqrt(2)*y**11
assert (x + y/2).expand(modulus=1) == y/2
- raises(ValueError, "((x + y)**11).expand(modulus=0)")
- raises(ValueError, "((x + y)**11).expand(modulus=x)")
+ raises(ValueError, lambda: ((x + y)**11).expand(modulus=0))
+ raises(ValueError, lambda: ((x + y)**11).expand(modulus=x))
def test_issue_2644():
assert (x*sqrt(x + y)*(1 + sqrt(x + y))).expand() == x**2 + x*y + x*sqrt(x + y)
@@ -169,12 +169,15 @@ def test_relational_noncommutative():
def test_basic_nostr():
for obj in basic_objs:
- for op in ['+','-','*','/','**']:
- if obj == 2 and op == '*':
- if hasattr(int, '__index__'): # Python 2.5+ (PEP 357)
- assert obj * '1' == '11'
- else:
- raises(TypeError, "obj %s '1'" % op)
+ raises(TypeError, lambda: obj + '1')
+ raises(TypeError, lambda: obj - '1')
+ if obj == 2:
+ if hasattr(int, '__index__'): # Python 2.5+ (PEP 357)
+ assert obj * '1' == '11'
+ else:
+ raises(TypeError, lambda: obj * '1')
+ raises(TypeError, lambda: obj / '1')
+ raises(TypeError, lambda: obj ** '1')
def test_leadterm():
assert (3+2*x**(log(3)/log(2)-1)).leadterm(x) == (3,0)
@@ -344,7 +347,7 @@ def _sympy_(self):
e = Rational(2)*m
assert e == 10
- raises(TypeError, "Rational(2)*MyInt")
+ raises(TypeError, lambda: Rational(2)*MyInt)
def test_SAGE2():
class MyInt(object):
@@ -354,7 +357,7 @@ def __int__(self):
e = Rational(2)*MyInt()
assert e == 10
- raises(TypeError, "Rational(2)*MyInt")
+ raises(TypeError, lambda: Rational(2)*MyInt)
def test_SAGE3():
class MySymbol:
@@ -383,9 +386,9 @@ def test_doit():
assert (2*Integral(x, x)).doit() == x**2
def test_attribute_error():
- raises(AttributeError, "x.cos()")
- raises(AttributeError, "x.sin()")
- raises(AttributeError, "x.exp()")
+ raises(AttributeError, lambda: x.cos())
+ raises(AttributeError, lambda: x.sin())
+ raises(AttributeError, lambda: x.exp())
def test_args():
assert (x*y).args in ((x, y), (y, x))
@@ -1027,7 +1030,7 @@ def test_args_cnc():
[set([x]), []]
assert Mul(x, x**2, evaluate=False).args_cnc(cset=True, warn=False) == \
[set([x, x**2]), []]
- raises(ValueError, 'Mul(x, x, evaluate=False).args_cnc(cset=True)')
+ raises(ValueError, lambda: Mul(x, x, evaluate=False).args_cnc(cset=True))
assert Mul(x, y, x, evaluate=False).args_cnc() == \
[[x, y, x], []]
@@ -1199,7 +1202,7 @@ def test_issue_1100():
# difference gives S.NaN
a = x - y
assert a._eval_interval(x, 1, oo)._eval_interval(y, oo, 1) is S.NaN
- raises(ValueError, 'x._eval_interval(x, None, None)')
+ raises(ValueError, lambda: x._eval_interval(x, None, None))
def test_primitive():
assert (3*(x + 1)**2).primitive() == (3, (x + 1)**2)
@@ -1326,7 +1329,7 @@ def test_round():
assert (pi + sqrt(2)).round(2) == 4.56
assert (10*(pi + sqrt(2))).round(-1) == 50
- raises(TypeError, 'round(x + 2, 2)')
+ raises(TypeError, lambda: round(x + 2, 2))
assert S(2.3).round(1) == 2.3
e = S(12.345).round(2)
assert e == round(12.345, 2)
@@ -1347,7 +1350,7 @@ def test_round():
assert a.round(27) == Float('2.999999999999999999999999999','')
assert a.round(30) == Float('2.999999999999999999999999999','')
- raises(TypeError, 'x.round()')
+ raises(TypeError, lambda: x.round())
# exact magnitude of 10
assert str(S(1).round()) == '1.'
@@ -28,9 +28,9 @@ def D(i):
assert D([('a','b'), ('b','a')]) == ({'a': set(['b']), 'b': set(['a'])}, {'a': set(['b']), 'b': set(['a'])})
# see if it catches inconsistency
- raises(ValueError, "D([('a',Not('a'))])")
- raises(ValueError, "D([('a','b'), ('b',Not('a'))])")
- raises(ValueError, "D([('a','b'), ('b','c'), ('b','na'), ('na',Not('a'))])")
+ raises(ValueError, lambda: D([('a',Not('a'))]))
+ raises(ValueError, lambda: D([('a','b'), ('b',Not('a'))]))
+ raises(ValueError, lambda: D([('a','b'), ('b','c'), ('b','na'), ('na',Not('a'))]))
# something related to real-world
@@ -133,7 +133,7 @@ def test_FactRules_parse():
def test_FactRules_parse2():
- raises(ValueError, "FactRules('a -> !a')")
+ raises(ValueError, lambda: FactRules('a -> !a'))
def test_FactRules_deduce():
f = FactRules(['a -> b', 'b -> c', 'b -> d', 'c -> e'])
Oops, something went wrong.

0 comments on commit d2dd067

Please sign in to comment.