From 7d26dcf3ee9a0c033f1529d09fe1f600b527c1cc Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 22 Mar 2023 08:31:58 +0100 Subject: Fix incorrect preferred-modules matches (#8481) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: d33bs (cherry picked from commit d64c0cc1484b0cbea5fd3a9dfac4c0d6ddc7d1aa) Co-authored-by: Daniƫl van Noord <13665637+DanielNoord@users.noreply.github.com> --- tests/checkers/unittest_imports.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/checkers/unittest_imports.py b/tests/checkers/unittest_imports.py index 7544e3422..d454c8161 100644 --- a/tests/checkers/unittest_imports.py +++ b/tests/checkers/unittest_imports.py @@ -192,6 +192,23 @@ class TestImportsChecker(CheckerTestCase): # assert there were no errors assert len(errors) == 0 + # Test for challenges with preferred modules indefinite matches + Run( + [ + f"{os.path.join(REGR_DATA, 'preferred_module/unpreferred_submodule.py')}", + "-d all", + "-e preferred-module", + # prefer pathlib instead of random (testing to avoid regression) + # pathlib shouldn't match with path, which is in the test file + "--preferred-modules=random:pathlib", + ], + exit=False, + ) + _, errors = capsys.readouterr() + + # Assert there were no errors + assert len(errors) == 0 + @staticmethod def test_allow_reexport_package(capsys: CaptureFixture[str]) -> None: """Test --allow-reexport-from-package option.""" -- cgit v1.2.1