fixed some of pre-commit's complaints

This commit is contained in:
as 2018-12-11 08:12:41 +01:00
parent 70c742e49b
commit 6c97a90692
2 changed files with 18 additions and 7 deletions

View File

@ -30,7 +30,7 @@ server with an associated set of resolve methods that know how to fetch
data. data.
We are going to create a very simple schema, with a ``Query`` with only We are going to create a very simple schema, with a ``Query`` with only
one field: ``hello`` and an input name. And when we query it, it should return ``"Hello one field: ``hello`` and an input name. And when we query it, it should return ``"Hello
{argument}"``. {argument}"``.
.. code:: python .. code:: python

View File

@ -145,12 +145,14 @@ def test_time_query_variable():
assert result.data == {"time": isoformat} assert result.data == {"time": isoformat}
@pytest.mark.xfail(reason="creating the error message fails when un-parsable object is not JSON serializable.") @pytest.mark.xfail(
reason="creating the error message fails when un-parsable object is not JSON serializable."
)
def test_bad_variables(): def test_bad_variables():
def _test_bad_variables(type, input): def _test_bad_variables(type, input):
result = schema.execute( result = schema.execute(
"""query Test($input: %s){ %s(in: $input) }""" % (type, type.lower()), """query Test($input: {}){{ {}(in: $input) }}""".format(type, type.lower()),
variables={"input": input} variables={"input": input},
) )
assert len(result.errors) == 1 assert len(result.errors) == 1
# when `input` is not JSON serializable formatting the error message in # when `input` is not JSON serializable formatting the error message in
@ -166,9 +168,18 @@ def test_bad_variables():
time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo) time = datetime.time(now.hour, now.minute, now.second, now.microsecond, now.tzinfo)
bad_pairs = [ bad_pairs = [
('DateTime', not_a_date), ('DateTime', not_a_date_str), ('DateTime', today), ('DateTime', time), ("DateTime", not_a_date),
('Date', not_a_date), ('Date', not_a_date_str), ('Date', now), ('Date', time), ("DateTime", not_a_date_str),
('Time', not_a_date), ('Time', not_a_date_str), ('Time', now), ('Time', today) ("DateTime", today),
("DateTime", time),
("Date", not_a_date),
("Date", not_a_date_str),
("Date", now),
("Date", time),
("Time", not_a_date),
("Time", not_a_date_str),
("Time", now),
("Time", today),
] ]
for type, input in bad_pairs: for type, input in bad_pairs: