14
0
forked from pool/python-pyVows

Accepting request 783594 from devel:languages:python

- Update to 3.0.0:
  * No upstream changelog, various fixes for Python 3.
- Drop patches no longer required:
  * pr_133.patch
  * py37-async-keyword.patch

OBS-URL: https://build.opensuse.org/request/show/783594
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-pyVows?expand=0&rev=3
This commit is contained in:
2020-03-11 17:51:57 +00:00
committed by Git OBS Bridge
6 changed files with 15 additions and 452 deletions

View File

@@ -1,399 +0,0 @@
From 9ce9ef9c67122e0a58988eef9efe218b03367345 Mon Sep 17 00:00:00 2001
From: David Halls <dahalls@gmail.com>
Date: Thu, 19 Oct 2017 22:07:21 +0100
Subject: [PATCH 1/4] Fixes for Python 3
---
.gitignore | 3 ++
.travis.yml | 38 ++++---------------------
Makefile | 11 +++----
REQUIREMENTS | 3 --
pyvows/reporting/common.py | 10 ++++---
pyvows/reporting/test.py | 5 +++-
pyvows/runner/abc.py | 2 +-
pyvows/runner/executionplan.py | 9 +++---
pyvows/runner/gevent.py | 30 ++++++++++---------
requirements-travis.txt | 4 ---
setup.py | 4 +--
tests/assertions/like_vows.py | 4 +--
tests/assertions/types/file_vows.py | 4 ++-
tests/bugs/64_vows.py | 5 +++-
tests/context_inheritance_vows.py | 8 ++++--
tests/prune_execution_vows.py | 2 +-
tests/reporting/error_reporting_vows.py | 5 +++-
tests/reporting/xunit_reporter_vows.py | 6 ++--
tests/skipping_vows.py | 10 +++++--
19 files changed, 76 insertions(+), 87 deletions(-)
delete mode 100644 REQUIREMENTS
delete mode 100644 requirements-travis.txt
diff --git a/pyvows/reporting/common.py b/pyvows/reporting/common.py
index 94f4448..c6c1ed7 100644
--- a/pyvows/reporting/common.py
+++ b/pyvows/reporting/common.py
@@ -42,10 +42,10 @@ def ensure_encoded(thing, encoding='utf-8'):
Currently used only for characters `✓` and `✗`.
'''
- if isinstance(thing, unicode):
- return thing.encode(encoding)
- else:
+ if isinstance(thing, bytes) or not isinstance(thing, str):
return thing
+ else:
+ return thing.encode(encoding)
class VowsReporter(object):
@@ -169,8 +169,10 @@ def print_traceback(self, err_type, err_obj, err_traceback, file=sys.stdout):
'''Prints a color-formatted traceback with appropriate indentation.'''
if isinstance(err_obj, AssertionError):
error_msg = err_obj
+ elif isinstance(err_obj, bytes):
+ error_msg = err_obj.decode('utf8')
else:
- error_msg = unicode(err_obj)
+ error_msg = err_obj
print(self.indent_msg(red(error_msg)), file=file)
diff --git a/pyvows/reporting/test.py b/pyvows/reporting/test.py
index 32e2642..6e63172 100644
--- a/pyvows/reporting/test.py
+++ b/pyvows/reporting/test.py
@@ -11,7 +11,10 @@
from __future__ import division, print_function
import sys
-from StringIO import StringIO
+try:
+ from StringIO import StringIO
+except:
+ from io import StringIO
from pyvows.color import yellow, red, blue
from pyvows.reporting.common import (
diff --git a/pyvows/runner/abc.py b/pyvows/runner/abc.py
index 3db72eb..6ded6fa 100644
--- a/pyvows/runner/abc.py
+++ b/pyvows/runner/abc.py
@@ -67,7 +67,7 @@ def run_vow(self, tests_collection, topic, ctx_obj, vow, vow_name, enumerated):
vow_result['succeeded'] = True
if self.on_vow_success:
self.on_vow_success(vow_result)
- except SkipTest, se:
+ except SkipTest as se:
vow_result['skip'] = se
except:
err_type, err_value, err_traceback = sys.exc_info()
diff --git a/pyvows/runner/executionplan.py b/pyvows/runner/executionplan.py
index 3b344a0..65fc82a 100644
--- a/pyvows/runner/executionplan.py
+++ b/pyvows/runner/executionplan.py
@@ -15,7 +15,7 @@ def __init__(self, suites, exclusion_patterns, inclusion_patterns):
def plan(self):
plan = {}
- for suiteName, contextClasses in self.suites.iteritems():
+ for suiteName, contextClasses in self.suites.items():
plan[suiteName] = {
'contexts': {}
}
@@ -63,9 +63,10 @@ def plan_context(self, contextClass, idBase):
]
context['vows'] = [
- name for name, vow in contextMembers if inspect.ismethod(vow)
- and self.is_included(context['id'] + '.' + name)
- and not self.is_excluded(name)
+ name for name, vow in contextMembers
+ if (inspect.ismethod(vow) or inspect.isfunction(vow))
+ and self.is_included(context['id'] + '.' + name)
+ and not self.is_excluded(name)
]
subcontexts = [
diff --git a/pyvows/runner/gevent.py b/pyvows/runner/gevent.py
index 4314225..9fb869e 100644
--- a/pyvows/runner/gevent.py
+++ b/pyvows/runner/gevent.py
@@ -14,7 +14,10 @@
import inspect
import sys
import time
-import StringIO
+try:
+ from StringIO import StringIO
+except:
+ from io import StringIO
try:
from colorama.ansitowin32 import AnsiToWin32
except ImportError:
@@ -36,8 +39,8 @@ def AnsiToWin32(*args, **kwargs):
class _LocalOutput(gevent.local.local):
def __init__(self):
- self.__dict__['stdout'] = StringIO.StringIO()
- self.__dict__['stderr'] = StringIO.StringIO()
+ self.__dict__['stdout'] = StringIO()
+ self.__dict__['stderr'] = StringIO()
class _StreamCapture(object):
@@ -71,9 +74,9 @@ def run(self):
start_time = time.time()
result = VowsResult()
if self.capture_output:
- self._capture_streams(self.capture_output)
+ self._capture_streams(True)
try:
- for suiteName, suitePlan in self.execution_plan.iteritems():
+ for suiteName, suitePlan in self.execution_plan.items():
batches = [batch for batch in self.suites[suiteName] if batch.__name__ in suitePlan['contexts']]
for batch in batches:
self.pool.spawn(
@@ -88,7 +91,8 @@ def run(self):
self.pool.join()
finally:
- self._capture_streams(False)
+ if self.capture_output:
+ self._capture_streams(False)
result.elapsed_time = elapsed(start_time)
return result
@@ -125,11 +129,11 @@ def _run_setup_and_topic(ctx_obj, index):
except Exception:
raise VowsTopicError('setup', sys.exc_info())
- # Find & run topic function
- if not hasattr(ctx_obj, 'topic'): # ctx_obj has no topic
- return ctx_obj._get_first_available_topic(index)
-
try:
+ # Find & run topic function
+ if not hasattr(ctx_obj, 'topic'): # ctx_obj has no topic
+ return ctx_obj._get_first_available_topic(index)
+
topic_func = ctx_obj.topic
topic_list = get_topics_for(topic_func, ctx_obj)
@@ -239,11 +243,11 @@ def _update_execution_plan():
try:
topic = _run_setup_and_topic(ctx_obj, index)
_update_execution_plan()
- except SkipTest, se:
+ except SkipTest as se:
ctx_result['skip'] = se
skipReason = se
topic = None
- except VowsTopicError, e:
+ except VowsTopicError as e:
ctx_result['error'] = e
skipReason = SkipTest('topic dependency failed')
topic = None
@@ -251,7 +255,7 @@ def _update_execution_plan():
if not ctx_result['error']:
try:
_run_teardown()
- except Exception, e:
+ except Exception as e:
ctx_result['error'] = e
finally:
ctx_result['stdout'] = VowsParallelRunner.output.stdout.getvalue()
diff --git a/setup.py b/setup.py
index 1b4945e..dbf2f4e 100755
--- a/setup.py
+++ b/setup.py
@@ -24,8 +24,8 @@
]
_install_requires = [
- 'gevent>=0.13.6',
- 'preggy>=0.11.1',
+ 'gevent>=1.2.2',
+ 'preggy>=1.3.0',
]
if sys.version_info < (2, 7):
_install_requires.append('argparse >= 1.1')
diff --git a/tests/assertions/like_vows.py b/tests/assertions/like_vows.py
index 49b6d89..8fca8e9 100644
--- a/tests/assertions/like_vows.py
+++ b/tests/assertions/like_vows.py
@@ -8,6 +8,7 @@
# http://www.opensource.org/licenses/mit-license
# Copyright (c) 2011 Bernardo Heynemann heynemann@gmail.com
+import sys
from pyvows import Vows, expect
@@ -47,9 +48,6 @@ def we_assert_it_is_like_42(self, topic):
def we_assert_it_is_like_42_float(self, topic):
expect(topic).to_be_like(42.0)
- def we_assert_it_is_like_42_long(self, topic):
- expect(topic).to_be_like(long(42))
-
def we_assert_it_is_not_like_41(self, topic):
expect(topic).Not.to_be_like(41)
diff --git a/tests/assertions/types/file_vows.py b/tests/assertions/types/file_vows.py
index 9249922..ae16022 100644
--- a/tests/assertions/types/file_vows.py
+++ b/tests/assertions/types/file_vows.py
@@ -15,7 +15,9 @@
STRINGS = {
'that_are_files': (
__file__,
- unicode(__file__),
+ (__file__.decode('utf8')
+ if isinstance(__file__, bytes) \
+ else __file__),
),
'that_are_not_files': (
diff --git a/tests/bugs/64_vows.py b/tests/bugs/64_vows.py
index 248a089..451e3b4 100644
--- a/tests/bugs/64_vows.py
+++ b/tests/bugs/64_vows.py
@@ -11,7 +11,10 @@
from pyvows.result import VowsResult
from pyvows.reporting import VowsTestReporter # , VowsDefaultReporter
-from StringIO import StringIO
+try:
+ from StringIO import StringIO
+except:
+ from io import StringIO
@Vows.batch
diff --git a/tests/context_inheritance_vows.py b/tests/context_inheritance_vows.py
index 741688d..dab1c32 100644
--- a/tests/context_inheritance_vows.py
+++ b/tests/context_inheritance_vows.py
@@ -31,7 +31,8 @@ def topic(self, ponies):
# Second case: BaseSubcontext should be ignored.
class BaseSubcontext(Vows.Context):
- def topic(self, (Thingy, ponies)):
+ def topic(self, v):
+ (Thingy, ponies) = v
self.ignore('prepare')
for pony in ponies:
yield (Thingy, self.prepare(pony))
@@ -56,7 +57,8 @@ class ActualContext(BaseContext):
class ActualSubcontext(BaseContext.BaseSubcontext):
def prepare(self, something):
- return unicode(something)
+ return something.decode('utf8') if isinstance(something, bytes) else something
- def pony_is_alicorn(self, (Thingy, pony)):
+ def pony_is_alicorn(self, v):
+ (Thingy, pony) = v
expect(Thingy.alicorns).to_include(pony)
diff --git a/tests/prune_execution_vows.py b/tests/prune_execution_vows.py
index 9a708a4..e323f98 100644
--- a/tests/prune_execution_vows.py
+++ b/tests/prune_execution_vows.py
@@ -141,7 +141,7 @@ def the_excluded_context_is_not_included(self, topic):
}
expect(topic).to_equal(baseline)
- class WithBothInclusionAndExclution(Vows.Context):
+ class WithBothInclusionAndExclusion(Vows.Context):
@Vows.capture_error
def topic(self):
planner = ExecutionPlanner(
diff --git a/tests/reporting/error_reporting_vows.py b/tests/reporting/error_reporting_vows.py
index d290d2e..2846218 100644
--- a/tests/reporting/error_reporting_vows.py
+++ b/tests/reporting/error_reporting_vows.py
@@ -12,7 +12,10 @@
from pyvows.reporting import VowsDefaultReporter
from pyvows.runner.abc import VowsTopicError
-from StringIO import StringIO
+try:
+ from StringIO import StringIO
+except:
+ from io import StringIO
# These tests check that the reporting, which happens after all tests
# have run, correctly shows the errors raised in topic functions.
diff --git a/tests/reporting/xunit_reporter_vows.py b/tests/reporting/xunit_reporter_vows.py
index dec98f3..0433bc1 100644
--- a/tests/reporting/xunit_reporter_vows.py
+++ b/tests/reporting/xunit_reporter_vows.py
@@ -34,11 +34,11 @@ def topic(self):
return reporter
def should_create_xml_header(self, topic):
- expect(topic.to_xml().find('<?xml version="1.0" encoding="utf-8"?>')).to_equal(0)
+ expect(topic.to_xml().find(b'<?xml version="1.0" encoding="utf-8"?>')).to_equal(0)
def should_have_a_testsuite_node(self, topic):
- expect(topic.to_xml()).to_match(r'.*<testsuite errors="0" failures="0" hostname=".+?" ' +
- 'name="pyvows" skip="0" tests="0" time="0\.000" timestamp=".+?"/>')
+ expect(topic.to_xml()).to_match(br'.*<testsuite errors="0" failures="0" hostname=".+?" ' +
+ br'name="pyvows" skip="0" tests="0" time="0\.000" timestamp=".+?"/>')
class WithDocument(Vows.Context):
def topic(self, topic):
diff --git a/tests/skipping_vows.py b/tests/skipping_vows.py
index 03e8dab..c5e1534 100644
--- a/tests/skipping_vows.py
+++ b/tests/skipping_vows.py
@@ -6,7 +6,10 @@
from pyvows.reporting.xunit import XUnitReporter
from pyvows.reporting.common import V_VERBOSE
-from StringIO import StringIO
+try:
+ from StringIO import StringIO
+except:
+ from io import StringIO
@Vows.batch
@@ -331,7 +334,10 @@ def subcontext_shows_skipped_message(self, topic):
def tests_should_not_run_vow_shows_run(self, topic):
expect(topic).Not.to_include('? tests should not run\n')
- expect(topic).to_include('tests should not run\n')
+ try:
+ expect(topic).to_include('tests should not run\n')
+ except:
+ expect(topic).to_include("b'tests should not run'\n")
def subcontext_tests_should_also_not_run_vow_shows_skipped(self, topic):
expect(topic).to_include('? subcontext tests should also not run\n')
diff --git a/pyvows/cli.py b/pyvows/cli.py
index 4850340..45ca215 100755
--- a/pyvows/cli.py
+++ b/pyvows/cli.py
@@ -224,7 +224,7 @@ def main():
if xml:
if arguments.cover_report:
- with open(arguments.cover_report, 'w') as report:
+ with open(arguments.cover_report, 'wb') as report:
report.write(xml)
arguments.cover_threshold /= 100.0
diff --git a/pyvows/reporting/xunit.py b/pyvows/reporting/xunit.py
index f952dc3..969de3f 100644
--- a/pyvows/reporting/xunit.py
+++ b/pyvows/reporting/xunit.py
@@ -26,7 +26,7 @@ class XUnitReporter(object):
def __init__(self, result):
self.result_summary = self.summarize_results(result)
- def write_report(self, filename, encoding='utf-8'):
+ def write_report(self, filename, encoding=None):
# FIXME: Add Docstring
with codecs.open(filename, 'w', encoding, 'replace') as output_file:
output_file.write(self.to_xml(encoding))

View File

@@ -1,42 +0,0 @@
--- pyVows-2.1.0/pyvows/runner/utils.py.orig 2019-02-21 10:04:05.498271976 +0700
+++ pyVows-2.1.0/pyvows/runner/utils.py 2019-02-21 10:04:56.462676610 +0700
@@ -34,10 +34,10 @@
# check for decorated topic function
if hasattr(topic_function, '_original'):
# _wrapper_type is 'async_topic' or 'capture_error'
- async = (getattr(topic_function, '_wrapper_type', None) == 'async_topic')
+ async_ = (getattr(topic_function, '_wrapper_type', None) == 'async_topic')
topic_function = topic_function._original
else:
- async = False
+ async_ = False
code = get_code_for(topic_function)
@@ -48,7 +48,7 @@
expected_args = code.co_argcount - 1
# taking the callback argument into consideration
- if async:
+ if async_:
expected_args -= 1
# prepare to create `topics` list
--- pyVows-2.1.0/tests/async_vows.py.orig 2019-02-21 10:07:12.347754104 +0700
+++ pyVows-2.1.0/tests/async_vows.py 2019-02-21 10:07:25.163855622 +0700
@@ -15,13 +15,13 @@
#-------------------------------------------------------------------------------------------------
def asyncFunc(pool, callback):
- def async():
+ def async_():
time.sleep(0.1)
return 10
def get_value(value):
callback(value, 20, kwarg=30, kw2=40)
- pool.apply_async(async, callback=get_value)
+ pool.apply_async(async_, callback=get_value)
#-------------------------------------------------------------------------------------------------

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:cf5c866e3478defe52270efbaf399cb11b5602d63f0b4502eccce7dfb002b138
size 36661

3
pyVows-3.0.0.tar.gz Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:dbee2e9962cd91b1650a97c5c17d05036374cce661b2dfd8338a3305f5e868c2
size 39112

View File

@@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Mar 11 05:04:44 UTC 2020 - Steve Kowalik <steven.kowalik@suse.com>
- Update to 3.0.0:
* No upstream changelog, various fixes for Python 3.
- Drop patches no longer required:
* pr_133.patch
* py37-async-keyword.patch
-------------------------------------------------------------------
Thu Mar 7 15:52:32 UTC 2019 - John Vandenberg <jayvdb@gmail.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package python-pyVows
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
# 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
@@ -18,19 +18,16 @@
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
Name: python-pyVows
Version: 2.1.0
Version: 3.0.0
Release: 0
Summary: BDD test engine based on Vows.js
License: MIT
Group: Development/Languages/Python
URL: https://github.com/heynemann/pyvows
Source: https://files.pythonhosted.org/packages/source/p/pyVows/pyVows-%{version}.tar.gz
# Extracted from https://patch-diff.githubusercontent.com/raw/heynemann/pyvows/pull/133.patch
Patch0: pr_133.patch
Patch1: py37-async-keyword.patch
BuildRequires: %{python_module Unidecode}
BuildRequires: %{python_module gevent >= 0.13.6}
BuildRequires: %{python_module colorama >= 0.3.7}
BuildRequires: %{python_module gevent >= 0.13.6}
BuildRequires: %{python_module preggy >= 0.5.8}
BuildRequires: %{python_module setuptools}
BuildRequires: fdupes
@@ -47,8 +44,6 @@ pyVows is a BDD test engine based on Vows.js <http://vowsjs.org>.
%prep
%setup -q -n pyVows-%{version}
%patch0 -p1
%patch1 -p1
sed -i '/^#!/d' pyvows/__main__.py pyvows/cli.py
%build