File: test_location.py

package info (click to toggle)
graphql-core 3.2.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,384 kB
  • sloc: python: 45,812; makefile: 26; sh: 13
file content (43 lines) | stat: -rw-r--r-- 1,707 bytes parent folder | download
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
        different_location = SourceLocation(1, 1)
        assert not location == different_location
        assert location != different_location
        different_location = SourceLocation(2, 2)
        assert not location == different_location
        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
        different_location = (1, 1)
        assert not location == different_location
        assert location != different_location
        different_location = (2, 2)
        assert not location == different_location
        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
        different_location = SourceLocation(1, 1).formatted
        assert not location == different_location
        assert location != different_location
        different_location = SourceLocation(2, 2).formatted
        assert not location == different_location
        assert location != different_location