GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-106193: Rename and fix duplicated tests in `test_monitoring` by hugovk · Pull Request #109139 · python/cpython

Conversation

@hugovk

@hugovk hugovk commented Sep 8, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Fixes #106193.
Found via python/core-workflow#505 (comment).

Fixes some copy/paste errors, and then fix some undefined names, because the redefined method name masked the unknown variables. We can work out what they should be.

Before

We can see two pairs of tests:

    @staticmethod
    def func1():
        line1 = 1

    MUST_INCLUDE_LI = [
            ('instruction', 'func1', 2),
            ('line', 'func1', 1),
            ('instruction', 'func1', 4),
            ('instruction', 'func1', 6)]

    def test_line_then_instruction(self):
        recorders = [ LineRecorder, InstructionRecorder ]
        self.check_events(self.func1,
                          recorders = recorders, must_include = self.EXPECTED_LI)

    def test_instruction_then_line(self):
        recorders = [ InstructionRecorder, LineRecorderLowNoise ]
        self.check_events(self.func1,
                          recorders = recorders, must_include = self.EXPECTED_LI)
    @staticmethod
    def func2():
        len(())

    MUST_INCLUDE_CI = [
            ('instruction', 'func2', 2),
            ('call', 'func2', sys.monitoring.MISSING),
            ('call', 'len', ()),
            ('instruction', 'func2', 12),
            ('instruction', 'func2', 14)]



    def test_line_then_instruction(self):
        recorders = [ CallRecorder, InstructionRecorder ]
        self.check_events(self.func2,
                          recorders = recorders, must_include = self.MUST_INCLUDE_CI)

    def test_instruction_then_line(self):
        recorders = [ InstructionRecorder, CallRecorder ]
        self.check_events(self.func2,
                          recorders = recorders, must_include = self.MUST_INCLUDE_CI)

After

Fixes:

  • Test names are based on the recorders.
  • self.EXPECTED_LI should be self.MUST_INCLUDE_CI, like the others.
  • LineRecorderLowNoise should be LineRecorder, like the previous test.
  • ('line', 'func1', 1) needed changing to ('line', 'func1', 2) to pass.
    @staticmethod
    def func1():
        line1 = 1

    MUST_INCLUDE_LI = [
            ('instruction', 'func1', 2),
            ('line', 'func1', 2),
            ('instruction', 'func1', 4),
            ('instruction', 'func1', 6)]

    def test_line_then_instruction(self):
        recorders = [ LineRecorder, InstructionRecorder ]
        self.check_events(self.func1,
                          recorders = recorders, must_include = self.MUST_INCLUDE_LI)

    def test_instruction_then_line(self):
        recorders = [ InstructionRecorder, LineRecorder ]
        self.check_events(self.func1,
                          recorders = recorders, must_include = self.MUST_INCLUDE_LI)
    @staticmethod
    def func2():
        len(())

    MUST_INCLUDE_CI = [
            ('instruction', 'func2', 2),
            ('call', 'func2', sys.monitoring.MISSING),
            ('call', 'len', ()),
            ('instruction', 'func2', 12),
            ('instruction', 'func2', 14)]



    def test_call_then_instruction(self):
        recorders = [ CallRecorder, InstructionRecorder ]
        self.check_events(self.func2,
                          recorders = recorders, must_include = self.MUST_INCLUDE_CI)

    def test_instruction_then_call(self):
        recorders = [ InstructionRecorder, CallRecorder ]
        self.check_events(self.func2,
                          recorders = recorders, must_include = self.MUST_INCLUDE_CI)

cc @markshannon @sobolevn

  • Issue: test_monitoring has duplicated tests #106193

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
hugovk added 3 commits September 8, 2023 16:02
@hugovk
Rename duplicated tests in test_monitoring
282098b
@hugovk
Fix typos
d082bb3
@hugovk
Update expected value to fix test
7b2dd3d
@bedevere-bot bedevere-bot added awaiting core review tests Tests in the Lib/test dir labels Sep 8, 2023
@bedevere-bot bedevere-bot mentioned this pull request Sep 8, 2023
test_monitoring has duplicated tests #106193
Closed
@hugovk hugovk added skip news needs backport to 3.12 only security fixes labels Sep 8, 2023
@hugovk hugovk mentioned this pull request Sep 8, 2023
gh-60283: Check for redefined test names in CI #109161
Merged
@AlexWaygood
AlexWaygood requested a review from markshannon September 11, 2023 08:52
@hugovk
Merge branch 'main' into fix-duplicate-names-test_monitoring
c4f67e5
@hugovk

hugovk commented Sep 18, 2023

Copy link
Copy Markdown
Member Author

(Resolved conflict.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon

markshannon commented Oct 12, 2023

Copy link
Copy Markdown
Member

Thanks

hugovk reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@markshannon
markshannon merged commit ea530f2 into python:main Oct 12, 2023
@miss-islington

miss-islington commented Oct 12, 2023

Copy link
Copy Markdown
Contributor

Thanks @hugovk for the PR, and @markshannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the awaiting core review label Oct 12, 2023
@miss-islington

miss-islington commented Oct 12, 2023

Copy link
Copy Markdown
Contributor

Sorry, @hugovk and @markshannon, I could not cleanly backport this to 3.12 due to a conflict.
Please backport using cherry_picker on command line.

cherry_picker ea530f2f9ae63e81c22a1818bec0a650ccf758d2 3.12
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@miss-islington miss-islington assigned markshannon Oct 12, 2023
@AlexWaygood AlexWaygood assigned hugovk and unassigned markshannon Oct 12, 2023
@hugovk
hugovk deleted the fix-duplicate-names-test_monitoring branch October 12, 2023 22:24
@bedevere-app

bedevere-app Bot commented Oct 15, 2023

Copy link
Copy Markdown

GH-110897 is a backport of this pull request to the 3.12 branch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bedevere-app bedevere-app Bot removed the needs backport to 3.12 only security fixes label Oct 15, 2023
hugovk added a commit to hugovk/cpython that referenced this pull request Oct 15, 2023
@hugovk
[3.12] pythongh-106193: Rename and fix duplicated tests in `test_moni…
15ea3d5
…toring` (pythonGH-109139)

(cherry picked from commit ea530f2)

Co-authored-by: Hugo van Kemenade <[email protected]>
@hugovk hugovk mentioned this pull request Oct 15, 2023
Lint: Include test_monitoring.py for Ruff #110898
Merged
hugovk added a commit that referenced this pull request Oct 15, 2023
@hugovk
[3.12] gh-106193: Rename and fix duplicated tests in test_monitoring (
9c39149
GH-109139) (#110897)
Glyphack pushed a commit to Glyphack/cpython that referenced this pull request Sep 2, 2024
@hugovk @Glyphack
pythongh-106193: Rename and fix duplicated tests in test_monitoring (…
ace4b62
…pythonGH-109139)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@markshannon markshannon Awaiting requested review from markshannon

Uh oh!

There was an error while loading. Please reload this page.

Assignees

@hugovk hugovk

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

test_monitoring has duplicated tests

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@hugovk @markshannon @miss-islington @bedevere-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.