FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-106193: Rename and fix duplicated tests in `test_monitoring` by hugovk · Pull Request #109139 · python/cpython · GitHub

/ cpython Public

gh-106193: Rename and fix duplicated tests in test_monitoring - #109139

Merged
markshannon merged 4 commits into
python:mainfrom
hugovk:fix-duplicate-names-test_monitoring
Oct 12, 2023
Merged

gh-106193: Rename and fix duplicated tests in test_monitoring#109139
markshannon merged 4 commits into
python:mainfrom
hugovk:fix-duplicate-names-test_monitoring

Conversation

hugovk commented Sep 8, 2023
edited
Loading

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

hugovk commented Sep 18, 2023

Copy link
Copy Markdown
Member Author

(Resolved conflict.)

Copy link
Copy Markdown
Member

Thanks

markshannon merged commit ea530f2 into python:main 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!

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

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

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.

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
…toring` (pythonGH-109139)

(cherry picked from commit ea530f2)

Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip news tests Tests in the Lib/test dir

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_monitoring has duplicated tests

4 participants


Back | FazBrowse Home | New Git URL