1
- from contextlib import contextmanager
2
- from setuptools import Command , SetuptoolsDeprecationWarning
1
+ from setuptools import Command
3
2
from setuptools .dist import Distribution
4
3
from setuptools .command .build import build
5
- from distutils .command .build import build as distutils_build
6
-
7
- import pytest
8
4
9
5
10
6
def test_distribution_gives_setuptools_build_obj (tmpdir_cwd ):
@@ -24,15 +20,6 @@ def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
24
20
assert isinstance (dist .get_command_obj ("build" ), build )
25
21
26
22
27
- @contextmanager
28
- def _restore_sub_commands ():
29
- orig = distutils_build .sub_commands [:]
30
- try :
31
- yield
32
- finally :
33
- distutils_build .sub_commands = orig
34
-
35
-
36
23
class Subcommand (Command ):
37
24
"""Dummy command to be used in tests"""
38
25
@@ -44,24 +31,3 @@ def finalize_options(self):
44
31
45
32
def run (self ):
46
33
raise NotImplementedError ("just to check if the command runs" )
47
-
48
-
49
- @_restore_sub_commands ()
50
- def test_subcommand_in_distutils (tmpdir_cwd ):
51
- """
52
- Ensure that sub commands registered in ``distutils`` run,
53
- after instructing the users to migrate to ``setuptools``.
54
- """
55
- dist = Distribution (
56
- dict (
57
- packages = [],
58
- cmdclass = {'subcommand' : Subcommand },
59
- )
60
- )
61
- distutils_build .sub_commands .append (('subcommand' , None ))
62
-
63
- warning_msg = "please use .setuptools.command.build."
64
- with pytest .warns (SetuptoolsDeprecationWarning , match = warning_msg ):
65
- # For backward compatibility, the subcommand should run anyway:
66
- with pytest .raises (NotImplementedError , match = "the command runs" ):
67
- dist .run_command ("build" )
0 commit comments