-
Notifications
You must be signed in to change notification settings - Fork 765
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
Catching GraphQLLocatedError for tests #1072
Comments
I think what does |
@ulgens Thanks for your answer.
I edited my post. the And I also execute the query whereas I'm not logged in in a second test. The goal is to check that an exception is thrown If I perform a query while not logged in. If, for instance, an I hope I'm clear :D The only way that I've found up to now is to do : self.assertIsNotNone(
response.errors, "blablabla"
) or to check if there isn't any error : self.assertIsNone(
response.errors, "blablabla"
) I guess that does the trick too. But how can I be sure that the error is caused by the fact that I'm not logged in ? Or should I be satisfied by the fact that there is an error and..that's it ? |
Could provide a custom ExecutionContext class with it's own |
@zbyte64 |
In the past I have used the following class to get stack traces of exceptions:
Then when I setup my view in the urls.py I pass it as an option:
Kind of lame that this method still requires patching the urlconf for use in tests: https://pytest-django.readthedocs.io/en/latest/helpers.html#pytest-mark-urls-override-the-urlconf |
There is a new However passing the
Looking at the code of the |
Currently when passing `execution_context_class` like this: ``` GraphQLView.as_view(execution_context_class=CustomContext) ``` you get the following error from `View.as_view()` ``` TypeError: GraphQLView() received an invalid keyword 'execution_context_class'. as_view only accepts arguments that are already attributes of the class. ``` this PR fixes the `hasattr` check in `.as_view`. Fixes: graphql-python#1072
The above error is caused by |
…()` (#1109) * Add ability to pass `execution_context_class` to `GraphQLView.as_view()` Currently when passing `execution_context_class` like this: ``` GraphQLView.as_view(execution_context_class=CustomContext) ``` you get the following error from `View.as_view()` ``` TypeError: GraphQLView() received an invalid keyword 'execution_context_class'. as_view only accepts arguments that are already attributes of the class. ``` this PR fixes the `hasattr` check in `.as_view`. Fixes: #1072 * make black happy removed whitespace
Is your feature request related to a problem? Please describe.
No, question about doing a particular thing
Describe the solution you'd like
I'd like to know the way to catch GraphQLLocatedError, or a way to
assertRaises
them.I've tried :
But none of these work. How can I do this ?
The text was updated successfully, but these errors were encountered: