From c4bafa375d8aa387201a6f622aff3d22f1753b31 Mon Sep 17 00:00:00 2001 From: David Luevano Alvarado Date: Sat, 18 Feb 2023 20:37:30 -0600 Subject: add simple test feature --- tests/__init__.py | 0 tests/conftest.py | 7 +++++++ tests/test_arg_parser.py | 16 ++++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/test_arg_parser.py (limited to 'tests') diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..9368432 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,7 @@ +import pytest +from pyssg.arg_parser import get_parser + + +@pytest.fixture +def arg_parser(): + return get_parser() \ No newline at end of file diff --git a/tests/test_arg_parser.py b/tests/test_arg_parser.py new file mode 100644 index 0000000..45263ce --- /dev/null +++ b/tests/test_arg_parser.py @@ -0,0 +1,16 @@ +import pytest +from argparse import ArgumentParser + + +@pytest.mark.parametrize('args, arg_name, exp_result', [ + (['--version'], 'version', True), + (['-v'], 'version', True), + (['--config', 'value'], 'config', 'value'), + (['-c', 'value'], 'config', 'value'), +]) +def test_individual_args(args: list[str], + arg_name: str, + exp_result: str | bool, + arg_parser: ArgumentParser) -> None: + parsed_args: dict[str, str | bool] = vars(arg_parser.parse_args(args)) + assert parsed_args[arg_name] == exp_result -- cgit v1.2.3-70-g09d2