man-group / pytest-plugins

A grab-bag of nifty pytest plugins
MIT License
568 stars 85 forks source link

1.7.0: pytest is failing with setuptools > 60.0.0 because deprecation warning #196

Open kloczek opened 2 years ago

kloczek commented 2 years ago

Issue

pytest is failing on create venv.

Environment

Provide at least:

tests/integration/test_tmpvirtualenv.py F [ 6%] tests/unit/test_package_entry.py ............. [ 87%] tests/unit/test_venv.py .. [100%]

================================================================================= FAILURES ================================================================================= _____ test_installed_packages __

def test_installed_packages():
  with venv.VirtualEnv() as v:

tests/integration/test_tmpvirtualenv.py:14:


../../BUILDROOT/python-pytest-virtualenv-1.7.0-13.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_virtualenv.py:143: in init self.run(cmd) ../../BUILDROOT/python-pytest-virtualenv-1.7.0-13.fc35.x86_64/usr/lib/python3.8/site-packages/pytest_virtualenv.py:151: in run return super(VirtualEnv, self).run(args, **kwargs)


self = <pytest_virtualenv.VirtualEnv object at 0x7f389d6f4220>, cmd = ['/usr/bin/python3', '-m', 'virtualenv', '-p', '/usr/bin/python3.8', '/tmp/tmpzu0c3ejg/.env'] capture = False, check_rc = True, cd = Path('/tmp/tmpzu0c3ejg'), shell = False kwargs = {'env': {'AR': '/usr/bin/gcc-ar', 'BASH_FUNC_which%%': '() { ( alias;\n eval ${whichdeclare} ) | /usr/bin/which --tt...es -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none', ...}} p = <subprocess.Popen object at 0x7f389d6f4100>, out = None, = None err = CalledProcessError(1, ['/usr/bin/python3', '-m', 'virtualenv', '-p', '/usr/bin/python3.8', '/tmp/tmpzu0c3ejg/.env'])

def run(self, cmd, capture=False, check_rc=True, cd=None, shell=False, **kwargs):
    """
    Run a command relative to a given directory, defaulting to the workspace root

    Parameters
    ----------
    cmd : `str` or `list`
        Command string or list. Commands given as a string will be run in a subshell.
    capture : `bool`
        Capture and return output
    check_rc : `bool`
        Assert return code is zero
    cd : `str`
        Path to chdir to, defaults to workspace root
    """
    if isinstance(cmd, string_types):
        shell = True
    else:
        # Some of the command components might be path objects or numbers
        cmd = [str(i) for i in cmd]

    if not cd:
        cd = self.workspace

    with cmdline.chdir(cd):
        log.debug("run: {0}".format(cmd))
        if capture:
            p = subprocess.Popen(cmd, shell=shell, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
        else:
            p = subprocess.Popen(cmd, shell=shell, **kwargs)
        (out, _) = p.communicate()

        if out is not None and not isinstance(out, string_types):
            out = out.decode('utf-8')

        if self.debug and capture:
            log.debug("Stdout/stderr:")
            log.debug(out)

        if check_rc and p.returncode != 0:
            err = subprocess.CalledProcessError(p.returncode, cmd)
            err.output = out
            if capture and not self.debug:
                log.error("Stdout/stderr:")
                log.error(out)
          raise err

E subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'virtualenv', '-p', '/usr/bin/python3.8', '/tmp/tmpzu0c3ejg/.env']' returned non-zero exit status 1.

/usr/lib/python3.8/site-packages/pytest_shutil/workspace.py:132: CalledProcessError --------------------------------------------------------------------------- Captured stdout call --------------------------------------------------------------------------- RuntimeError: failed to build image wheel because: Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 51, in _install key = Path(installer_class.name) / wheel.path.stem AttributeError: 'NoneType' object has no attribute 'path'

--------------------------------------------------------------------------- Captured stderr call --------------------------------------------------------------------------- /usr/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( /usr/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( ========================================================================= short test summary info ========================================================================== FAILED tests/integration/test_tmpvirtualenv.py::test_installed_packages - subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'virtualenv', '-p', '/usr/bi... ======================================================================= 1 failed, 15 passed in 0.83s =======================================================================

and manual test to try run that command:
```console
[tkloczko@ss-desktop pytest-virtualenv-1.7.0]$ /usr/bin/python3 -m virtualenv -p /usr/bin/python3.8 /tmp/tmpzu0c3ejg/.env
/usr/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
RuntimeError: failed to build image wheel because:
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/virtualenv/seed/embed/via_app_data/via_app_data.py", line 51, in _install
    key = Path(installer_class.__name__) / wheel.path.stem
AttributeError: 'NoneType' object has no attribute 'path'

[tkloczko@ss-desktop pytest-virtualenv-1.7.0]$