More specific raise reason
This commit is contained in:
13
test.py
13
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):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user