Skip to content

Commit addabc0

Browse files
committed
Simplify test for handling lazy error messages
1 parent 2545ff4 commit addabc0

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

src/graphql/error/located_error.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
def located_error(
1313
original_error: Exception,
14-
nodes: Optional[Union["None", Collection["Node"]]],
14+
nodes: Optional[Union["None", Collection["Node"]]] = None,
1515
path: Optional[Collection[Union[str, int]]] = None,
1616
) -> GraphQLError:
1717
"""Located GraphQL Error

tests/error/test_located_error.py

+7-18
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
from graphql.error import GraphQLError, located_error
44

5-
from ..utils import dedent
6-
75

86
def describe_located_error():
97
def throws_without_an_original_error():
@@ -26,23 +24,14 @@ def does_not_pass_through_elasticsearch_like_errors():
2624
cast(Any, e).path = "/something/feed/_search"
2725
assert located_error(e, [], []) is not e
2826

29-
def handles_proxy_error_messages():
30-
class ProxyString:
31-
def __init__(self, value):
32-
self.value = value
33-
34-
def __str__(self):
35-
return self.value
27+
def handles_lazy_error_messages():
28+
class LazyString:
29+
def __str__(self) -> str:
30+
return "lazy"
3631

37-
class MyError(Exception):
32+
class LazyError(Exception):
3833
def __init__(self):
39-
self.message = ProxyString("Example error")
34+
self.message = LazyString()
4035
super().__init__()
4136

42-
error = located_error(MyError(), [], [])
43-
44-
assert str(error) == dedent(
45-
"""
46-
Example error
47-
"""
48-
)
37+
assert str(located_error(LazyError())) == "lazy"

0 commit comments

Comments
 (0)