-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] hypothesis.errors.InvalidArgument: test has already been decorated with a settings object. #2115
Comments
Hi! This is weird, I think we should have tests for it. What is your |
And |
Sure thing, the test venv has:
|
I tried to reproduce it with a simpler version but wasn't successful. I also noted that |
Generally, I don't expect that the exact Python version / Platform would matter here, but will take a closer look. import hypothesis
import pytest
from hypothesis import HealthCheck
import schemathesis
from test.apps import _graphql
@pytest.fixture
def graphql_schema():
app = _graphql._fastapi.create_app()
return schemathesis.graphql.from_asgi("/graphql", app)
schema = schemathesis.from_pytest_fixture("graphql_schema")
@schema.parametrize()
@hypothesis.settings(
deadline=None,
suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much],
)
def test_graphql_schema(case):
response = case.call_asgi()
case.validate_response(response)
How do you run your tests? Maybe there is some CLI arg, that could interfere? |
You're right, I had left out a key detail from my example code which it turns out is the cause of the error. It seems that the error happens when the schema fixture is parametrized. Here is an example to demonstrate: import copy
import falcon
import hypothesis
from hypothesis import HealthCheck
import itertools
import pytest
import schemathesis
from .util import GRAPHQL_HEADERS, create_database
INTERFACES = ["v1"]
DB_SCHEMAS = ["db0"]
@pytest.fixture(params=itertools.product(INTERFACES, DB_SCHEMAS))
def graphql_schema_from_asgi(request, db_setup_factory):
interface, db_schema = request.param
setup = db_setup_factory(schema=db_schema)
# this slows things down but we need this fixture to not be async
# so schemathesis.from_pytest_fixture can use it correctly
falcon.async_to_sync(create_database, setup.sql_engine_manager)
endpoint = f"/{interface}/graphql"
return schemathesis.graphql.from_asgi(endpoint, setup.app, headers=GRAPHQL_HEADERS)
graphql_schema = schemathesis.from_pytest_fixture("graphql_schema_from_asgi")
@graphql_schema.parametrize()
@hypothesis.settings(
deadline=None,
suppress_health_check=[HealthCheck.too_slow, HealthCheck.filter_too_much],
)
def test_graphql_schema(case):
response = case.call_asgi()
case.validate_response(response) |
Thank you! I can reproduce it now. |
Fixed in |
Confirmed that the error is now resolved with 3.26.1 - thanks for the super fast turnaround! |
Awesome! Happy to help |
Checklist
Describe the bug
After upgrading from schemathesis 3.19.5 to 3.26.0, several tests are now failing with this error message:
To Reproduce
Here is an example test that produces the above error:
The problem seems to be the fact that we are decorating our test with both the
@graphql_schema
decorator generated by schemathesis and the@hypothesis.settings
decorator. But we need to do this, in order to customize the behavior of hypothesis for our test.Expected behavior
The expected behaviour is that a test which passes without issue in 3.19.5 of schemathesis would continue to work in 3.26.0
Environment
Additional context
The text was updated successfully, but these errors were encountered: