From 1a5b7d318fa923edfcefd3df8f64dae2e9c49d3f Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Tue, 23 Jun 2020 21:17:30 -0700 Subject: [PATCH] Fixed test I broke in #863 --- docs/changelog.rst | 2 +- tests/test_plugins.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 07a0b3a6..e0b88820 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -17,7 +17,7 @@ Changelog - Respect existing ``scope["actor"]`` if already set by ASGI middleware. (`#854 `__) - New process for shipping :ref:`contributing_alpha_beta`. (`#807 `__) - Re-arranged plugins documentation into :ref:`plugins`, :ref:`writing_plugins`, :ref:`plugin_hooks` and a new section on :ref:`testing_plugins`. (`#687 `__) -- ``{{ csrftoken() }}`` now works when plugins render a template using ``datasette.render_template()``. (`#863 `__) +- ``{{ csrftoken() }}`` now works when plugins render a template using ``datasette.render_template(..., request=request)``. (`#863 `__) .. _v0_44: diff --git a/tests/test_plugins.py b/tests/test_plugins.py index 2c114850..1a6f004a 100644 --- a/tests/test_plugins.py +++ b/tests/test_plugins.py @@ -580,9 +580,8 @@ def test_register_routes_post(app_client): assert "post data" == response.json["this is"] -def test_register_routes_csrftoken(tmpdir): - templates = tmpdir / "templates" - templates.mkdir() +def test_register_routes_csrftoken(restore_working_directory, tmpdir_factory): + templates = tmpdir_factory.mktemp("templates") (templates / "csrftoken_form.html").write_text( "CSRFTOKEN: {{ csrftoken() }}", "utf-8" )