Skip to content

Update test_detect.py #4311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 8, 2025
Merged

Update test_detect.py #4311

merged 1 commit into from
May 8, 2025

Conversation

pombredanne
Copy link
Member

@pombredanne pombredanne commented May 8, 2025

Fix lingering test failure

    def check_position(self, test_path, expected, with_span=True):
        """
        Check license detection in file or folder against expected result.
        Expected is a list of (license, lines span, qspan span) tuples.
        """
        test_location = self.get_test_loc(test_path)
        results = []
        # FULL INDEX!!
        idx = cache.get_index()
        matches = idx.match(test_location)
        for match in matches:
            for detected in match.rule.license_keys():
                results.append((detected, match.lines(), with_span and match.qspan or None))
>       assert results == expected
E       AssertionError: assert [('gpl-2.0-plus', (12, 25), Span(51, 160)),\n ('fsf-unlimited-no-warranty', (231, 238), Span(978, 1041)),\n ('warranty-disclaimer', (306, 307), Span(1351, 1373))] == [('gpl-2.0-plus', (12, 25), Span(48, 157)),\n ('fsf-unlimited-no-warranty', (231, 238), Span(965, 1028)),\n ('warranty-disclaimer', (306, 307), Span(1337, 1359))]
E         At index 0 diff: ('gpl-2.0-plus', (12, 25), Span(51, 160)) != ('gpl-2.0-plus', (12, 25), Span(48, 157))
E         Full diff:
E           [
E         -  ('gpl-2.0-plus', (12, 25), Span(48, 157)),
E         ?                                  ^^   ^^
E         +  ('gpl-2.0-plus', (12, 25), Span(51, 160)),
E         ?                                  ^^   ^^
E         -  ('fsf-unlimited-no-warranty', (231, 238), Span(965, 1028)),
E         ?                                                  ^^    ^^
E         +  ('fsf-unlimited-no-warranty', (231, 238), Span(978, 1041)),
E         ?                                                  ^^    ^^
E         -  ('warranty-disclaimer', (306, 307), Span(1337, 1359)),
E         ?                                               --- --
E         +  ('warranty-disclaimer', (306, 307), Span(1351, 1373)),
E         ?                                             +++++
E           ]

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Fix lingering test failure

Signed-off-by: Philippe Ombredanne <[email protected]>
@pombredanne
Copy link
Member Author

I am merging even though we still have this unrelated issue:

@pombredanne pombredanne merged commit a89b5e5 into develop May 8, 2025
40 of 43 checks passed
@pombredanne pombredanne deleted the fix-test-failure branch May 8, 2025 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant