Skip to content

Commit aec601a

Browse files
committed
handle optional args better
Signed-off-by: Zen <[email protected]>
1 parent ead316f commit aec601a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/test_main_funcs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ def test_named_init_argparser(self):
2626

2727
def _check_for_test_args(self, args):
2828
self.assertIsInstance(args, Namespace)
29-
if hasattr(args, "arg1"):
30-
self.assertEqual(args.arg1, "discover")
31-
if hasattr(args, "arg2"):
32-
self.assertEqual(args.arg2, "tests")
29+
if arg1 := getattr(args, "arg1", None):
30+
self.assertEqual(arg1, "discover")
31+
if arg2 := getattr(args, "arg2", None):
32+
self.assertEqual(arg2, "tests")
3333

3434
def test_get_args_n_logger(self):
3535
args, logger = get_args_n_logger("zenlib_test", "test description", get_test_args())

0 commit comments

Comments
 (0)