From 91b60f5507e68ceac3f4891e6432fdf1dea3c498 Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Sun, 10 Nov 2024 18:45:44 +0000 Subject: [PATCH 01/10] - F shebang line for Python3 Co-authored-by: 4dsherwood <4dsherwood@gmail.com> Co-authored-by: Nitsan Avni Co-authored-by: Jay Bazuzi Co-Authored-By: Michael R Wolf --- tests/find_stale_approved_files.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/find_stale_approved_files.py b/tests/find_stale_approved_files.py index 787f199..fd2051d 100755 --- a/tests/find_stale_approved_files.py +++ b/tests/find_stale_approved_files.py @@ -1,3 +1,4 @@ +#! /usr/bin/env python3 import os import argparse import pathlib From bbfbbc4df0a7e30a6fe9b3920ee211917a9f3c8f Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 13:58:27 -0800 Subject: [PATCH 02/10] . e move pytest requirement to requirements --- requirements.test.txt | 4 +++- run_tests.sh | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/requirements.test.txt b/requirements.test.txt index 66a69cf..2cecea0 100644 --- a/requirements.test.txt +++ b/requirements.test.txt @@ -1,6 +1,8 @@ numpy pylint -pytest-asyncio==0.21.1 # 0.23 has a bug 2023/12/3 +pytest +pytest-asyncio==0.21.1 # 0.23 has a bug 2023/12/3 pytest-xdist + # mariadb diff --git a/run_tests.sh b/run_tests.sh index d232a8e..e29a235 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,4 +1,3 @@ python -m pip install --upgrade pip pip install tox -pip install pytest tox -e py \ No newline at end of file From b88b85d8fc333019fe8c5eb3868c77ce5383cdb4 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 14:00:11 -0800 Subject: [PATCH 03/10] . e don't upgrade pip --- run_tests.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/run_tests.sh b/run_tests.sh index e29a235..c7b2872 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,3 +1,2 @@ -python -m pip install --upgrade pip -pip install tox +pip --disable-pip-version-check install tox tox -e py \ No newline at end of file From 150dadc84c4918e1e545566719c9a97a46c943f6 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 14:00:36 -0800 Subject: [PATCH 04/10] . e run pip via `python3` to make it work on my machine --- run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_tests.sh b/run_tests.sh index c7b2872..b2ff784 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,2 +1,2 @@ -pip --disable-pip-version-check install tox +python3 -m pip --disable-pip-version-check install tox tox -e py \ No newline at end of file From 42e17d99fc743c471885adbd4e97542bc066f480 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 14:02:49 -0800 Subject: [PATCH 05/10] . e add standard bash boilerplate to run_tests --- run_tests.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_tests.sh b/run_tests.sh index b2ff784..311585e 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -1,2 +1,5 @@ +#! /usr/bin/env bash +set -euo pipefail + python3 -m pip --disable-pip-version-check install tox tox -e py \ No newline at end of file From b5c953325a65aca3f53f607ba97c1e460e1d794c Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 15:05:06 -0800 Subject: [PATCH 06/10] . e add 3.12 to test matrix --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ac08d7d..5a50f7c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: true matrix: - python-version: [3.8, 3.9, "3.10", "3.11"] + python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] os: [macos-latest, ubuntu-latest, windows-latest] steps: From 3e57a753b13a1e6339020e42d13b9ca00d04e585 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 15:12:49 -0800 Subject: [PATCH 07/10] . t add setuptools to test requirements --- requirements.test.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.test.txt b/requirements.test.txt index 66a69cf..b0633f0 100644 --- a/requirements.test.txt +++ b/requirements.test.txt @@ -1,3 +1,4 @@ +setuptools numpy pylint pytest-asyncio==0.21.1 # 0.23 has a bug 2023/12/3 From 8e03e15fd677f42fd4c670743435a8689de55cc7 Mon Sep 17 00:00:00 2001 From: Jay Bazuzi Date: Sun, 10 Nov 2024 19:02:53 -0800 Subject: [PATCH 08/10] . t dynamically discover the approvals modules --- ..._options.test_list_of_modules.approved.txt | 6 ++++++ tests/test_options.py | 21 ++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 tests/approved_files/test_options.test_list_of_modules.approved.txt diff --git a/tests/approved_files/test_options.test_list_of_modules.approved.txt b/tests/approved_files/test_options.test_list_of_modules.approved.txt new file mode 100644 index 0000000..4a0d115 --- /dev/null +++ b/tests/approved_files/test_options.test_list_of_modules.approved.txt @@ -0,0 +1,6 @@ +0) approvaltests.approvals +1) approvaltests.combination_approvals +2) approvaltests.integrations.mrjob.mrjob_approvals +3) approvaltests.utilities.command_line_approvals +4) approvaltests.utilities.logger.simple_logger_approvals +5) approvaltests.utilities.logging.logging_approvals diff --git a/tests/test_options.py b/tests/test_options.py index c2af144..6c23f48 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -1,9 +1,12 @@ +import importlib import inspect +import sys from approvaltests import ( get_default_reporter, approvals, verify, + verify_all, ReporterForTesting, combination_approvals, ) @@ -13,14 +16,22 @@ from approvaltests.reporters.report_with_beyond_compare import ReportWithPycharm from approvaltests.utilities import command_line_approvals from approvaltests.utilities.logger import simple_logger_approvals +from approvaltests.utilities.logging import logging_approvals + + +_approvals_modules = list(sorted(filter( + lambda name: name.startswith("approvaltests.") and name.endswith("approvals"), + sys.modules.keys(), +))) + + +def test_list_of_modules(): + verify_all("", _approvals_modules) def test_every_function_in_approvals_with_verify_has_an_options(): - assert_verify_methods_have_options(approvals) - assert_verify_methods_have_options(combination_approvals) - assert_verify_methods_have_options(simple_logger_approvals) - assert_verify_methods_have_options(command_line_approvals) - assert_verify_methods_have_options(mrjob_approvals) + for module_name in _approvals_modules: + assert_verify_methods_have_options(importlib.import_module(module_name)) def assert_verify_methods_have_options(module): From 6538898686c6e7b140866a5b10b720a6ea7ad6a1 Mon Sep 17 00:00:00 2001 From: Nitsan Avni Date: Mon, 11 Nov 2024 08:15:12 +0000 Subject: [PATCH 09/10] - F stale approved files: consistent sorting of output --- tests/find_stale_approved_files.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/find_stale_approved_files.py b/tests/find_stale_approved_files.py index fd2051d..70174a3 100755 --- a/tests/find_stale_approved_files.py +++ b/tests/find_stale_approved_files.py @@ -30,7 +30,7 @@ def main() -> None: if missing_files: print("The following files are not in the approved log:") - for file in missing_files: + for file in sorted(missing_files): print(file) else: print("All found approved files are present in the log.") From ae7b1ffee382888794b31ea7657645b526fe1e6e Mon Sep 17 00:00:00 2001 From: github actions Date: Tue, 12 Nov 2024 10:29:08 +0000 Subject: [PATCH 10/10] . d updated markdown snippets --- docs/features.md | 2 +- tests/test_options.py | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docs/features.md b/docs/features.md index e9b8d91..8cf7c38 100644 --- a/docs/features.md +++ b/docs/features.md @@ -53,5 +53,5 @@ If you want to set the extension of the approval file, you can now do it through ```py verify(content, options=Options().for_file.with_extension(".md")) ``` -snippet source | anchor +snippet source | anchor diff --git a/tests/test_options.py b/tests/test_options.py index 6c23f48..de10ccd 100644 --- a/tests/test_options.py +++ b/tests/test_options.py @@ -19,10 +19,15 @@ from approvaltests.utilities.logging import logging_approvals -_approvals_modules = list(sorted(filter( - lambda name: name.startswith("approvaltests.") and name.endswith("approvals"), - sys.modules.keys(), -))) +_approvals_modules = list( + sorted( + filter( + lambda name: name.startswith("approvaltests.") + and name.endswith("approvals"), + sys.modules.keys(), + ) + ) +) def test_list_of_modules():