diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-08 19:34:22 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2020-07-08 19:45:19 -0400 |
| commit | f945849aa91150e0a568a2a047df8b092096feb4 (patch) | |
| tree | 0b5ae84acf72e8b4026de90c254f17257982b93e | |
| parent | 4ea1f8e375a509f48502bd84169a2fbbabae7981 (diff) | |
| download | external_python_setuptools-f945849aa91150e0a568a2a047df8b092096feb4.tar.gz external_python_setuptools-f945849aa91150e0a568a2a047df8b092096feb4.tar.bz2 external_python_setuptools-f945849aa91150e0a568a2a047df8b092096feb4.zip | |
Restore test expectations on non-Debian hosts.
| -rw-r--r-- | distutils/_platform.py | 21 | ||||
| -rw-r--r-- | distutils/tests/test_bdist_dumb.py | 8 | ||||
| -rw-r--r-- | distutils/tests/test_install.py | 7 |
3 files changed, 33 insertions, 3 deletions
diff --git a/distutils/_platform.py b/distutils/_platform.py new file mode 100644 index 00000000..b03659a9 --- /dev/null +++ b/distutils/_platform.py @@ -0,0 +1,21 @@ +import re +import pathlib +import contextlib + + +# from jaraco.context +class suppress(contextlib.suppress, contextlib.ContextDecorator): + """ + A version of contextlib.suppress with decorator support. + + >>> @suppress(KeyError) + ... def key_error(): + ... {}[''] + >>> key_error() + """ + + +@suppress(Exception) +def is_debian(): + issue = pathlib.Path('/etc/issue').read_text() + return bool(re.search('(debian|buntu|mint)', issue, re.IGNORE_CASE)) diff --git a/distutils/tests/test_bdist_dumb.py b/distutils/tests/test_bdist_dumb.py index f99dec53..e58d775d 100644 --- a/distutils/tests/test_bdist_dumb.py +++ b/distutils/tests/test_bdist_dumb.py @@ -9,6 +9,7 @@ from test.support import run_unittest from distutils.core import Distribution from distutils.command.bdist_dumb import bdist_dumb from distutils.tests import support +from distutils._platform import is_debian SETUP_PY = """\ from distutils.core import setup @@ -85,7 +86,12 @@ class BuildDumbTestCase(support.TempdirManager, fp.close() contents = sorted(filter(None, map(os.path.basename, contents))) - wanted = ['foo-0.1.egg-info', 'foo.py'] + egg_info_name = ( + 'foo-0.1.egg-info' if is_debian() else + 'foo-0.1-py%s.%s.egg-info' % sys.version_info[:2] + ) + wanted = [egg_info_name, 'foo.py'] + if not sys.dont_write_bytecode: wanted.append('foo.%s.pyc' % sys.implementation.cache_tag) self.assertEqual(contents, sorted(wanted)) diff --git a/distutils/tests/test_install.py b/distutils/tests/test_install.py index 7553888d..907442bb 100644 --- a/distutils/tests/test_install.py +++ b/distutils/tests/test_install.py @@ -15,6 +15,7 @@ from distutils.command.install import INSTALL_SCHEMES from distutils.core import Distribution from distutils.errors import DistutilsOptionError from distutils.extension import Extension +from distutils._platform import is_debian from distutils.tests import support from test import support as test_support @@ -195,7 +196,8 @@ class InstallTestCase(support.TempdirManager, found = [os.path.basename(line) for line in content.splitlines()] expected = ['hello.py', 'hello.%s.pyc' % sys.implementation.cache_tag, 'sayhi', - 'UNKNOWN-0.0.0.egg-info'] + 'UNKNOWN-0.0.0.egg-info' if is_debian() else + 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected) def test_record_extensions(self): @@ -228,7 +230,8 @@ class InstallTestCase(support.TempdirManager, found = [os.path.basename(line) for line in content.splitlines()] expected = [_make_ext_name('xx'), - 'UNKNOWN-0.0.0.egg-info'] + 'UNKNOWN-0.0.0.egg-info' if is_debian() else + 'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]] self.assertEqual(found, expected) def test_debug_mode(self): |
