Python: fix: remove dead code from test_middleware_with_agent.py#5140
Open
Serjbory wants to merge 2 commits intomicrosoft:mainfrom
Open
Python: fix: remove dead code from test_middleware_with_agent.py#5140Serjbory wants to merge 2 commits intomicrosoft:mainfrom
Serjbory wants to merge 2 commits intomicrosoft:mainfrom
Conversation
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.
Motivation and Context
Motivation and Context
Three
with pytest.raises(...)blocks intest_middleware_with_agent.pycontain multiple statements. Becausepytest.raisesexits immediately after the first exception is caught, all subsequent statements in the block are dead code that never executes. This creates a false sense of test coverage — theawait agent.run(...)calls appear to be tested but are actually unreachable.In all three cases, the
Agent(...)constructor is what raises the expectedMiddlewareException. Theagent.run()calls after it are dead code.Description
3 locations fixed in
test_middleware_with_agent.py:1.
test_decorator_and_type_mismatch(line ~1470)@agent_middlewaredecorator outside thepytest.raisesblock (decorators don't raise)await agent.run(...)afterAgent(...)constructor2.
test_neither_decorator_nor_type(line ~1597)await agent.run(...)afterAgent(...)constructor3.
test_insufficient_parameters_error(line ~1606)@agent_middlewaredecorator outside thepytest.raisesblockawait agent.run(...)afterAgent(...)constructorAll 53 tests in
test_middleware_with_agent.pypass after the changes.Contribution Checklist