summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMark Rogaski <mrogaski@pobox.com>2017-07-12 00:59:46 -0400
committerTim Graham <timograham@gmail.com>2017-07-13 13:12:29 -0400
commitfc6b90bdb7a9531e988245942f79518308616b7b (patch)
tree0870ffd6796536b3a6c824b3e7c23650e81dac16 /tests
parent30f334cc58e939c7d9bd8455c80bd066fbde9f2b (diff)
[1.11.x] Fixed #28174 -- Fixed crash in runserver's autoreload with Python 2 on Windows with non-str environment variables.
Diffstat (limited to 'tests')
-rw-r--r--tests/utils_tests/test_autoreload.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index 5d42af62c8..3fae2e4da2 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -1,6 +1,9 @@
+from __future__ import unicode_literals
+
import gettext
import os
import shutil
+import sys
import tempfile
from importlib import import_module
@@ -251,3 +254,17 @@ class ResetTranslationsTests(SimpleTestCase):
self.assertEqual(trans_real._translations, {})
self.assertIsNone(trans_real._default)
self.assertIsInstance(trans_real._active, _thread._local)
+
+
+class TestRestartWithReloader(SimpleTestCase):
+
+ def test_environment(self):
+ """"
+ With Python 2 on Windows, restart_with_reloader() coerces environment
+ variables to str to avoid "TypeError: environment can only contain
+ strings" in Python's subprocess.py.
+ """
+ # With unicode_literals, these values are unicode.
+ os.environ['SPAM'] = 'spam'
+ with mock.patch.object(sys, 'argv', ['-c', 'pass']):
+ autoreload.restart_with_reloader()