File tree Expand file tree Collapse file tree 3 files changed +13
-6
lines changed Expand file tree Collapse file tree 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.
1010![ Lint Status] ( https://github.com/graphql-python/graphql-core/actions/workflows/lint.yml/badge.svg )
1111[ ![ Code Style] ( https://img.shields.io/badge/code%20style-black-000000.svg )] ( https://github.com/ambv/black )
1212
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
1414replication of the complete test suite of GraphQL.js, making sure this port is
1515reliable and compatible with GraphQL.js.
1616
Original file line number Diff line number Diff line change 77__all__ = ["Undefined" , "UndefinedType" ]
88
99
10- class UndefinedType ( ValueError ) :
10+ class UndefinedType :
1111 """Auxiliary class for creating the Undefined singleton."""
1212
1313 _instance : Optional [UndefinedType ] = None
@@ -34,7 +34,7 @@ def __bool__(self) -> bool:
3434 return False
3535
3636 def __eq__ (self , other : Any ) -> bool :
37- return other is Undefined
37+ return other is Undefined or other is None
3838
3939 def __ne__ (self , other : Any ) -> bool :
4040 return not self == other
Original file line number Diff line number Diff line change @@ -21,16 +21,23 @@ def is_hashable():
2121 def as_bool_is_false ():
2222 assert bool (Undefined ) is False
2323
24- def only_equal_to_itself ():
24+ def only_equal_to_itself_and_none ():
25+ # because we want it to behave similarly to JavaScript
2526 assert Undefined == Undefined
2627 assert not Undefined != Undefined
2728 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
3031 false_object = False
3132 assert Undefined != false_object
3233 assert not Undefined == false_object
3334
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+
3441 def cannot_be_redefined ():
3542 with warns (RuntimeWarning , match = "Redefinition of 'Undefined'" ):
3643 redefined_undefined = UndefinedType ()
You can’t perform that action at this time.
0 commit comments