Hello community,

here is the log from the commit of package python-pytest-console-scripts for 
openSUSE:Factory checked in at 2020-04-21 13:04:58
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pytest-console-scripts (Old)
 and      /work/SRC/openSUSE:Factory/.python-pytest-console-scripts.new.2738 
(New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-pytest-console-scripts"

Tue Apr 21 13:04:58 2020 rev:5 rq:793540 version:0.2.0

Changes:
--------
--- 
/work/SRC/openSUSE:Factory/python-pytest-console-scripts/python-pytest-console-scripts.changes
      2019-11-15 22:38:43.392217073 +0100
+++ 
/work/SRC/openSUSE:Factory/.python-pytest-console-scripts.new.2738/python-pytest-console-scripts.changes
    2020-04-21 13:04:59.552133208 +0200
@@ -1,0 +2,6 @@
+Mon Apr  6 08:19:12 UTC 2020 - Tomáš Chvátal <[email protected]>
+
+- Add patch to work with python-virtualenv >= 20:
+  * virtualenv-20.patch
+
+-------------------------------------------------------------------

New:
----
  virtualenv-20.patch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-pytest-console-scripts.spec ++++++
--- /var/tmp/diff_new_pack.pGRHTv/_old  2020-04-21 13:05:00.224134548 +0200
+++ /var/tmp/diff_new_pack.pGRHTv/_new  2020-04-21 13:05:00.228134556 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package python-pytest-console-scripts
 #
-# Copyright (c) 2019 SUSE LLC.
+# Copyright (c) 2020 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,14 +17,15 @@
 
 
 %{?!python_module:%define python_module() python-%{**} python3-%{**}}
+%define skip_python2 1
 Name:           python-pytest-console-scripts
 Version:        0.2.0
 Release:        0
 Summary:        Pytest plugin for testing console scripts
 License:        MIT
-Group:          Development/Languages/Python
 URL:            https://github.com/kvas-it/pytest-console-scripts
 Source:         
https://files.pythonhosted.org/packages/source/p/pytest-console-scripts/pytest-console-scripts-%{version}.tar.gz
+Patch0:         virtualenv-20.patch
 BuildRequires:  %{python_module setuptools}
 BuildRequires:  fdupes
 BuildRequires:  python-rpm-macros
@@ -37,7 +38,7 @@
 BuildRequires:  %{python_module pytest >= 4.0.0}
 BuildRequires:  %{python_module pytest-runner}
 BuildRequires:  %{python_module pytest}
-BuildRequires:  %{python_module virtualenv}
+BuildRequires:  %{python_module virtualenv >= 20}
 # /SECTION
 %python_subpackages
 

++++++ virtualenv-20.patch ++++++
>From 3ee9419066c5d789854b55112472444053d4c7b5 Mon Sep 17 00:00:00 2001
From: Vasily Kuznetsov <[email protected]>
Date: Fri, 13 Mar 2020 16:18:24 +0100
Subject: [PATCH] Update the tests and make them compatible with virtualenv
 v.20 (#31)

---
 pytest_console_scripts.py |  5 ++++-
 tests/test_run_scripts.py | 33 +++++++++++++++++++++++++--------
 4 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/pytest_console_scripts.py b/pytest_console_scripts.py
index dbeb5ee..a5c0c1e 100644
--- a/pytest_console_scripts.py
+++ b/pytest_console_scripts.py
@@ -146,7 +146,10 @@ def _restore_logger(self, config):
 
     def run_inprocess(self, command, *arguments, **options):
         cmdargs = [command] + list(arguments)
-        script = py.path.local(distutils.spawn.find_executable(command))
+        script_path = distutils.spawn.find_executable(command)
+        if script_path is None:
+            raise FileNotFoundError('Cannot execute ' + command)
+        script = py.path.local(script_path)
         stdin = options.get('stdin', StreamMock())
         stdout = StreamMock()
         stderr = StreamMock()
diff --git a/tests/test_run_scripts.py b/tests/test_run_scripts.py
index 2a0a9d2..3f76d5d 100644
--- a/tests/test_run_scripts.py
+++ b/tests/test_run_scripts.py
@@ -1,9 +1,8 @@
+import json
 import os
 import subprocess
 import sys
 
-import mock
-import py
 import pytest
 import virtualenv
 
@@ -32,6 +31,7 @@ def __init__(self, path):
         dpp = self._distpackages_path()
         if dpp is not None:
             self.path.mkdir(dpp)
+        self.sys_path = self._get_sys_path()
 
     def _distpackages_path(self):
         """Return (relative) path used for installing distribution packages.
@@ -51,18 +51,33 @@ def _distpackages_path(self):
                     parts = parts[parts.index('lib'):]
                     return os.path.join(*parts)
 
-    def _update_env(self, env):
+    def _get_sys_path(self):
+        """Return sys.path of this virtualenv."""
+        result = self.run([
+            'python', '-c',
+            'import json,sys; print(json.dumps(sys.path))',
+        ], skip_pythonpath=True)
+        assert result.returncode == 0
+        return json.loads(str(result.stdout.read(), encoding='utf-8'))
+
+    def _update_env(self, env, skip_pythonpath=False):
         bin_dir = self.path.join('bin').strpath
         env['PATH'] = bin_dir + ':' + env.get('PATH', '')
+        if 'PYTHONHOME' in env:
+            del env['PYTHONHOME']
         env['VIRTUAL_ENV'] = self.path.strpath
+        if skip_pythonpath:
+            return
         # Make installed packages of the Python installation that runs this
         # test accessible. This allows us to run tests in the virtualenv
         # without installing all the dependencies there.
-        env['PYTHONPATH'] = ':'.join(sys.path)
+        python_path = set(sys.path + self.sys_path)
+        env['PYTHONPATH'] = ':'.join(python_path)
 
-    def run(self, cmd, *args, **kw):
+    def run(self, cmd, skip_pythonpath=False, *args, **kw):
         """Run a command in the virtualenv, return terminated process."""
-        self._update_env(kw.setdefault('env', dict(os.environ)))
+        self._update_env(kw.setdefault('env', dict(os.environ)),
+                         skip_pythonpath=skip_pythonpath)
         kw.setdefault('stdout', subprocess.PIPE)
         kw.setdefault('stderr', subprocess.PIPE)
         proc = subprocess.Popen(cmd, *args, **kw)
@@ -75,14 +90,16 @@ def install_console_script(self, cmd, script_path):
         script_name = script_path.purebasename
         setup_py = script_dir.join('setup.py')
         setup_py.write(SETUP_TEMPLATE.format(cmd=cmd, script_name=script_name))
-        self.run(['python', 'setup.py', 'develop'], cwd=str(script_dir))
+        result = self.run(['python', 'setup.py', 'develop'],
+                          cwd=str(script_dir), skip_pythonpath=True)
+        assert result.returncode == 0
 
 
 @pytest.fixture(scope='session')
 def pcs_venv(tmpdir_factory):
     """Virtualenv for testing console scripts."""
     venv = tmpdir_factory.mktemp('venv')
-    virtualenv.create_environment(venv.strpath)
+    virtualenv.cli_run([venv.strpath])
     yield VEnvWrapper(venv)
 

Reply via email to