Skip to content

Commit cdd4c28

Browse files
committed
Direct tests to the new names
1 parent f5e5969 commit cdd4c28

File tree

5 files changed

+37
-50
lines changed

5 files changed

+37
-50
lines changed

distutils/compilers/C/tests/test_base.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import sys
44
import sysconfig
55
import textwrap
6-
from distutils import ccompiler
76

87
import pytest
98

9+
from .. import base
10+
1011
pytestmark = pytest.mark.usefixtures('suppress_path_mangle')
1112

1213

@@ -46,7 +47,7 @@ def test_set_include_dirs(c_file):
4647
Extensions should build even if set_include_dirs is invoked.
4748
In particular, compiler-specific paths should not be overridden.
4849
"""
49-
compiler = ccompiler.new_compiler()
50+
compiler = base.new_compiler()
5051
python = sysconfig.get_paths()['include']
5152
compiler.set_include_dirs([python])
5253
compiler.compile(_make_strs([c_file]))
@@ -60,7 +61,7 @@ def test_has_function_prototype():
6061
# Issue https://github.com/pypa/setuptools/issues/3648
6162
# Test prototype-generating behavior.
6263

63-
compiler = ccompiler.new_compiler()
64+
compiler = base.new_compiler()
6465

6566
# Every C implementation should have these.
6667
assert compiler.has_function('abort')
@@ -84,7 +85,7 @@ def test_include_dirs_after_multiple_compile_calls(c_file):
8485
Calling compile multiple times should not change the include dirs
8586
(regression test for setuptools issue #3591).
8687
"""
87-
compiler = ccompiler.new_compiler()
88+
compiler = base.new_compiler()
8889
python = sysconfig.get_paths()['include']
8990
compiler.set_include_dirs([python])
9091
compiler.compile(_make_strs([c_file]))

distutils/compilers/C/tests/test_cygwin.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,12 @@
33
import os
44
import sys
55
from distutils import sysconfig
6-
from distutils.cygwinccompiler import (
7-
CONFIG_H_NOTOK,
8-
CONFIG_H_OK,
9-
CONFIG_H_UNCERTAIN,
10-
check_config_h,
11-
get_msvcr,
12-
)
136
from distutils.tests import support
147

158
import pytest
169

10+
from .. import cygwin
11+
1712

1813
@pytest.fixture(autouse=True)
1914
def stuff(request, monkeypatch, distutils_managed_tempdir):
@@ -54,24 +49,24 @@ def test_check_config_h(self):
5449
'4.0.1 (Apple Computer, Inc. build 5370)]'
5550
)
5651

57-
assert check_config_h()[0] == CONFIG_H_OK
52+
assert cygwin.check_config_h()[0] == cygwin.CONFIG_H_OK
5853

5954
# then it tries to see if it can find "__GNUC__" in pyconfig.h
6055
sys.version = 'something without the *CC word'
6156

6257
# if the file doesn't exist it returns CONFIG_H_UNCERTAIN
63-
assert check_config_h()[0] == CONFIG_H_UNCERTAIN
58+
assert cygwin.check_config_h()[0] == cygwin.CONFIG_H_UNCERTAIN
6459

6560
# if it exists but does not contain __GNUC__, it returns CONFIG_H_NOTOK
6661
self.write_file(self.python_h, 'xxx')
67-
assert check_config_h()[0] == CONFIG_H_NOTOK
62+
assert cygwin.check_config_h()[0] == cygwin.CONFIG_H_NOTOK
6863

6964
# and CONFIG_H_OK if __GNUC__ is found
7065
self.write_file(self.python_h, 'xxx __GNUC__ xxx')
71-
assert check_config_h()[0] == CONFIG_H_OK
66+
assert cygwin.check_config_h()[0] == cygwin.CONFIG_H_OK
7267

7368
def test_get_msvcr(self):
74-
assert get_msvcr() == []
69+
assert cygwin.get_msvcr() == []
7570

