MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_env_var

Method test_env_var

Lib/test/test_utf8_mode.py:72–102  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

70 # TODO: RUSTPYTHON
71 @unittest.expectedFailure
72 def test_env_var(self):
73 code = 'import sys; print(sys.flags.utf8_mode)'
74
75 out = self.get_output('-c', code, PYTHONUTF8='1')
76 self.assertEqual(out, '1')
77
78 out = self.get_output('-c', code, PYTHONUTF8='0')
79 self.assertEqual(out, '0')
80
81 # -X utf8 has the priority over PYTHONUTF8
82 out = self.get_output('-X', 'utf8=0', '-c', code, PYTHONUTF8='1')
83 self.assertEqual(out, '0')
84
85 if MS_WINDOWS:
86 # PYTHONLEGACYWINDOWSFSENCODING disables the UTF-8 mode
87 # and has the priority over PYTHONUTF8
88 out = self.get_output('-X', 'utf8', '-c', code, PYTHONUTF8='1',
89 PYTHONLEGACYWINDOWSFSENCODING='1')
90 self.assertEqual(out, '0')
91
92 # Cannot test with the POSIX locale, since the POSIX locale enables
93 # the UTF-8 mode
94 if not self.posix_locale():
95 # PYTHONUTF8 should be ignored if -E is used
96 out = self.get_output('-E', '-c', code, PYTHONUTF8='1')
97 self.assertEqual(out, '0')
98
99 # invalid mode
100 out = self.get_output('-c', code, PYTHONUTF8='xxx', failure=True)
101 self.assertIn('invalid PYTHONUTF8 environment variable value',
102 out.rstrip())
103
104 @unittest.expectedFailureIf(MS_WINDOWS, "TODO: RUSTPYTHON")
105 def test_filesystemencoding(self):

Callers

nothing calls this directly

Calls 5

get_outputMethod · 0.95
posix_localeMethod · 0.95
assertInMethod · 0.80
assertEqualMethod · 0.45
rstripMethod · 0.45

Tested by

no test coverage detected