simonw / datasette-graphql

Datasette plugin providing an automatic GraphQL API for your SQLite databases
https://datasette-graphql-demo.datasette.io/
Apache License 2.0
100 stars 6 forks source link

Schema caching tests broken on Python 3.6 and 3.7 #52

Closed simonw closed 4 years ago

simonw commented 4 years ago

Broken due to #51 commit https://github.com/simonw/datasette-graphql/commit/ae717857cde97db4a52054310b029bf8ba222d7c

Tests pass in 3.8, fail in 3.6 and 3.7.

simonw commented 4 years ago

Testing on my laptop:

% /Users/simon/.pyenv/versions/3.6.10/bin/python -m venv /tmp/python36env
% source /tmp/python36env/bin/activate
% cd Dropbox/Development/datasette-graphql 
datasette-graphql % pip install -e '.[test]'
...
% pytest
...
>       assert mock_schema_for_database.called
E       AssertionError: assert False
E        +  where False = <MagicMock name='schema_for_database' id='4517736632'>.called

tests/test_schema_caching.py:34: AssertionError
==== short test summary info ====
FAILED tests/test_schema_caching.py::test_schema_caching - AssertionError: assert False
==== 1 failed, 47 passed in 2.44s ====
simonw commented 4 years ago

I wonder if this is the problem: https://docs.python.org/3/library/unittest.mock.html#patch

Changed in version 3.8: patch() now returns an AsyncMock if the target is an async function.

simonw commented 4 years ago

I'm going to only run the template tag test on Python 3.8 or higher, rather than figure out how to get async mocking working on older Pythons.