Hi list,

I am rather new to py library and just started using py.test.

You may already have noticed, that the "assert" in magic-mode will
evaluate its arguments (e.g. the parts of an equality check) more than
once. This will not work, if the arguments have side effects, as in:

i = 1
def foo():
  global i
  i += 1
  return i

def test_foo():
  assert foo() == 3


Is there a common solution to this, other than the annoying

  foo_result = foo()
  assert foo_result == 3

thingie? Maybe py.test could preemptive cache all calls to assert
beforehand? Is this possible?


Ciao, Imi.

-- 
DF0E A04F 7063 69C5 A76B  7557 0A77 608F 9172 3535
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to