This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Unittest incorrect result with argparse.ArgumentError in self asserRaises context
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.8
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: iritkatriel, piscvau, serhiy.storchaka
Priority: normal Keywords:

Created on 2021-08-16 09:52 by piscvau, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit piscvau, 2021-08-16 09:52 reproduces the error
Messages (3)
msg399640 - (view) Author: Troulet-lambert Odile (piscvau) Date: 2021-08-16 09:52
When passed an Argparse.ArgumentError in the self.assertRaises context uniittest does not recognize the exception and raises an exception.
As a consequence the test fails whereas it should pass
msg399644 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2021-08-16 10:32
What is the output of the failed test?
msg399645 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-08-16 10:40
You raise ArgumentTypeError, but expect ArgumentError. ArgumentTypeError is not a subclass of ArgumentError.
Date User Action Args
2022-04-11 14:59:48adminsetgithub: 89086
2021-08-19 17:24:09serhiy.storchakasetstatus: open -> closed
resolution: not a bug
stage: resolved
2021-08-16 10:40:03serhiy.storchakasetnosy: + serhiy.storchaka

messages: + msg399645
versions: + Python 3.8, - Python 3.6
2021-08-16 10:32:44iritkatrielsetnosy: + iritkatriel

messages: + msg399644
versions: + Python 3.6, - Python 3.8
2021-08-16 09:52:33piscvaucreate