From bf48a9639ea0390d34181d35e874f444096b91bc Mon Sep 17 00:00:00 2001 From: Justin Warren Date: Sun, 15 Jan 2023 13:32:13 +1100 Subject: [PATCH] Added helper submodule for testing utils --- setup.cfg | 2 ++ tests/conftest.py | 3 +++ tests/helpers/__init__.py | 0 tests/helpers/util.py | 11 +++++++++++ tests/test_cmdline.py | 9 +-------- tests/test_configfile.py | 9 +-------- 6 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 setup.cfg create mode 100644 tests/conftest.py create mode 100644 tests/helpers/__init__.py create mode 100644 tests/helpers/util.py diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..6d8a5af --- /dev/null +++ b/setup.cfg @@ -0,0 +1,2 @@ +[pytest] +norecursedirs=tests/helpers \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..501ed17 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,3 @@ +import sys +import os +sys.path.append(os.path.join(os.path.dirname(__file__), 'helpers')) \ No newline at end of file diff --git a/tests/helpers/__init__.py b/tests/helpers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/helpers/util.py b/tests/helpers/util.py new file mode 100644 index 0000000..faed6e1 --- /dev/null +++ b/tests/helpers/util.py @@ -0,0 +1,11 @@ +""" Utility functions for tests +""" +from fediblockhole import setup_argparse, augment_args + +def shim_argparse(testargv: list=[], tomldata: str=None): + """Helper function to parse test args + """ + ap = setup_argparse() + args = ap.parse_args(testargv) + args = augment_args(args, tomldata) + return args \ No newline at end of file diff --git a/tests/test_cmdline.py b/tests/test_cmdline.py index 4e6f355..46b5748 100644 --- a/tests/test_cmdline.py +++ b/tests/test_cmdline.py @@ -1,15 +1,8 @@ """Test the commandline defined parameters correctly """ +from util import shim_argparse from fediblockhole import setup_argparse, augment_args -def shim_argparse(testargv: list=[], tomldata: str=None): - """Helper function to parse test args - """ - ap = setup_argparse() - args = ap.parse_args(testargv) - args = augment_args(args, tomldata) - return args - def test_cmdline_no_configfile(): """ Test bare command with no configfile """ diff --git a/tests/test_configfile.py b/tests/test_configfile.py index d52a425..4b2c1e7 100644 --- a/tests/test_configfile.py +++ b/tests/test_configfile.py @@ -1,15 +1,8 @@ """Test the config file is loading parameters correctly """ +from util import shim_argparse from fediblockhole import setup_argparse, augment_args -def shim_argparse(testargv: list=[], tomldata: str=None): - """Helper function to parse test args - """ - ap = setup_argparse() - args = ap.parse_args(testargv) - args = augment_args(args, tomldata) - return args - def test_parse_tomldata(): tomldata = """ # Test TOML config for FediBlockHole