summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDurval Carvalho <durvalcsouza@outlook.com>2022-12-21 14:25:24 -0500
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2023-01-31 07:29:55 +0100
commitf586c12f0167f51c9e398d7214ac1aa5522f1460 (patch)
treeb983c0360fd46e180c46be70ecfb4cd37fd7d961
parent26b7a25632e7fe0b897bc9b88b5c364a4b6398b6 (diff)
[4.1.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
-rw-r--r--AUTHORS1
-rw-r--r--docs/topics/testing/tools.txt8
2 files changed, 9 insertions, 0 deletions
diff --git a/AUTHORS b/AUTHORS
index f77693fea5..fb9550f079 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -326,6 +326,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>
Francisco Albarran Cristobal <pahko.xd@gmail.com>
Francisco Couzo <franciscouzo@gmail.com>
diff --git a/docs/topics/testing/tools.txt b/docs/topics/testing/tools.txt
index f9764998ca..a7ac9023f3 100644
--- a/docs/topics/testing/tools.txt
+++ b/docs/topics/testing/tools.txt
@@ -638,6 +638,14 @@ or by including the ``Accept-Language`` HTTP header in the request::
response = self.client.get('/', HTTP_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