| 1 |
from graphql import SourceLocation |
| 2 |
|
| 3 |
|
| 4 |
def describe_source_location(): |
| 5 |
def can_be_formatted(): |
| 6 |
location = SourceLocation(1, 2) |
| 7 |
assert location.formatted == {"line": 1, "column": 2} |
| 8 |
|
| 9 |
def can_compare_with_other_source_location(): |
| 10 |
location = SourceLocation(1, 2) |
| 11 |
same_location = SourceLocation(1, 2) |
| 12 |
assert location == same_location |
| 13 |
assert not location != same_location |
| 14 |
different_location = SourceLocation(1, 1) |
| 15 |
assert not location == different_location |
| 16 |
assert location != different_location |
| 17 |
different_location = SourceLocation(2, 2) |
| 18 |
assert not location == different_location |
| 19 |
assert location != different_location |
| 20 |
|
| 21 |
def can_compare_with_location_tuple(): |
| 22 |
location = SourceLocation(1, 2) |
| 23 |
same_location = (1, 2) |
| 24 |
assert location == same_location |
| 25 |
assert not location != same_location |
| 26 |
different_location = (1, 1) |
| 27 |
assert not location == different_location |
| 28 |
assert location != different_location |
| 29 |
different_location = (2, 2) |
| 30 |
assert not location == different_location |
| 31 |
assert location != different_location |
| 32 |
|
| 33 |
def can_compare_with_formatted_location(): |
| 34 |
location = SourceLocation(1, 2) |
| 35 |
same_location = location.formatted |
| 36 |
assert location == same_location |
| 37 |
assert not location != same_location |
| 38 |
different_location = SourceLocation(1, 1).formatted |
| 39 |
assert not location == different_location |
| 40 |
assert location != different_location |
| 41 |
different_location = SourceLocation(2, 2).formatted |
| 42 |
assert not location == different_location |
| 43 |
assert location != different_location |