bpo-31904: Fix site and sysconfig modules for VxWorks RTOS (GH-21821)
diff --git a/Lib/test/test_site.py b/Lib/test/test_site.py
index 2e70880..6060288 100644
--- a/Lib/test/test_site.py
+++ b/Lib/test/test_site.py
@@ -36,6 +36,7 @@
import site
+HAS_USER_SITE = (site.USER_SITE is not None)
OLD_SYS_PATH = None
@@ -195,6 +196,7 @@ def test_addsitedir(self):
def test__getuserbase(self):
self.assertEqual(site._getuserbase(), sysconfig._getuserbase())
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_get_path(self):
if sys.platform == 'darwin' and sys._framework:
scheme = 'osx_framework_user'
@@ -244,6 +246,7 @@ def test_s_option(self):
self.assertEqual(rc, 1,
"User base not set by PYTHONUSERBASE")
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_getuserbase(self):
site.USER_BASE = None
user_base = site.getuserbase()
@@ -261,6 +264,7 @@ def test_getuserbase(self):
self.assertTrue(site.getuserbase().startswith('xoxo'),
site.getuserbase())
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_getusersitepackages(self):
site.USER_SITE = None
site.USER_BASE = None
@@ -295,6 +299,7 @@ def test_getsitepackages(self):
wanted = os.path.join('xoxo', 'lib', 'site-packages')
self.assertEqual(dirs[1], wanted)
+ @unittest.skipUnless(HAS_USER_SITE, 'need user site')
def test_no_home_directory(self):
# bpo-10496: getuserbase() and getusersitepackages() must not fail if
# the current user has no home directory (if expanduser() returns the
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
index 352dbde..e279957 100644
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -18,6 +18,10 @@
get_scheme_names, get_config_var, _main)
import _osx_support
+
+HAS_USER_BASE = sysconfig._HAS_USER_BASE
+
+
class TestSysConfig(unittest.TestCase):
def setUp(self):
@@ -230,9 +234,10 @@ def test_get_config_h_filename(self):
self.assertTrue(os.path.isfile(config_h), config_h)
def test_get_scheme_names(self):
- wanted = ('nt', 'nt_user', 'osx_framework_user',
- 'posix_home', 'posix_prefix', 'posix_user')
- self.assertEqual(get_scheme_names(), wanted)
+ wanted = ['nt', 'posix_home', 'posix_prefix']
+ if HAS_USER_BASE:
+ wanted.extend(['nt_user', 'osx_framework_user', 'posix_user'])
+ self.assertEqual(get_scheme_names(), tuple(sorted(wanted)))
@skip_unless_symlink
def test_symlink(self): # Issue 7880
@@ -244,7 +249,8 @@ def test_user_similar(self):
# Issue #8759: make sure the posix scheme for the users
# is similar to the global posix_prefix one
base = get_config_var('base')
- user = get_config_var('userbase')
+ if HAS_USER_BASE:
+ user = get_config_var('userbase')
# the global scheme mirrors the distinction between prefix and
# exec-prefix but not the user scheme, so we have to adapt the paths
# before comparing (issue #9100)
@@ -259,8 +265,9 @@ def test_user_similar(self):
# before comparing
global_path = global_path.replace(sys.base_prefix, sys.prefix)
base = base.replace(sys.base_prefix, sys.prefix)
- user_path = get_path(name, 'posix_user')
- self.assertEqual(user_path, global_path.replace(base, user, 1))
+ if HAS_USER_BASE:
+ user_path = get_path(name, 'posix_user')
+ self.assertEqual(user_path, global_path.replace(base, user, 1))
def test_main(self):
# just making sure _main() runs and returns things in the stdout