<commit_before>import pytest

from graphql import (GraphQLField, GraphQLInterfaceType, GraphQLObjectType,
                     GraphQLString)

from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType


class Container(ObjectType):
    field1 = Field(GraphQLString, name='field1')
    field2 = Field(GraphQLString, name='field2')


def test_generate_objecttype():
    class MyObjectType(ObjectType):
        '''Documentation'''

    graphql_type = MyObjectType._meta.graphql_type
    assert isinstance(graphql_type, GraphQLObjectType)
    assert graphql_type.name == "MyObjectType"
    assert graphql_type.description == "Documentation"


def test_generate_objecttype_with_meta():
    class MyObjectType(ObjectType):

        class Meta:
            name = 'MyOtherObjectType'
            description = 'Documentation'

    graphql_type = MyObjectType._meta.graphql_type
    assert isinstance(graphql_type, GraphQLObjectType)
    assert graphql_type.name == "MyOtherObjectType"
    assert graphql_type.description == "Documentation"


def test_empty_objecttype_has_meta():
    class MyObjectType(ObjectType):
        pass

    assert MyObjectType._meta


def test_generate_objecttype_with_fields():
    class MyObjectType(ObjectType):
        field = Field(GraphQLString)

    graphql_type = MyObjectType._meta.graphql_type
    fields = graphql_type.get_fields()
    assert 'field' in fields


def test_ordered_fields_in_objecttype():
    class MyObjectType(ObjectType):
        b = Field(GraphQLString)
        a = Field(GraphQLString)
        field = Field(GraphQLString)
        asa = Field(GraphQLString)

    graphql_type = MyObjectType._meta.graphql_type
    fields = graphql_type.get_fields()
    assert list(fields.keys()) == ['b', 'a', 'field', 'asa']


def test_objecttype_inheritance():
    class MyInheritedObjectType(ObjectType):
        inherited = Field(GraphQLString)

    class MyObjectType(MyInheritedObjectType):
        field1 = Field(GraphQLString)
        field2 = Field(GraphQLString)

    graphql_type = MyObjectType._meta.graphql_type
    fields = graphql_type.get_fields()
    assert fields.keys() == ['inherited', 'field1', 'field2']


def test_objecttype_as_container_get_fields():

    class Container(ObjectType):
        field1 = Field(GraphQLString)
        field2 = Field(GraphQLString)

    assert list(Container._meta.graphql_type.get_fields().keys()) == ['field1', 'field2']

<commit_msg>Fixed Python3 tests<commit_after>import pytest

from graphql import (GraphQLField, GraphQLInterfaceType, GraphQLObjectType,
                     GraphQLString)

from ..field import Field
from ..interface import Interface
from ..objecttype import ObjectType


class Container(ObjectType):
    field1 = Field(GraphQLString, name='field1')
    field2 = Field(GraphQLString, name='field2')


def test_generate_objecttype():
    class MyObjectType(ObjectType):
        '''Documentation'''

    graphql_type = MyObjectType._meta.graphql_type
    assert isinstance(graphql_type, GraphQLObjectType)
    assert graphql_type.name == "MyObjectType"
    assert graphql_type.description == "Documentation"


def test_generate_objecttype_with_meta():
    class MyObjectType(ObjectType):

        class Meta:
            name = 'MyOtherObjectType'
            description = 'Documentation'

    graphql_type = MyObjectType._meta.graphql_type
    assert isinstance(graphql_type, GraphQLObjectType)
    assert graphql_type.name == "MyOtherObjectType"
    assert graphql_type.description == "Documentation"


def test_empty_objecttype_has_meta():
    class MyObjectType(ObjectType):
        pass

    assert MyObjectType._meta


def test_generate_objecttype_with_fields():
    class MyObjectType(ObjectType):
        field = Field(GraphQLString)

    graphql_type = MyObjectType._meta.graphql_type
    fields = graphql_type.get_fields()
    assert 'field' in fields


def test_ordered_fields_in_objecttype():
    class MyObjectType(ObjectType):
        b = Field(GraphQLString)
        a = Field(GraphQLString)
        field = Field(GraphQLString)
        asa = Field(GraphQLString)

    graphql_type = MyObjectType._meta.graphql_type
    fields = graphql_type.get_fields()
    assert list(fields.keys()) == ['b', 'a', 'field', 'asa']


def test_objecttype_inheritance():
    class MyInheritedObjectType(ObjectType):
        inherited = Field(GraphQLString)

    class MyObjectType(MyInheritedObjectType):
        field1 = Field(GraphQLString)
        field2 = Field(GraphQLString)

    graphql_type = MyObjectType._meta.graphql_type
    fields = graphql_type.get_fields()
    assert list(fields.keys()) == ['inherited', 'field1', 'field2']


def test_objecttype_as_container_get_fields():

    class Container(ObjectType):
        field1 = Field(GraphQLString)
        field2 = Field(GraphQLString)

    assert list(Container._meta.graphql_type.get_fields().keys()) == ['field1', 'field2']


{'fraction_non_alphanumeric': 0.09319286871961102, 'fraction_numerical': 0.00506482982171799, 'mean_word_length': 3.971802618328298, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3418720', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1438, 'n_words': 286}