5
मैं जोर देकर unittest का उपयोग कर रहा हूं कि मेरी स्क्रिप्ट सही SystemExit
कोड उठाती है।Unittest: दाएं सिस्टमएक्सिट कोड
से http://docs.python.org/3.3/library/unittest.html#unittest.TestCase.assertRaises
with self.assertRaises(SomeException) as cm:
do_something()
the_exception = cm.exception
self.assertEqual(the_exception.error_code, 3)
उदाहरण के आधार पर मैं कोडित इस:
with self.assertRaises(SystemExit) as cm:
do_something()
the_exception = cm.exception
self.assertEqual(the_exception.error_code, 3)
बहरहाल, यह काम नहीं करता। निम्नलिखित त्रुटि ऊपर आता है:
AttributeError: 'SystemExit' object has no attribute 'error_code'