|
2 | 2 | from math import inf, nan, pi
|
3 | 3 | from typing import Any
|
4 | 4 |
|
5 |
| -from pytest import raises, warns |
| 5 | +from pytest import raises |
6 | 6 |
|
7 | 7 | from graphql.error import GraphQLError
|
8 | 8 | from graphql.language import parse_value as parse_value_to_ast
|
@@ -175,11 +175,8 @@ def serializes():
|
175 | 175 | assert str(exc_info.value) == "Int cannot represent non-integer value: [5]"
|
176 | 176 |
|
177 | 177 | def cannot_be_redefined():
|
178 |
| - with warns( |
179 |
| - RuntimeWarning, match="Redefinition of specified scalar type 'Int'" |
180 |
| - ): |
181 |
| - redefined_int = GraphQLScalarType(name="Int") |
182 |
| - assert redefined_int == GraphQLInt |
| 178 | + with raises(TypeError, match="Redefinition of reserved type 'Int'"): |
| 179 | + GraphQLScalarType(name="Int") |
183 | 180 |
|
184 | 181 | def pickles():
|
185 | 182 | assert pickle.loads(pickle.dumps(GraphQLInt)) is GraphQLInt
|
@@ -308,11 +305,8 @@ def serializes():
|
308 | 305 | )
|
309 | 306 |
|
310 | 307 | def cannot_be_redefined():
|
311 |
| - with warns( |
312 |
| - RuntimeWarning, match="Redefinition of specified scalar type 'Float'" |
313 |
| - ): |
314 |
| - redefined_float = GraphQLScalarType(name="Float") |
315 |
| - assert redefined_float == GraphQLFloat |
| 308 | + with raises(TypeError, match="Redefinition of reserved type 'Float'"): |
| 309 | + GraphQLScalarType(name="Float") |
316 | 310 |
|
317 | 311 | def pickles():
|
318 | 312 | assert pickle.loads(pickle.dumps(GraphQLFloat)) is GraphQLFloat
|
@@ -424,11 +418,8 @@ def __str__(self):
|
424 | 418 | )
|
425 | 419 |
|
426 | 420 | def cannot_be_redefined():
|
427 |
| - with warns( |
428 |
| - RuntimeWarning, match="Redefinition of specified scalar type 'String'" |
429 |
| - ): |
430 |
| - redefined_string = GraphQLScalarType(name="String") |
431 |
| - assert redefined_string == GraphQLString |
| 421 | + with raises(TypeError, match="Redefinition of reserved type 'String'"): |
| 422 | + GraphQLScalarType(name="String") |
432 | 423 |
|
433 | 424 | def pickles():
|
434 | 425 | assert pickle.loads(pickle.dumps(GraphQLString)) is GraphQLString
|
@@ -576,11 +567,8 @@ def serializes():
|
576 | 567 | )
|
577 | 568 |
|
578 | 569 | def cannot_be_redefined():
|
579 |
| - with warns( |
580 |
| - RuntimeWarning, match="Redefinition of specified scalar type 'Boolean'" |
581 |
| - ): |
582 |
| - redefined_boolean = GraphQLScalarType(name="Boolean") |
583 |
| - assert redefined_boolean == GraphQLBoolean |
| 570 | + with raises(TypeError, match="Redefinition of reserved type 'Boolean'"): |
| 571 | + GraphQLScalarType(name="Boolean") |
584 | 572 |
|
585 | 573 | def pickles():
|
586 | 574 | assert pickle.loads(pickle.dumps(GraphQLBoolean)) is GraphQLBoolean
|
@@ -707,11 +695,8 @@ def __str__(self):
|
707 | 695 | assert str(exc_info.value) == "ID cannot represent value: ['abc']"
|
708 | 696 |
|
709 | 697 | def cannot_be_redefined():
|
710 |
| - with warns( |
711 |
| - RuntimeWarning, match="Redefinition of specified scalar type 'ID'" |
712 |
| - ): |
713 |
| - redefined_id = GraphQLScalarType(name="ID") |
714 |
| - assert redefined_id == GraphQLID |
| 698 | + with raises(TypeError, match="Redefinition of reserved type 'ID'"): |
| 699 | + GraphQLScalarType(name="ID") |
715 | 700 |
|
716 | 701 | def pickles():
|
717 | 702 | assert pickle.loads(pickle.dumps(GraphQLID)) is GraphQLID
|
0 commit comments