7671
@pytest.mark.skipif('sys.platform != "cygwin"')
7772
def test_dll_libraries_not_none(self):
Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
from distutils import sysconfig
2-
from distutils.errors import CCompilerError, DistutilsPlatformError
2+
from distutils.errors import DistutilsPlatformError
33
from distutils.util import is_mingw, split_quoted
44

55
import pytest
66

7+
from .. import cygwin, errors
78

8-
class TestMingw32CCompiler:
9+
10+
class TestMinGW32Compiler:
911
@pytest.mark.skipif(not is_mingw(), reason='not on mingw')
1012
def test_compiler_type(self):
11-
from distutils.cygwinccompiler import Mingw32CCompiler
12-
13-
compiler = Mingw32CCompiler()
13+
compiler = cygwin.MinGW32Compiler()
1414
assert compiler.compiler_type == 'mingw32'
1515

1616
@pytest.mark.skipif(not is_mingw(), reason='not on mingw')
1717
def test_set_executables(self, monkeypatch):
18-
from distutils.cygwinccompiler import Mingw32CCompiler
19-
2018
monkeypatch.setenv('CC', 'cc')
2119
monkeypatch.setenv('CXX', 'c++')
2220

23-
compiler = Mingw32CCompiler()
21+
compiler = cygwin.MinGW32Compiler()
2422

2523
assert compiler.compiler == split_quoted('cc -O -Wall')
2624
assert compiler.compiler_so == split_quoted('cc -shared -O -Wall')
@@ -30,27 +28,21 @@ def test_set_executables(self, monkeypatch):
3028

3129
@pytest.mark.skipif(not is_mingw(), reason='not on mingw')
3230
def test_runtime_library_dir_option(self):
33-
from distutils.cygwinccompiler import Mingw32CCompiler
34-
35-
compiler = Mingw32CCompiler()
31+
compiler = cygwin.MinGW32Compiler()
3632
with pytest.raises(DistutilsPlatformError):
3733
compiler.runtime_library_dir_option('/usr/lib')
3834

3935
@pytest.mark.skipif(not is_mingw(), reason='not on mingw')
4036
def test_cygwincc_error(self, monkeypatch):
41-
import distutils.cygwinccompiler
42-
43-
monkeypatch.setattr(distutils.cygwinccompiler, 'is_cygwincc', lambda _: True)
37+
monkeypatch.setattr(cygwin, 'is_cygwincc', lambda _: True)
4438

45-
with pytest.raises(CCompilerError):
46-
distutils.cygwinccompiler.Mingw32CCompiler()
39+
with pytest.raises(errors.Error):
40+
cygwin.MinGW32Compiler()
4741

4842
@pytest.mark.skipif('sys.platform == "cygwin"')
4943
def test_customize_compiler_with_msvc_python(self):
50-
from distutils.cygwinccompiler import Mingw32CCompiler
51-
5244
# In case we have an MSVC Python build, but still want to use
53-
# Mingw32CCompiler, then customize_compiler() shouldn't fail at least.
45+
# MinGW32Compiler, then customize_compiler() shouldn't fail at least.
5446
# https://github.com/pypa/setuptools/issues/4456
55-
compiler = Mingw32CCompiler()
47+
compiler = cygwin.MinGW32Compiler()
5648
sysconfig.customize_compiler(compiler)

distutils/compilers/C/tests/test_msvc.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
1-
"""Tests for distutils._msvccompiler."""
2-
31
import os
42
import sys
53
import sysconfig
64
import threading
75
import unittest.mock as mock
8-
from distutils import _msvccompiler
9-
from distutils.compilers.C import msvc
106
from distutils.errors import DistutilsPlatformError
117
from distutils.tests import support
128
from distutils.util import get_platform
139

1410
import pytest
1511

16-
needs_winreg = pytest.mark.skipif('not hasattr(_msvccompiler, "winreg")')
12+
from .. import msvc
13+
14+
needs_winreg = pytest.mark.skipif('not hasattr(msvc, "winreg")')
1715

