mirror of
https://github.com/graphql-python/graphene.git
synced 2025-09-21 11:22:33 +03:00
Use consistent style of importing from pytest
This commit is contained in:
parent
df0657b816
commit
9594bc616c
|
@ -1,4 +1,4 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ...types import Argument, Field, Int, List, NonNull, ObjectType, Schema, String
|
||||
from ..connection import Connection, ConnectionField, PageInfo
|
||||
|
@ -146,7 +146,7 @@ def test_connectionfield():
|
|||
|
||||
def test_connectionfield_node_deprecated():
|
||||
field = ConnectionField(MyObject)
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
field.type
|
||||
|
||||
assert "ConnectionFields now need a explicit ConnectionType for Nodes." in str(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# https://github.com/graphql-python/graphene/issues/356
|
||||
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
import graphene
|
||||
from graphene import relay
|
||||
|
@ -23,7 +23,7 @@ def test_issue():
|
|||
class Query(graphene.ObjectType):
|
||||
things = relay.ConnectionField(MyUnion)
|
||||
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
graphene.Schema(query=Query)
|
||||
|
||||
assert str(exc_info.value) == (
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from functools import partial
|
||||
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ..argument import Argument, to_arguments
|
||||
from ..field import Field
|
||||
|
@ -43,7 +43,7 @@ def test_to_arguments():
|
|||
def test_to_arguments_raises_if_field():
|
||||
args = {"arg_string": Field(String)}
|
||||
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
with raises(ValueError) as exc_info:
|
||||
to_arguments(args)
|
||||
|
||||
assert str(exc_info.value) == (
|
||||
|
@ -55,7 +55,7 @@ def test_to_arguments_raises_if_field():
|
|||
def test_to_arguments_raises_if_inputfield():
|
||||
args = {"arg_string": InputField(String)}
|
||||
|
||||
with pytest.raises(ValueError) as exc_info:
|
||||
with raises(ValueError) as exc_info:
|
||||
to_arguments(args)
|
||||
|
||||
assert str(exc_info.value) == (
|
||||
|
|
|
@ -2,7 +2,8 @@ import datetime
|
|||
|
||||
import pytz
|
||||
from graphql import GraphQLError
|
||||
import pytest
|
||||
|
||||
from pytest import fixture, mark
|
||||
|
||||
from ..datetime import Date, DateTime, Time
|
||||
from ..objecttype import ObjectType
|
||||
|
@ -27,13 +28,13 @@ class Query(ObjectType):
|
|||
schema = Schema(query=Query)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@fixture
|
||||
def sample_datetime():
|
||||
utc_datetime = datetime.datetime(2019, 5, 25, 5, 30, 15, 10, pytz.utc)
|
||||
return utc_datetime
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@fixture
|
||||
def sample_time(sample_datetime):
|
||||
time = datetime.time(
|
||||
sample_datetime.hour,
|
||||
|
@ -45,7 +46,7 @@ def sample_time(sample_datetime):
|
|||
return time
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@fixture
|
||||
def sample_date(sample_datetime):
|
||||
date = sample_datetime.date()
|
||||
return date
|
||||
|
@ -170,7 +171,7 @@ def test_time_query_variable(sample_time):
|
|||
assert result.data == {"time": isoformat}
|
||||
|
||||
|
||||
@pytest.mark.xfail(
|
||||
@mark.xfail(
|
||||
reason="creating the error message fails when un-parsable object is not JSON serializable."
|
||||
)
|
||||
def test_bad_variables(sample_date, sample_datetime, sample_time):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from functools import partial
|
||||
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ..argument import Argument
|
||||
from ..field import Field
|
||||
|
@ -85,7 +85,7 @@ def test_field_with_string_type():
|
|||
|
||||
def test_field_not_source_and_resolver():
|
||||
MyType = object()
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
Field(MyType, source="value", resolver=lambda: None)
|
||||
assert (
|
||||
str(exc_info.value)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ..argument import Argument
|
||||
from ..dynamic import Dynamic
|
||||
|
@ -39,7 +39,7 @@ def test_generate_mutation_with_meta():
|
|||
|
||||
|
||||
def test_mutation_raises_exception_if_no_mutate():
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
with raises(AssertionError) as excinfo:
|
||||
|
||||
class MyMutation(Mutation):
|
||||
pass
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ..field import Field
|
||||
from ..interface import Interface
|
||||
|
@ -91,7 +91,7 @@ def test_generate_objecttype_with_private_attributes():
|
|||
m = MyObjectType(_private_state="custom")
|
||||
assert m._private_state == "custom"
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
with raises(TypeError):
|
||||
MyObjectType(_other_private_state="Wrong")
|
||||
|
||||
|
||||
|
@ -177,14 +177,14 @@ def test_objecttype_as_container_all_kwargs():
|
|||
|
||||
|
||||
def test_objecttype_as_container_extra_args():
|
||||
with pytest.raises(IndexError) as excinfo:
|
||||
with raises(IndexError) as excinfo:
|
||||
Container("1", "2", "3")
|
||||
|
||||
assert "Number of args exceeds number of fields" == str(excinfo.value)
|
||||
|
||||
|
||||
def test_objecttype_as_container_invalid_kwargs():
|
||||
with pytest.raises(TypeError) as excinfo:
|
||||
with raises(TypeError) as excinfo:
|
||||
Container(unexisting_field="3")
|
||||
|
||||
assert "'unexisting_field' is an invalid keyword argument for Container" == str(
|
||||
|
@ -218,7 +218,7 @@ def test_objecttype_with_possible_types():
|
|||
|
||||
|
||||
def test_objecttype_with_possible_types_and_is_type_of_should_raise():
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
with raises(AssertionError) as excinfo:
|
||||
|
||||
class MyObjectType(ObjectType):
|
||||
class Meta:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from graphql.pyutils import dedent
|
||||
|
||||
|
@ -29,7 +29,7 @@ def test_schema_get_type():
|
|||
|
||||
def test_schema_get_type_error():
|
||||
schema = Schema(Query)
|
||||
with pytest.raises(AttributeError) as exc_info:
|
||||
with raises(AttributeError) as exc_info:
|
||||
schema.X
|
||||
|
||||
assert str(exc_info.value) == 'Type "X" not found in the Schema'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from functools import partial
|
||||
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ..scalars import String
|
||||
from ..structures import List, NonNull
|
||||
|
@ -14,7 +14,7 @@ def test_list():
|
|||
|
||||
|
||||
def test_list_with_unmounted_type():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
List(String())
|
||||
|
||||
assert (
|
||||
|
@ -82,7 +82,7 @@ def test_nonnull_inherited_works_list():
|
|||
|
||||
|
||||
def test_nonnull_inherited_dont_work_nonnull():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
NonNull(NonNull(String))
|
||||
|
||||
assert (
|
||||
|
@ -92,7 +92,7 @@ def test_nonnull_inherited_dont_work_nonnull():
|
|||
|
||||
|
||||
def test_nonnull_with_unmounted_type():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
NonNull(String())
|
||||
|
||||
assert (
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from graphql.type import (
|
||||
GraphQLArgument,
|
||||
GraphQLEnumType,
|
||||
|
@ -290,7 +291,7 @@ def test_resolve_type_with_missing_type():
|
|||
return MyOtherObjectType
|
||||
|
||||
type_map = create_type_map([MyObjectType])
|
||||
with pytest.raises(AssertionError) as excinfo:
|
||||
with raises(AssertionError) as excinfo:
|
||||
resolve_type(resolve_type_func, type_map, "MyOtherObjectType", {}, {}, None)
|
||||
|
||||
assert "MyOtherObjectTyp" in str(excinfo.value)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from ..field import Field
|
||||
from ..objecttype import ObjectType
|
||||
|
@ -38,7 +38,7 @@ def test_generate_union_with_meta():
|
|||
|
||||
|
||||
def test_generate_union_with_no_types():
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
with raises(Exception) as exc_info:
|
||||
|
||||
class MyUnion(Union):
|
||||
pass
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
from pytest import mark
|
||||
|
||||
from ..crunch import crunch
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
@mark.parametrize(
|
||||
"description,uncrunched,crunched",
|
||||
[
|
||||
["number primitive", 0, [0]],
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from .. import deprecated
|
||||
from ..deprecated import deprecated as deprecated_decorator
|
||||
|
@ -71,5 +71,5 @@ def test_deprecated_class_text(mocker):
|
|||
def test_deprecated_other_object(mocker):
|
||||
mocker.patch.object(deprecated, "warn_deprecation")
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
with raises(TypeError):
|
||||
deprecated_decorator({})
|
||||
|
|
Loading…
Reference in New Issue
Block a user