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 07:29:21 +0100 |
| commit | af396ce3f9a15db27173469b1eb2388810dd00c3 (patch) | |
| tree | d72757e761522785572f5e7241b31570fbb42501 /docs | |
| parent | 7217c11eba6175023fff859cd7b3dd6c94690a0d (diff) | |
[4.2.x] Fixed #34180 -- Added note about resetting language in test tear-downs.
Co-authored-by: Faris Naimi <farisfaris66@gmail.com>
Backport of 40217d1a82b0c16cddba377325d12b2c253f402a from main
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/topics/testing/tools.txt | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt index 1ecc97a2a9..ba42180744 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 |
