from setuptools.dist import Distribution
from setuptools.command.build import build


def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
    """
    Check that the setuptools Distribution uses the
    setuptools specific build object.
    """
    dist = Distribution(dict(
        script_name='setup.py',
        script_args=['build'],
        packages=[''],
        package_data={'': ['path/*']},
    ))
    assert isinstance(dist.get_command_obj("build"), build)

from setuptools.dist import Distribution
from setuptools.command.build import build
from distutils.command.build import build as distutils_build


def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
    """
    Check that the setuptools Distribution uses the
    setuptools specific build object.
    """
    dist = Distribution(dict(
        script_name='setup.py',
        script_args=['build'],
        packages=[''],
        package_data={'': ['path/*']},
    ))

    build_obj = dist.get_command_obj("build")
    assert isinstance(build_obj, build)

    build_obj.sub_commands.append(("custom_build_subcommand", None))

    distutils_subcommands = [cmd[0] for cmd in distutils_build.sub_commands]
    assert "custom_build_subcommand" not in distutils_subcommands

Test that extending setuptools' build sub_commands does not extend distutils
Test that extending setuptools' build sub_commands does not extend distutils

  from setuptools.dist import Distribution
  from setuptools.command.build import build
+ from distutils.command.build import build as distutils_build
  
  
  def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
      """
      Check that the setuptools Distribution uses the
      setuptools specific build object.
      """
      dist = Distribution(dict(
          script_name='setup.py',
          script_args=['build'],
          packages=[''],
          package_data={'': ['path/*']},
      ))
-     assert isinstance(dist.get_command_obj("build"), build)
  
+     build_obj = dist.get_command_obj("build")
+     assert isinstance(build_obj, build)
+ 
+     build_obj.sub_commands.append(("custom_build_subcommand", None))
+ 
+     distutils_subcommands = [cmd[0] for cmd in distutils_build.sub_commands]
+     assert "custom_build_subcommand" not in distutils_subcommands
+ 
Test that extending setuptools' build sub_commands does not extend distutils
## Code Before:
from setuptools.dist import Distribution
from setuptools.command.build import build


def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
    """
    Check that the setuptools Distribution uses the
    setuptools specific build object.
    """
    dist = Distribution(dict(
        script_name='setup.py',
        script_args=['build'],
        packages=[''],
        package_data={'': ['path/*']},
    ))
    assert isinstance(dist.get_command_obj("build"), build)

## Instruction:
Test that extending setuptools' build sub_commands does not extend distutils
## Code After:
from setuptools.dist import Distribution
from setuptools.command.build import build
from distutils.command.build import build as distutils_build


def test_distribution_gives_setuptools_build_obj(tmpdir_cwd):
    """
    Check that the setuptools Distribution uses the
    setuptools specific build object.
    """
    dist = Distribution(dict(
        script_name='setup.py',
        script_args=['build'],
        packages=[''],
        package_data={'': ['path/*']},
    ))

    build_obj = dist.get_command_obj("build")
    assert isinstance(build_obj, build)

    build_obj.sub_commands.append(("custom_build_subcommand", None))

    distutils_subcommands = [cmd[0] for cmd in distutils_build.sub_commands]
    assert "custom_build_subcommand" not in distutils_subcommands
