(self)
| 349 | |
| 350 | @unittest.skipUnless(HAS_USER_SITE, 'need user site') |
| 351 | def test_no_home_directory(self): |
| 352 | # bpo-10496: getuserbase() and getusersitepackages() must not fail if |
| 353 | # the current user has no home directory (if expanduser() returns the |
| 354 | # path unchanged). |
| 355 | site.USER_SITE = None |
| 356 | site.USER_BASE = None |
| 357 | |
| 358 | with EnvironmentVarGuard() as environ, \ |
| 359 | mock.patch('os.path.expanduser', lambda path: path): |
| 360 | environ.unset('PYTHONUSERBASE', 'APPDATA') |
| 361 | |
| 362 | user_base = site.getuserbase() |
| 363 | self.assertStartsWith(user_base, '~' + os.sep) |
| 364 | |
| 365 | user_site = site.getusersitepackages() |
| 366 | self.assertStartsWith(user_site, user_base) |
| 367 | |
| 368 | with mock.patch('os.path.isdir', return_value=False) as mock_isdir, \ |
| 369 | mock.patch.object(site, 'addsitedir') as mock_addsitedir, \ |
| 370 | support.swap_attr(site, 'ENABLE_USER_SITE', True): |
| 371 | |
| 372 | # addusersitepackages() must not add user_site to sys.path |
| 373 | # if it is not an existing directory |
| 374 | known_paths = set() |
| 375 | site.addusersitepackages(known_paths) |
| 376 | |
| 377 | mock_isdir.assert_called_once_with(user_site) |
| 378 | mock_addsitedir.assert_not_called() |
| 379 | self.assertFalse(known_paths) |
| 380 | |
| 381 | def test_gethistoryfile(self): |
| 382 | filename = 'file' |
nothing calls this directly
no test coverage detected