-
-
Notifications
You must be signed in to change notification settings - Fork 138
/
Copy pathtest_location.py
43 lines (38 loc) · 1.81 KB
/
test_location.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from graphql import SourceLocation
def describe_source_location():
def can_be_formatted():
location = SourceLocation(1, 2)
assert location.formatted == {"line": 1, "column": 2}
def can_compare_with_other_source_location():
location = SourceLocation(1, 2)
same_location = SourceLocation(1, 2)
assert location == same_location
assert not location != same_location # noqa: SIM202
different_location = SourceLocation(1, 1)
assert not location == different_location # noqa: SIM201
assert location != different_location
different_location = SourceLocation(2, 2)
assert not location == different_location # noqa: SIM201
assert location != different_location
def can_compare_with_location_tuple():
location = SourceLocation(1, 2)
same_location = (1, 2)
assert location == same_location
assert not location != same_location # noqa: SIM202
different_location = (1, 1)
assert not location == different_location # noqa: SIM201
assert location != different_location
different_location = (2, 2)
assert not location == different_location # noqa: SIM201
assert location != different_location
def can_compare_with_formatted_location():
location = SourceLocation(1, 2)
same_location = location.formatted
assert location == same_location
assert not location != same_location # noqa: SIM202
different_location = SourceLocation(1, 1).formatted
assert not location == different_location # noqa: SIM201
assert location != different_location
different_location = SourceLocation(2, 2).formatted
assert not location == different_location # noqa: SIM201
assert location != different_location