The nose testing suite applies introspection to asserts.
Sin embargo, AFAICT, tiene que llamar a su afirma para obtener la introspección:
import nose
def test1():
nose.tools.assert_equal(6, 5+2)
resultados en
C:\temp\py>C:\Python26\Scripts\nosetests.exe -d test.py
F
======================================================================
FAIL: test.test1
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\nose-0.11.1-py2.6.egg\nose\case.py", line
183, in runTest
self.test(*self.arg)
File "C:\temp\py\test.py", line 3, in test1
nose.tools.assert_equal(6, 5+2)
AssertionError: 6 != 7
>> raise self.failureException, \
(None or '%r != %r' % (6, 7))
Aviso del AssertionError allí. Cuando mi línea era sólo assert 6 == 5+2
, me sale:
C:\temp\py>C:\Python26\Scripts\nosetests.exe -d test.py
F
======================================================================
FAIL: test.test1
----------------------------------------------------------------------
Traceback (most recent call last):
File "C:\Python26\lib\site-packages\nose-0.11.1-py2.6.egg\nose\case.py", line
183, in runTest
self.test(*self.arg)
File "C:\temp\py\test.py", line 2, in test1
assert 6 == 5 + 2
AssertionError:
>> assert 6 == 5 + 2
Además, no estoy seguro de si su improvisada afirma se saltan con -O
, pero eso sería un cheque muy rápido.
Por supuesto, sabía que esto. No quiero escribir uno ya que está codificado en la expresión que se afirma. SECO. –
Veo lo que quieres decir. No creo que Python tenga una forma de hacer esto. –