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

Method test_expanduser_home_envvar

Lib/test/test_posixpath.py:303–317  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

301 self.assertEqual(posixpath.expanduser(b"foo"), b"foo")
302
303 def test_expanduser_home_envvar(self):
304 with os_helper.EnvironmentVarGuard() as env:
305 env['HOME'] = '/home/victor'
306 self.assertEqual(posixpath.expanduser("~"), "/home/victor")
307
308 # expanduser() strips trailing slash
309 env['HOME'] = '/home/victor/'
310 self.assertEqual(posixpath.expanduser("~"), "/home/victor")
311
312 for home in '/', '', '//', '///':
313 with self.subTest(home=home):
314 env['HOME'] = home
315 self.assertEqual(posixpath.expanduser("~"), "/")
316 self.assertEqual(posixpath.expanduser("~/"), "/")
317 self.assertEqual(posixpath.expanduser("~/foo"), "/foo")
318
319 @unittest.skipIf(sys.platform == "vxworks",
320 "no home directory on VxWorks")

Callers

nothing calls this directly

Calls 3

expanduserMethod · 0.80
subTestMethod · 0.80
assertEqualMethod · 0.45

Tested by

no test coverage detected