[Test] Un-shadow duplicated test classes in test_lu_op.py and test_tensordot.py - #79767
Open
Anai-Guo wants to merge 1 commit into
Open
[Test] Un-shadow duplicated test classes in test_lu_op.py and test_tensordot.py#79767Anai-Guo wants to merge 1 commit into
Anai-Guo wants to merge 1 commit into
Conversation
…nsordot.py Both files define a test class name twice at module level, so only the later definition is collected and the earlier case never runs. test_lu_op.py: the zero-size case added at the end of the file is also called TestLUOp, which shadows the "case 1" m < n class it collides with. TestLUOp2-5 still subclass the original (they captured it at class-creation time), but the [3, 10, 12] m < n case itself is no longer collected. Renamed the zero-size class to TestLUOpZeroSize, matching TestLUAPIZeroSize in the same file. test_tensordot.py: TestTensordotAPIZeroSize is defined twice. The second definition is the first plus set_dtype -> float64, which is exactly what TestTensordotAPIFloat64ZeroSize (a subclass of the first definition) already provides. The duplicate therefore only costs the default float32 zero-size case. Removed it; float64 stays covered by TestTensordotAPIFloat64ZeroSize.
|
|
Paddle-Bot
approved these changes
Sep 12, 2026
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
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.
PR Category
Execute Infrastructure
PR Types
Bug fixes
Description
Two unit-test files define a test class name twice at module level. Python keeps only the last binding, so
unittest/pytestcollect only the later class and the earlier case silently stops running.1.
test/legacy_test/test_lu_op.pyTestLUOpis defined at line 106 (# m < n, "case 1",x_shape = [3, 10, 12]) and again at line 387, where a zero-size case (x_shape = [2, 0, 12]) reuses the same name.TestLUOp2…TestLUOp5still behave correctly — they subclass the first definition and captured the class object at class-creation time — but the m < n case itself is no longer collected, since the module attributeTestLUOpnow points at the zero-size class.Renamed the zero-size class to
TestLUOpZeroSize, matching theTestLUAPIZeroSizenaming already used in the same file. Both cases are then collected.TestLUOp[2, 0, 12][3, 10, 12](base ofTestLUOp2–TestLUOp5)TestLUOpZeroSize[2, 0, 12]Class count is unchanged (9 before, 9 after); one case is recovered.
2.
test/legacy_test/test_tensordot.pyTestTensordotAPIZeroSizeis defined at line 365 and again at line 385. The second definition is byte-identical to the first except that it addsset_dtype→np.float64— which is exactly whatTestTensordotAPIFloat64ZeroSize(line 380, a subclass of the first definition) already provides.So the duplicate buys no extra coverage and costs the default
float32zero-size case: the collectedTestTensordotAPIZeroSizeruns float64, and float64 is then tested twice.Removed the second definition.
TestTensordotAPIZeroSizegoes back to the baseset_dtype(np.float32) andTestTensordotAPIFloat64ZeroSizecontinues to cover float64. No class defined after line 400 subclassesTestTensordotAPIZeroSize, so nothing else changes binding.TestTensordotAPIZeroSizeTestTensordotAPIFloat64ZeroSize)TestTensordotAPIFloat64ZeroSizeDiff is
+1 / −19, test-only.是否引起精度变化
否
(Test-only. Two previously-uncollected cases start running again; no framework or kernel code is touched.)
🤖 Generated with Claude Code