1816

1917
class Testmsvccompiler(support.TempdirManager):
@@ -47,12 +45,12 @@ def test_cross_platform_compilation_paths(self, monkeypatch, plat_name, expected
4745
"""
4846
Ensure a specified target platform is passed to _get_vcvars_spec.
4947
"""
50-
compiler = _msvccompiler.MSVCCompiler()
48+
compiler = msvc.Compiler()
5149

5250
def _get_vcvars_spec(host_platform, platform):
5351
assert platform == expected
5452

55-
monkeypatch.setattr(_msvccompiler, '_get_vcvars_spec', _get_vcvars_spec)
53+
monkeypatch.setattr(msvc, '_get_vcvars_spec', _get_vcvars_spec)
5654
compiler.initialize(plat_name)
5755

5856
@needs_winreg
@@ -64,7 +62,7 @@ def test_get_vc_env_unicode(self):
6462
old_distutils_use_sdk = os.environ.pop('DISTUTILS_USE_SDK', None)
6563
os.environ[test_var] = test_value
6664
try:
67-
env = _msvccompiler._get_vc_env('x86')
65+
env = msvc._get_vc_env('x86')
6866
assert test_var.lower() in env
6967
assert test_value == env[test_var.lower()]
7068
finally:
@@ -77,7 +75,7 @@ def test_get_vc_env_unicode(self):
7775
def test_get_vc(self, ver):
7876
# This function cannot be mocked, so pass if VC is found
7977
# and skip otherwise.
80-
lookup = getattr(_msvccompiler, f'_find_vc{ver}')
78+
lookup = getattr(msvc, f'_find_vc{ver}')
8179
expected_version = {2015: 14, 2017: 15}[ver]
8280
version, path = lookup()
8381
if not version:
@@ -104,7 +102,7 @@ def test_concurrent_safe(self):
104102
"""
105103
Concurrent calls to spawn should have consistent results.
106104
"""
107-
compiler = _msvccompiler.MSVCCompiler()
105+
compiler = msvc.Compiler()
108106
compiler._paths = "expected"
109107
inner_cmd = 'import os; assert os.environ["PATH"] == "expected"'
110108
command = [sys.executable, '-c', inner_cmd]
@@ -125,7 +123,7 @@ def test_concurrent_safe_fallback(self):
125123
"""
126124
from distutils import ccompiler
127125

128-
compiler = _msvccompiler.MSVCCompiler()
126+
compiler = msvc.Compiler()
129127
compiler._paths = "expected"
130128

131129
def CCompiler_spawn(self, cmd):

distutils/compilers/C/tests/test_unix.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88
from distutils.errors import DistutilsPlatformError
99
from distutils.tests import support
1010
from distutils.tests.compat.py39 import EnvironmentVarGuard
11-
from distutils.unixccompiler import UnixCCompiler
1211
from distutils.util import _clear_cached_macosx_ver
1312

1413
import pytest
1514

15+
from .. import unix
16+
1617

1718
@pytest.fixture(autouse=True)
1819
def save_values(monkeypatch):
@@ -23,7 +24,7 @@ def save_values(monkeypatch):
2324

2425
@pytest.fixture(autouse=True)
2526
def compiler_wrapper(request):
26-
class CompilerWrapper(UnixCCompiler):
27+
class CompilerWrapper(unix.Compiler):
2728
def rpath_foo(self):
2829
return self.runtime_library_dir_option('/foo')
2930

@@ -319,7 +320,7 @@ def test_has_function(self):
319320
self.cc.has_function('abort')
320321

321322
def test_find_library_file(self, monkeypatch):
322-
compiler = UnixCCompiler()
323+
compiler = unix.Compiler()
323324
compiler._library_root = lambda dir: dir
324325
monkeypatch.setattr(os.path, 'exists', lambda d: 'existing' in d)
325326

0 commit comments

Comments
 (0)