The nose testing suite applies introspection to asserts। में
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))
सूचना AssertionError वहाँ
import nose
def test1():
nose.tools.assert_equal(6, 5+2)
परिणाम:
हालांकि, AFAICT, आप कॉल करना उनके आत्मनिरीक्षण प्राप्त करने के लिए इस बात पर ज़ोर दिया है। जब मेरी लाइन बस assert 6 == 5+2
था, मैं मिलेगा:
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
इसके अलावा, मैं नहीं यकीन है कि बेतकल्लुफ़ पाता है अगर उनकी -O
साथ छोड़ दिया गया है, लेकिन यह एक बहुत त्वरित जांच होगी।
स्रोत
2009-08-20 21:09:49
, मैं इस में पता था। मैं एक लिखना नहीं चाहता क्योंकि यह अभिव्यक्ति में एन्कोड किया गया है जिसे जोर दिया जा रहा है। सूखी। –
मैं देखता हूं कि आपका क्या मतलब है। मुझे विश्वास नहीं है कि पाइथन के पास ऐसा करने का एक तरीका है। –