From ddde136c1cfe9124b00471f594255a86fe5534e5 Mon Sep 17 00:00:00 2001 From: Joey Chatelain Date: Wed, 5 Aug 2026 11:05:19 -0700 Subject: [PATCH 1/2] update tests --- .github/workflows/run-canary-tests.yml | 2 +- tom_fink/tests/run_canary_tests.py | 14 ---------- tom_fink/tests/run_tests.py | 36 +++++++++++++++++++++----- 3 files changed, 31 insertions(+), 21 deletions(-) delete mode 100755 tom_fink/tests/run_canary_tests.py diff --git a/.github/workflows/run-canary-tests.yml b/.github/workflows/run-canary-tests.yml index 9f432b9..47f4017 100644 --- a/.github/workflows/run-canary-tests.yml +++ b/.github/workflows/run-canary-tests.yml @@ -17,4 +17,4 @@ jobs: poetry env info # display poetry's env info for debugging poetry install --with test,coverage,lint - name: Run Tests - run: poetry run python tom_fink/tests/run_canary_tests.py + run: poetry run python tom_fink/tests/run_tests.py --canary diff --git a/tom_fink/tests/run_canary_tests.py b/tom_fink/tests/run_canary_tests.py deleted file mode 100755 index fd1ee43..0000000 --- a/tom_fink/tests/run_canary_tests.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -# django_shell.py - -from django.core.management import call_command -from boot_django import boot_django, APP_NAME # noqa - - -boot_django() -print(f'running canary tests for {APP_NAME}') -call_command('test', APP_NAME, '--tag=canary', verbosity=2) - -# TODO: consider collecting switches and arguments -# from the command line (like -v or a specific test module -# or function) and passing them on to call command diff --git a/tom_fink/tests/run_tests.py b/tom_fink/tests/run_tests.py index b5fe523..073aa2e 100755 --- a/tom_fink/tests/run_tests.py +++ b/tom_fink/tests/run_tests.py @@ -1,14 +1,38 @@ #!/usr/bin/env python # django_shell.py +import argparse + from django.core.management import call_command from boot_django import boot_django, APP_NAME # noqa -boot_django() -print(f'running test for {APP_NAME}') -call_command('test', APP_NAME, '--exclude-tag=canary', verbosity=2) +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('testname', default='', nargs='?', + help='Module paths to test; ' + 'can be modulename, modulename.TestCase or modulename.TestCase.test_method') + parser.add_argument('-v', '--verbosity', default=2, type=int, choices=[0, 1, 2, 3], + help='Verbosity level;' + ' 0=minimal output, 1=normal output, 2=verbose output, 3=very verbose output') + parser.add_argument('--canary', action='store_true', help='Run only canary tests (skips canary tests by default)') + + testname = parser.parse_args().testname + verbosity = parser.parse_args().verbosity + run_canary = parser.parse_args().canary + + # We still only want to test this app's tests, so if no specific test is supplied, + # we use the app name to restrict testing + if not testname: + testname = APP_NAME + + # If the canary flag is set, we want to run only the canary tests, otherwise we want to exclude them + if run_canary: + canary_command_flag = '--tag=canary' + else: + canary_command_flag = '--exclude-tag=canary' -# TODO: consider collecting switches and arguments -# from the command line (like -v or a specific test module -# or function) and passing them on to call command + boot_django() + print(f'running test(s) for {APP_NAME}') + call_command('test', testname, canary_command_flag, verbosity=verbosity) + \ No newline at end of file From b40d910fb19c8e1820b0d40c47e566694174acd7 Mon Sep 17 00:00:00 2001 From: Joey Chatelain Date: Wed, 5 Aug 2026 11:09:38 -0700 Subject: [PATCH 2/2] fix last line --- tom_fink/tests/run_tests.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tom_fink/tests/run_tests.py b/tom_fink/tests/run_tests.py index 073aa2e..546d7bf 100755 --- a/tom_fink/tests/run_tests.py +++ b/tom_fink/tests/run_tests.py @@ -35,4 +35,3 @@ boot_django() print(f'running test(s) for {APP_NAME}') call_command('test', testname, canary_command_flag, verbosity=verbosity) - \ No newline at end of file