Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

TestUnforgivinExeuctionContext.test_unexpected_error fails

未关闭
#1,346 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
38/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
graphql, python

调研方向

首先,在报告的环境中运行 graphene/types/tests/test_schema.py 里的 TestUnforgivingExecutionContext.test_unexpected_error。使用 execution_context_class=UnforgivingExecutionContext 跟踪 schema.execute 调用,并比较所列字段的预期异常传播行为。当测试对每个所列异常和嵌套查询都通过时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

🐛 bug

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

  • What is the current behavior?

TestUnforgivinExeuctionContext.test_unexpected_error fails.

============================= test session starts ==============================
platform linux -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.2.2 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /build/source, configfile: tox.ini
plugins: asyncio-0.15.1, benchmark-3.2.2, mock-3.6.1, snapshottest-0.6.0
collected 389 items

examples/starwars/tests/test_query.py .............                      [  3%]
examples/starwars_relay/tests/test_connections.py .                      [  3%]
examples/starwars_relay/tests/test_mutation.py .                         [  3%]
examples/starwars_relay/tests/test_objectidentification.py ......        [  5%]
graphene/relay/tests/test_connection.py ...........                      [  8%]
graphene/relay/tests/test_connection_async.py .                          [  8%]
graphene/relay/tests/test_connection_query.py .....................      [ 13%]
graphene/relay/tests/test_global_id.py ....                              [ 14%]
graphene/relay/tests/test_mutation.py .........                          [ 17%]
graphene/relay/tests/test_mutation_async.py ..                           [ 17%]
graphene/relay/tests/test_node.py ..............                         [ 21%]
graphene/relay/tests/test_node_custom.py ...........                     [ 24%]
graphene/tests/issues/test_313.py .                                      [ 24%]
graphene/tests/issues/test_356.py .                                      [ 24%]
graphene/tests/issues/test_425.py .........                              [ 26%]
graphene/tests/issues/test_490.py .                                      [ 27%]
graphene/tests/issues/test_720.py .                                      [ 27%]
graphene/tests/issues/test_956.py .                                      [ 27%]
graphene/types/tests/test_argument.py ........                           [ 29%]
graphene/types/tests/test_base.py .....                                  [ 31%]
graphene/types/tests/test_base64.py .......                              [ 32%]
graphene/types/tests/test_datetime.py .............                      [ 36%]
graphene/types/tests/test_decimal.py ....                                [ 37%]
graphene/types/tests/test_definition.py ..........                       [ 39%]
graphene/types/tests/test_dynamic.py .....                               [ 41%]
graphene/types/tests/test_enum.py ......................                 [ 46%]
graphene/types/tests/test_field.py ..............                        [ 50%]
graphene/types/tests/test_generic.py ..                                  [ 50%]
graphene/types/tests/test_inputfield.py ....                             [ 51%]
graphene/types/tests/test_inputobjecttype.py .........                   [ 54%]
graphene/types/tests/test_interface.py ...........                       [ 57%]
graphene/types/tests/test_json.py ..                                     [ 57%]
graphene/types/tests/test_mountedtype.py ..                              [ 58%]
graphene/types/tests/test_mutation.py .........                          [ 60%]
graphene/types/tests/test_objecttype.py ............................     [ 67%]
graphene/types/tests/test_query.py ....................                  [ 72%]
graphene/types/tests/test_resolver.py .......                            [ 74%]
graphene/types/tests/test_scalar.py ..                                   [ 75%]
graphene/types/tests/test_scalars_serialization.py ....                  [ 76%]
graphene/types/tests/test_schema.py ..........FFFFFFFFF                  [ 80%]
graphene/types/tests/test_structures.py ................                 [ 85%]
graphene/types/tests/test_subscribe_async.py ....                        [ 86%]
graphene/types/tests/test_type_map.py ........                           [ 88%]
graphene/types/tests/test_union.py ....                                  [ 89%]
graphene/types/tests/test_uuid.py ..                                     [ 89%]
graphene/utils/tests/test_crunch.py ...............                      [ 93%]
graphene/utils/tests/test_deduplicator.py .....                          [ 94%]
graphene/utils/tests/test_deprecated.py ......                           [ 96%]
graphene/utils/tests/test_module_loading.py .....                        [ 97%]
graphene/utils/tests/test_orderedtype.py .....                           [ 98%]
graphene/utils/tests/test_resolve_only_args.py .                         [ 99%]
graphene/utils/tests/test_str_converters.py ..                           [ 99%]
graphene/utils/tests/test_trim_docstring.py .                            [100%]

