From 952ffecf1730e1d0026c15650c8b259dab0b1dcf Mon Sep 17 00:00:00 2001 From: Pavel Lutskov Date: Fri, 2 Apr 2021 19:16:09 +0200 Subject: [PATCH] More specific raise reason --- test.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/test.py b/test.py index 22407a4..ff3431a 100644 --- a/test.py +++ b/test.py @@ -1,3 +1,4 @@ +from argparse import ArgumentError, ArgumentTypeError import unittest from typing import List @@ -14,23 +15,21 @@ class TestArgClass(unittest.TestCase): assert A.parse_args(['--arg1', 'hello']) == A(arg1='hello') - @unittest.expectedFailure def test__required_argument_missing(self): @argclass class A: arg1: str - A.parse_args([]) + self.assertRaises(SystemExit, A.parse_args, []) - @unittest.expectedFailure def test__required_argument_wrong_given(self): @argclass class A: arg1: str - A.parse_args(['--arg2', 'hello']) + self.assertRaises(SystemExit, A.parse_args, ['--arg2', 'hello']) def test__optional_argument_missing(self): @@ -48,14 +47,13 @@ class TestArgClass(unittest.TestCase): assert A.parse_args(['--arg2', 'welt']) == A(arg2='welt') - @unittest.expectedFailure def test__optional_argument_wrong_given(self): @argclass class A: arg2: str = 'world' - A.parse_args(['--arg3', 'welt']) + self.assertRaises(SystemExit, A.parse_args, ['--arg3', 'welt']) def test__boolean_true(self): @@ -81,14 +79,13 @@ class TestArgClass(unittest.TestCase): assert A.parse_args(['--arg4', '42']) == A(arg4=42) - @unittest.expectedFailure def test__int_malformed(self): @argclass class A: arg4: int - A.parse_args(['--arg4', '4e2']) + self.assertRaises(SystemExit, A.parse_args, ['--arg4', '4e2']) def test__list(self):