Accepting request 937342 from devel:languages:python:pytest
OBS-URL: https://build.opensuse.org/request/show/937342 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pytest-console-scripts?expand=0&rev=7
This commit is contained in:
commit
ebaed9a0cc
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:a88ac15d663b88ef8fd5d4929a1b50e782dd25eb84443de849ad78636ad3e699
|
|
||||||
size 12298
|
|
3
pytest-console-scripts-1.2.1.tar.gz
Normal file
3
pytest-console-scripts-1.2.1.tar.gz
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:c7f258025110f1337c23499c2f6674b873d4adba2438be55895edf01451c5ce3
|
||||||
|
size 13617
|
@ -1,3 +1,16 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Dec 8 08:33:48 UTC 2021 - pgajdos@suse.com
|
||||||
|
|
||||||
|
- version update to 1.2.1
|
||||||
|
* no upstream changelog
|
||||||
|
- deleted patches
|
||||||
|
- virtualenv-20.patch (upstreamed)
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Dec 8 07:33:48 UTC 2021 - pgajdos@suse.com
|
||||||
|
|
||||||
|
- do not require pytest-runner for build, it is not needed
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri May 15 08:53:13 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
|
Fri May 15 08:53:13 UTC 2020 - Tomáš Chvátal <tchvatal@suse.com>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package python-pytest-console-scripts
|
# spec file for package python-pytest-console-scripts
|
||||||
#
|
#
|
||||||
# Copyright (c) 2020 SUSE LLC
|
# Copyright (c) 2021 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -19,24 +19,23 @@
|
|||||||
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
|
||||||
%define skip_python2 1
|
%define skip_python2 1
|
||||||
Name: python-pytest-console-scripts
|
Name: python-pytest-console-scripts
|
||||||
Version: 0.2.0
|
Version: 1.2.1
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: Pytest plugin for testing console scripts
|
Summary: Pytest plugin for testing console scripts
|
||||||
License: MIT
|
License: MIT
|
||||||
URL: https://github.com/kvas-it/pytest-console-scripts
|
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
|
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: %{python_module setuptools}
|
||||||
BuildRequires: fdupes
|
BuildRequires: fdupes
|
||||||
BuildRequires: python-rpm-macros
|
BuildRequires: python-rpm-macros
|
||||||
Requires: python-mock >= 2.0.0
|
Requires: python-mock >= 2.0.0
|
||||||
Requires: python-pytest >= 4.0.0
|
Requires: python-pytest >= 4.0.0
|
||||||
Requires: python-pytest-runner
|
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
# SECTION test requirements
|
# SECTION test requirements
|
||||||
BuildRequires: %{python_module mock >= 2.0.0}
|
BuildRequires: %{python_module mock >= 2.0.0}
|
||||||
BuildRequires: %{python_module pytest >= 4.0.0}
|
BuildRequires: %{python_module pytest >= 4.0.0}
|
||||||
BuildRequires: %{python_module pytest-runner}
|
BuildRequires: %{python_module pytest-runner}
|
||||||
|
BuildRequires: %{python_module setuptools_scm}
|
||||||
BuildRequires: %{python_module virtualenv >= 20}
|
BuildRequires: %{python_module virtualenv >= 20}
|
||||||
# /SECTION
|
# /SECTION
|
||||||
%python_subpackages
|
%python_subpackages
|
||||||
@ -61,11 +60,12 @@ much as possible.
|
|||||||
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
%python_expand %fdupes %{buildroot}%{$python_sitelib}
|
||||||
|
|
||||||
%check
|
%check
|
||||||
|
sed -i 's:env python:env python3:' tests/test_run_scripts.py
|
||||||
%pytest
|
%pytest
|
||||||
|
|
||||||
%files %{python_files}
|
%files %{python_files}
|
||||||
%license LICENSE
|
%license LICENSE
|
||||||
%doc README.rst
|
%doc README.md
|
||||||
%{python_sitelib}/*
|
%{python_sitelib}/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
@ -1,106 +0,0 @@
|
|||||||
From 3ee9419066c5d789854b55112472444053d4c7b5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Vasily Kuznetsov <kvas.it@gmail.com>
|
|
||||||
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)
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user