File tree 2 files changed +20
-0
lines changed
2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ class SourceLocation(NamedTuple):
16
16
def formatted (self ):
17
17
return dict (line = self .line , column = self .column )
18
18
19
+ def __eq__ (self , other ):
20
+ if isinstance (other , dict ):
21
+ return other == self .formatted
22
+ return super ().__eq__ (other )
23
+
24
+ def __ne__ (self , other ):
25
+ return not self == other
26
+
19
27
20
28
def get_location (source : "Source" , position : int ) -> SourceLocation :
21
29
"""Get the line and column for a character position in the source.
Original file line number Diff line number Diff line change
1
+ from graphql import SourceLocation
2
+
3
+
4
+ def describe_SourceLocation ():
5
+ def equals_with_itself ():
6
+ assert SourceLocation (1 , 2 ) == SourceLocation (1 , 2 )
7
+ assert (SourceLocation (1 , 2 ) != SourceLocation (1 , 2 )) is False
8
+
9
+ def equals_with_formatted_form ():
10
+ sl = SourceLocation (1 , 2 )
11
+ assert SourceLocation (1 , 2 ) == sl .formatted
12
+ assert (SourceLocation (1 , 2 ) != sl .formatted ) is False
You can’t perform that action at this time.
0 commit comments