This repository was archived by the owner on Apr 4, 2024. It is now read-only.
File tree 2 files changed +18
-0
lines changed
2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change 1
1
from typing import List , Optional
2
2
from selfie_lib .CommentTracker import SnapshotFileLayout
3
3
import inspect
4
+ from functools import total_ordering
4
5
5
6
7
+ @total_ordering
6
8
class CallLocation :
7
9
def __init__ (self , file_name : Optional [str ], line : int ):
8
10
self ._file_name = file_name
Original file line number Diff line number Diff line change 1
1
from unittest .mock import Mock
2
2
from selfie_lib .WriteTracker import CallLocation , CallStack , recordCall
3
+ import os
3
4
4
5
5
6
def test_call_location_ide_link ():
@@ -22,10 +23,25 @@ def test_call_stack_ide_link():
22
23
23
24
def test_record_call_with_caller_file_only_false ():
24
25
call_stack = recordCall (False )
26
+
25
27
assert (
26
28
len (call_stack .rest_of_stack ) > 0
27
29
), "Expected the rest of stack to contain more than one CallLocation"
28
30
31
+ expected_call_location_str = "File: RecordCall_test.py, Line: 25"
32
+
33
+ if call_stack .location .file_name is not None :
34
+ actual_file_name = os .path .basename (call_stack .location .file_name )
35
+ actual_call_location_str = (
36
+ f"File: { actual_file_name } , Line: { call_stack .location .line } "
37
+ )
38
+ else :
39
+ actual_call_location_str = "File name is None"
40
+
41
+ assert (
42
+ actual_call_location_str == expected_call_location_str
43
+ ), f"Expected call location to be '{ expected_call_location_str } ' but was '{ actual_call_location_str } '"
44
+
29
45
30
46
def test_record_call_with_caller_file_only_true ():
31
47
call_stack = recordCall (True )
You can’t perform that action at this time.
0 commit comments