Skip to content

Commit

Permalink
fix: run the tests in python 3.12 and 3.13 and remove snapshottest
Browse files Browse the repository at this point in the history
…dependency (#1572)

* actually run the tests in python 3.12 and 3.13

* remove snapshottest from the example tests

so that the tests pass in 3.12 and 3.13 again

* remove the section about snapshot testing from the testing docs

because the snapshottest package doesn't work on Python 3.12 and above

* fix assertion for badly formed JSON input on Python 3.13

* fix deprecation warning about datetime.utcfromtimestamp()
  • Loading branch information
PoByBolek authored Aug 8, 2024
1 parent dc3b2e4 commit 48678af
Show file tree
Hide file tree
Showing 15 changed files with 344 additions and 445 deletions.
40 changes: 0 additions & 40 deletions docs/testing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,43 +69,3 @@ You can also add extra keyword arguments to the ``execute`` method, such as
'hey': 'hello Peter!'
}
}
Snapshot testing
~~~~~~~~~~~~~~~~

As our APIs evolve, we need to know when our changes introduce any breaking changes that might break
some of the clients of our GraphQL app.

However, writing tests and replicating the same response we expect from our GraphQL application can be a
tedious and repetitive task, and sometimes it's easier to skip this process.

Because of that, we recommend the usage of `SnapshotTest <https://github.com/syrusakbary/snapshottest/>`_.

SnapshotTest lets us write all these tests in a breeze, as it automatically creates the ``snapshots`` for us
the first time the test are executed.


Here is a simple example on how our tests will look if we use ``pytest``:

.. code:: python
def test_hey(snapshot):
client = Client(my_schema)
# This will create a snapshot dir and a snapshot file
# the first time the test is executed, with the response
# of the execution.
snapshot.assert_match(client.execute('''{ hey }'''))
If we are using ``unittest``:

.. code:: python
from snapshottest import TestCase
class APITestCase(TestCase):
def test_api_me(self):
"""Testing the API for /me"""
client = Client(my_schema)
self.assertMatchSnapshot(client.execute('''{ hey }'''))
Empty file.
98 changes: 0 additions & 98 deletions examples/starwars/tests/snapshots/snap_test_query.py

This file was deleted.

Loading

0 comments on commit 48678af

Please sign in to comment.