GeezerVison is showing github.com — gh-106193: Rename and fix duplicated tests in `test_monitoring` by hugovk · Pull Request #109139 · python/cpython
Conversation
hugovk
commented
Sep 8, 2023
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
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
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
hugovk reacted with thumbs up emoji
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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!
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
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
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Milestone
No milestone
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.
|