Add tests for get_scope with builtin types, classes, and methods#189
Add tests for get_scope with builtin types, classes, and methods#189samwaseda merged 5 commits intosamwaseda-patch-1from
Conversation
…ypes Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
|
@copilot Remove |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## samwaseda-patch-1 #189 +/- ##
==================================================
Coverage 97.97% 97.97%
==================================================
Files 34 34
Lines 2268 2268
==================================================
Hits 2222 2222
Misses 46 46 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| fn = lambda x: x # noqa: E731 | ||
| scope = object_scope.get_scope(fn) | ||
| self.assertIs(scope.add, add) | ||
| self.assertIs(scope.len, len) |
There was a problem hiding this comment.
Assertions are unrelated to the newly scoped object
There was a problem hiding this comment.
@copilot Assertions are unrelated to the newly scoped object
There was a problem hiding this comment.
Fixed in 5ec4ac0. Moved the lambda to module level as identity = lambda x: x, so the test now asserts scope.identity is identity — directly verifying the scoped object is present in its own scope, consistent with the pattern used in the other TestGetScope tests.
There was a problem hiding this comment.
Works for me. I added a suggestion to remove the vestigial add check.
Co-authored-by: samwaseda <37879103+samwaseda@users.noreply.github.com>
Co-authored-by: Liam Huber <liamhuber@greyhavensolutions.com>
Summary
get_scopewas broadened to acceptCallable[..., Any] | type[Any]but lacked tests exercising the new callable categories. Adds coverage for actual "rubber meets the road" usage with builtins, user-defined classes, static methods, and lambdas.Related Issue(s)
Extends the fix in #186.
Backward Compatibility
No behavioral changes — test-only additions.
Implementation Notes
New test cases in
TestGetScope:test_builtin_typeget_scope(int)— hitssys.modulesfallback sinceinspect.getmodule(int)returnsNonetest_builtin_functionget_scope(len)— same fallback pathtest_user_defined_classget_scope(Outer)— directinspect.getmodulepath, verifies module globals visibletest_static_methodget_scope(Outer.Inner.nested_func)— nested staticmethod traversaltest_lambdaidentitylambda — primary assertion verifiesscope.identity is identity, consistent with the pattern used by all other testsflowrep/_version.py(a generated build artifact) is excluded from the repository via.gitignoreto prevent it from being accidentally committed.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.