=================================== FAILURES ===================================
_ TestUnforgivingExecutionContext.test_unexpected_error[unexpectedValueErrorField-ValueError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff54de550>
field = 'unexpectedValueErrorField', exception = <class 'ValueError'>
schema = <graphene.types.schema.Schema object at 0x7ffff54df550>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'ValueError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[unexpectedTypeErrorField-TypeError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff54df160>
field = 'unexpectedTypeErrorField', exception = <class 'TypeError'>
schema = <graphene.types.schema.Schema object at 0x7ffff4d30490>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'TypeError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[unexpectedAttributeErrorField-AttributeError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff5953d00>
field = 'unexpectedAttributeErrorField', exception = <class 'AttributeError'>
schema = <graphene.types.schema.Schema object at 0x7ffff573c520>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'AttributeError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[unexpectedKeyErrorField-KeyError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff4d30880>
field = 'unexpectedKeyErrorField', exception = <class 'KeyError'>
schema = <graphene.types.schema.Schema object at 0x7ffff4d30040>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'KeyError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[nestedObject { unexpectedValueErrorField }-ValueError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff5a19a90>
field = 'nestedObject { unexpectedValueErrorField }'
exception = <class 'ValueError'>
schema = <graphene.types.schema.Schema object at 0x7ffff59f1400>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'ValueError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[nestedObject { unexpectedTypeErrorField }-TypeError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff4d361f0>
field = 'nestedObject { unexpectedTypeErrorField }'
exception = <class 'TypeError'>
schema = <graphene.types.schema.Schema object at 0x7ffff59f4250>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'TypeError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[nestedObject { unexpectedAttributeErrorField }-AttributeError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff56ef430>
field = 'nestedObject { unexpectedAttributeErrorField }'
exception = <class 'AttributeError'>
schema = <graphene.types.schema.Schema object at 0x7ffff56ef7f0>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'AttributeError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[nestedObject { unexpectedKeyErrorField }-KeyError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff59e39d0>
field = 'nestedObject { unexpectedKeyErrorField }'
exception = <class 'KeyError'>
schema = <graphene.types.schema.Schema object at 0x7ffff5630be0>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'KeyError'>

graphene/types/tests/test_schema.py:180: Failed
_ TestUnforgivingExecutionContext.test_unexpected_error[nestedObjectError { __typename }-TypeError] _

self = <graphene.types.tests.test_schema.TestUnforgivingExecutionContext object at 0x7ffff5a677c0>
field = 'nestedObjectError { __typename }', exception = <class 'TypeError'>
schema = <graphene.types.schema.Schema object at 0x7ffff595ce50>

    @mark.parametrize(
        "field,exception",
        [
            ("unexpectedValueErrorField", ValueError),
            ("unexpectedTypeErrorField", TypeError),
            ("unexpectedAttributeErrorField", AttributeError),
            ("unexpectedKeyErrorField", KeyError),
            ("nestedObject { unexpectedValueErrorField }", ValueError),
            ("nestedObject { unexpectedTypeErrorField }", TypeError),
            ("nestedObject { unexpectedAttributeErrorField }", AttributeError),
            ("nestedObject { unexpectedKeyErrorField }", KeyError),
            ("nestedObjectError { __typename }", TypeError),
        ],
    )
    def test_unexpected_error(self, field, exception, schema):
        with raises(exception):
            # no result, but the exception should be propagated
>           schema.execute(
                f"query {{ {field} }}",
                execution_context_class=UnforgivingExecutionContext,
            )
E           Failed: DID NOT RAISE <class 'TypeError'>

graphene/types/tests/test_schema.py:180: Failed
============================= SnapshotTest summary =============================
21 snapshots passed.
=========================== short test summary info ============================
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[unexpectedValueErrorField-ValueError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[unexpectedTypeErrorField-TypeError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[unexpectedAttributeErrorField-AttributeError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[unexpectedKeyErrorField-KeyError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[nestedObject { unexpectedValueErrorField }-ValueError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[nestedObject { unexpectedTypeErrorField }-TypeError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[nestedObject { unexpectedAttributeErrorField }-AttributeError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[nestedObject { unexpectedKeyErrorField }-KeyError]
FAILED graphene/types/tests/test_schema.py::TestUnforgivingExecutionContext::test_unexpected_error[nestedObjectError { __typename }-TypeError]
======================== 9 failed, 380 passed in 3.56s =========================

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via
    a github repo, https://repl.it or similar.

  • What is the expected behavior?

Tests should complete.

  • What is the motivation / use case for changing the behavior?

n/a

  • Please tell us about your environment:

    • Version:
      • graphene 3.0b7
    • Dependencies:
      • graphql-core 3.1.5
      • graphql-relay 3.1.0
      • aniso8601
    • Platform: Linux
    • Test dependencies:
      • Python 3.9.5
      • pytest-6.2.4
      • py-1.10.0
      • pluggy-0.13.1
      • pytest-asyncio-0.15.1
      • pytest-benchmark-3.2.2
      • pytest-mock-3.6.1
      • snapshottest-0.6.0
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

Reproducible with python 3.7, 3.8 and 3.9.

主要语言
Python
星标
8.2k
派生
818
PR 合并指标
30 天内没有已合并 PR

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

graphql-python/graphene 的其他 Issue

查看 graphql-python/graphene 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。