Skip to content

Commit

Permalink
- r cleanup
Browse files Browse the repository at this point in the history
Co-Authored-By: 4dsherwood <4dsherwood@users.noreply.github.com>
Co-Authored-By: jmasonlee <262853+jmasonlee@users.noreply.github.com>
Co-Authored-By: Nitsan Avni <nitsanav@gmail.com>
Co-Authored-By: T. E. Green <78671457+Tegsy@users.noreply.github.com>
Co-Authored-By: Nazee Hajebi <2491283+NazeeHajebi@users.noreply.github.com>
  • Loading branch information
6 people committed Mar 10, 2024
1 parent 692d4e6 commit 2622763
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
11 changes: 5 additions & 6 deletions approvaltests/namer/inline_comparator.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ def get_test_method_doc_string():
@staticmethod
def get_caller_method(caller_frame) -> Callable:
caller_function_name: str = caller_frame[3]
caller_function_object = caller_frame.frame.f_globals.get(
caller_function_name, None
)
caller_function_object = caller_frame.frame.f_globals.get(caller_function_name)
if caller_function_object:
# pytest function
return caller_function_object
else:
# unittest class function
className = get_class_name_for_frame(caller_frame)
caller_function_object = caller_frame.frame.f_globals.get(
className, None
).__dict__.get(caller_function_name, None)
clazz = caller_frame.frame.f_globals.get(className)
caller_function_object = clazz.__dict__.get(caller_function_name)
return caller_function_object

def register(self, options: "Options", show_code: bool):
Expand Down
7 changes: 0 additions & 7 deletions tests/test_inline_approvals.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,6 @@ def test_with_labeled_input_inline(self) -> None:
(arg1: 3, arg2: 2) => 5
(arg1: 3, arg2: 4) => 7
"""
test_stack_frame: FrameInfo = StackFrameNamer.get_test_frame()
caller_frame = test_stack_frame
caller_function_name: str = caller_frame[3]
caller_function_object = caller_frame.frame.f_globals.get(
caller_function_name, None
)

verify_all_combinations_with_labeled_input(
lambda a,b: a + b,
arg1=(1, 3),
Expand Down

0 comments on commit 2622763

Please sign in to comment.