diff options
| author | Durval Carvalho <durvalcsouza@outlook.com> | 2022-12-21 14:25:24 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2023-01-31 06:35:30 +0100 |
| commit | 40217d1a82b0c16cddba377325d12b2c253f402a (patch) | |
| tree | fa6099d5ba877ebf8e29ec4cc2a281d5f8047150 | |
| parent | 20a0850099340fb4cb8df0e4441e5019b2cbd1ea (diff) | |
Fixed #34180 -- Added note about resetting language in test tear-downs.
Co-authored-by: Faris Naimi <farisfaris66@gmail.com>
| -rw-r--r-- | AUTHORS | 1 | ||||
| -rw-r--r-- | docs/topics/testing/tools.txt | 8 |
2 files changed, 9 insertions, 0 deletions
@@ -330,6 +330,7 @@ answer newbie questions, and generally made Django that much better: Florian Apolloner <florian@apolloner.eu> Florian Demmer <fdemmer@gmail.com> Florian Moussous <florian.moussous@gmail.com> + fnaimi66 <https://github.com/fnaimi66> Fran Hrženjak <fran.hrzenjak@gmail.com> Francesco Panico <panico.francesco@gmail.com> Francisco Albarran Cristobal <pahko.xd@gmail.com> diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index f3e5ec982f..82fa4116f9 100644 --- a/docs/topics/testing/tools.txt +++ b/docs/topics/testing/tools.txt @@ -685,6 +685,14 @@ or by including the ``Accept-Language`` HTTP header in the request:: response = self.client.get("/", headers={"accept-language": "fr"}) self.assertEqual(response.content, b"Bienvenue sur mon site.") +.. note:: + + When using these methods, ensure to reset the active language at the end of + each test:: + + def tearDown(self): + translation.activate(settings.LANGUAGE_CODE) + More details are in :ref:`how-django-discovers-language-preference`. If the middleware isn't enabled, the active language may be set using |
