File tree 3 files changed +13
-6
lines changed
3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ a query language for APIs created by Facebook.
10
10
![ Lint Status] ( https://github.com/graphql-python/graphql-core/actions/workflows/lint.yml/badge.svg )
11
11
[ ![ Code Style] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/ambv/black )
12
12
13
- An extensive test suite with over 2300 unit tests and 100% coverage comprises a
13
+ An extensive test suite with over 2400 unit tests and 100% coverage comprises a
14
14
replication of the complete test suite of GraphQL.js, making sure this port is
15
15
reliable and compatible with GraphQL.js.
16
16
Original file line number Diff line number Diff line change 7
7
__all__ = ["Undefined" , "UndefinedType" ]
8
8
9
9
10
- class UndefinedType ( ValueError ) :
10
+ class UndefinedType :
11
11
"""Auxiliary class for creating the Undefined singleton."""
12
12
13
13
_instance : Optional [UndefinedType ] = None
@@ -34,7 +34,7 @@ def __bool__(self) -> bool:
34
34
return False
35
35
36
36
def __eq__ (self , other : Any ) -> bool :
37
- return other is Undefined
37
+ return other is Undefined or other is None
38
38
39
39
def __ne__ (self , other : Any ) -> bool :
40
40
return not self == other
Original file line number Diff line number Diff line change @@ -21,16 +21,23 @@ def is_hashable():
21
21
def as_bool_is_false ():
22
22
assert bool (Undefined ) is False
23
23
24
- def only_equal_to_itself ():
24
+ def only_equal_to_itself_and_none ():
25
+ # because we want it to behave similarly to JavaScript
25
26
assert Undefined == Undefined
26
27
assert not Undefined != Undefined
27
28
none_object = None
28
- assert Undefined ! = none_object
29
- assert not Undefined = = none_object
29
+ assert Undefined = = none_object
30
+ assert not Undefined ! = none_object
30
31
false_object = False
31
32
assert Undefined != false_object
32
33
assert not Undefined == false_object
33
34
35
+ def should_not_be_an_exception ():
36
+ # because we want to create similar code to JavaScript where
37
+ # undefined return values are different from exceptions
38
+ # (for instance, this is used in the completeValue function)
39
+ assert not isinstance (Undefined , Exception )
40
+
34
41
def cannot_be_redefined ():
35
42
with warns (RuntimeWarning , match = "Redefinition of 'Undefined'" ):
36
43
redefined_undefined = UndefinedType ()
You can’t perform that action at this time.
0 commit comments