Sunwoo Bae
- 60
- 4
I would like to make output only read:
Traceback (most recent call last):
AssertionError
... without giving the File "<input>", line 1, in <module>
The discussion revolves around how to handle and format assertion errors in Python, particularly in the context of unit testing. Participants explore different approaches to managing output when assertions fail, including the use of try...except blocks and the assertRaises function.
Participants do not reach a consensus, as there are multiple competing views on how to handle assertion errors and whether the original context is appropriate for unit testing.
There is uncertainty regarding the original poster's familiarity with unit testing frameworks and whether they are following a specific tutorial, which may affect their approach to handling assertions.
Individuals interested in Python programming, particularly those working with error handling and unit testing.
assertRaises in your test instead of testing the crash dump output.can you tell me what assertRaises exactly do and how to use it? I have never heard about it :(pbuk said:Oh its for unit testing? You should useassertRaisesin your test instead of testing the crash dump output.
try...except and how to get the message string from an AssertionError in a Python reference if you haven't covered them already (have you skipped some of the tutorial?).