diff options
author | David Luevano Alvarado <david@luevano.xyz> | 2023-02-18 20:37:30 -0600 |
---|---|---|
committer | David Luevano Alvarado <david@luevano.xyz> | 2023-02-18 20:37:30 -0600 |
commit | c4bafa375d8aa387201a6f622aff3d22f1753b31 (patch) | |
tree | 8c17fb9aec5c6e930c13f312a561bf0be09e5e55 | |
parent | 0259f32e880041e3fbfd7bfba2698723c71700c8 (diff) |
add simple test feature
-rw-r--r-- | src/pyssg/__main__.py | 7 | ||||
-rw-r--r-- | tests/__init__.py | 0 | ||||
-rw-r--r-- | tests/conftest.py | 7 | ||||
-rw-r--r-- | tests/test_arg_parser.py | 16 |
4 files changed, 23 insertions, 7 deletions
diff --git a/src/pyssg/__main__.py b/src/pyssg/__main__.py deleted file mode 100644 index 5213889..0000000 --- a/src/pyssg/__main__.py +++ /dev/null @@ -1,7 +0,0 @@ -from .pyssg import main - - -# since this is not used as a package, rather it's used as a command line tool, -# this is never called because pyssg:main is called directly when running pyssg -if __name__ == '__main__': - main() diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/__init__.py 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 |