fix test error
This commit is contained in:
parent
16208d8606
commit
474839395a
82
change-required-pytest.patch
Normal file
82
change-required-pytest.patch
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
From 66fcadb23bea79e60f370e66bf7588de2f1934e3 Mon Sep 17 00:00:00 2001
|
||||||
|
From: jenisys <jenisys@users.noreply.github.com>
|
||||||
|
Date: Fri, 5 Jul 2019 08:27:44 +0200
|
||||||
|
Subject: [PATCH] Tweak tests, required by pytest >= 5.0. With pytest.raises
|
||||||
|
use str(e.value) instead of str(e) in some cases.
|
||||||
|
|
||||||
|
---
|
||||||
|
tests/issues/test_issue0458.py | 2 +-
|
||||||
|
tests/unit/test_context_cleanups.py | 2 +-
|
||||||
|
tests/unit/test_textutil.py | 24 +++++++++++++++---------
|
||||||
|
3 files changed, 17 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/tests/issues/test_issue0458.py b/tests/issues/test_issue0458.py
|
||||||
|
index 1853ad6a..f66f6d36 100644
|
||||||
|
--- a/tests/issues/test_issue0458.py
|
||||||
|
+++ b/tests/issues/test_issue0458.py
|
||||||
|
@@ -48,7 +48,7 @@ def test_issue(exception_class, message):
|
||||||
|
raise_exception(exception_class, message)
|
||||||
|
|
||||||
|
# -- SHOULD NOT RAISE EXCEPTION HERE:
|
||||||
|
- text = _text(e)
|
||||||
|
+ text = _text(e.value)
|
||||||
|
# -- DIAGNOSTICS:
|
||||||
|
print(u"text"+ text)
|
||||||
|
print(u"exception: %s" % e)
|
||||||
|
diff --git a/tests/unit/test_context_cleanups.py b/tests/unit/test_context_cleanups.py
|
||||||
|
index b0e8ae60..bf0ab50f 100644
|
||||||
|
--- a/tests/unit/test_context_cleanups.py
|
||||||
|
+++ b/tests/unit/test_context_cleanups.py
|
||||||
|
@@ -153,7 +153,7 @@ class NonCallable(object): pass
|
||||||
|
with pytest.raises(AssertionError) as e:
|
||||||
|
with scoped_context_layer(context):
|
||||||
|
context.add_cleanup(non_callable)
|
||||||
|
- assert "REQUIRES: callable(cleanup_func)" in str(e)
|
||||||
|
+ assert "REQUIRES: callable(cleanup_func)" in str(e.value)
|
||||||
|
|
||||||
|
def test_on_cleanup_error__prints_error_by_default(self, capsys):
|
||||||
|
def bad_cleanup_func():
|
||||||
|
diff --git a/tests/unit/test_textutil.py b/tests/unit/test_textutil.py
|
||||||
|
index f7f642c0..e05e9ad0 100644
|
||||||
|
--- a/tests/unit/test_textutil.py
|
||||||
|
+++ b/tests/unit/test_textutil.py
|
||||||
|
@@ -214,9 +214,11 @@ def test_text__with_assert_failed_and_unicode_message(self, message):
|
||||||
|
with pytest.raises(AssertionError) as e:
|
||||||
|
assert False, message
|
||||||
|
|
||||||
|
- text2 = text(e)
|
||||||
|
- expected = u"AssertionError: %s" % message
|
||||||
|
- assert text2.endswith(expected)
|
||||||
|
+ # -- FOR: pytest < 5.0
|
||||||
|
+ # expected = u"AssertionError: %s" % message
|
||||||
|
+ text2 = text(e.value)
|
||||||
|
+ assert u"AssertionError" in text(e)
|
||||||
|
+ assert message in text2, "OOPS: text=%r" % text2
|
||||||
|
|
||||||
|
@requires_python2
|
||||||
|
@pytest.mark.parametrize("message", [
|
||||||
|
@@ -251,10 +254,13 @@ def test_text__with_raised_exception_and_unicode_message(self,
|
||||||
|
with pytest.raises(exception_class) as e:
|
||||||
|
raise exception_class(message)
|
||||||
|
|
||||||
|
- text2 = text(e)
|
||||||
|
+ # -- FOR: pytest < 5.0
|
||||||
|
+ # expected = u"AssertionError: %s" % message
|
||||||
|
+ text2 = text(e.value)
|
||||||
|
expected = u"%s: %s" % (exception_class.__name__, message)
|
||||||
|
assert isinstance(text2, six.text_type)
|
||||||
|
- assert text2.endswith(expected)
|
||||||
|
+ assert exception_class.__name__ in str(e)
|
||||||
|
+ assert message in text2, "OOPS: text=%r" % text2
|
||||||
|
|
||||||
|
@requires_python2
|
||||||
|
@pytest.mark.parametrize("exception_class, message", [
|
||||||
|
@@ -268,7 +274,7 @@ def test_text__with_raised_exception_and_bytes_message(self, exception_class,
|
||||||
|
with pytest.raises(exception_class) as e:
|
||||||
|
raise exception_class(bytes_message)
|
||||||
|
|
||||||
|
- text2 = text(e)
|
||||||
|
+ text2 = text(e.value)
|
||||||
|
unicode_message = bytes_message.decode(self.ENCODING)
|
||||||
|
expected = u"%s: %s" % (exception_class.__name__, unicode_message)
|
||||||
|
assert isinstance(text2, six.text_type)
|
||||||
@ -1,13 +1,14 @@
|
|||||||
%?python_enable_dependency_generator
|
%?python_enable_dependency_generator
|
||||||
Name: python-behave
|
Name: python-behave
|
||||||
Version: 1.2.6
|
Version: 1.2.6
|
||||||
Release: 3
|
Release: 4
|
||||||
Summary: A tool for behavior-driven development, Python style
|
Summary: A tool for behavior-driven development, Python style
|
||||||
License: BSD
|
License: BSD
|
||||||
URL: http://pypi.python.org/pypi/behave
|
URL: http://pypi.python.org/pypi/behave
|
||||||
Source0: https://github.com/behave/behave/archive/v%{version}/behave-%{version}.tar.gz
|
Source0: https://github.com/behave/behave/archive/v%{version}/behave-%{version}.tar.gz
|
||||||
# Upstream issue: https://github.com/behave/behave/issues/755
|
# Upstream issue: https://github.com/behave/behave/issues/755
|
||||||
Patch0000: 0001-Backport-for-py38-fixes.patch
|
Patch0000: 0001-Backport-for-py38-fixes.patch
|
||||||
|
Patch0001: change-required-pytest.patch
|
||||||
BuildArch: noarch
|
BuildArch: noarch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
@ -75,6 +76,9 @@ install -Dpm0644 behave.1 %{buildroot}%{_mandir}/man1/
|
|||||||
%doc %{_mandir}/man1/behave.1*
|
%doc %{_mandir}/man1/behave.1*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Jan 8 2021 wutao<wutao61@huawei.com> - 1.2.6-4
|
||||||
|
- fix test failure because of pytest upgrade
|
||||||
|
|
||||||
* Fri Sep 11 2020 wangxiao<wangxiao65@huawei.com> - 1.2.6-3
|
* Fri Sep 11 2020 wangxiao<wangxiao65@huawei.com> - 1.2.6-3
|
||||||
- fix test error
|
- fix test error
|
||||||
* Thu Dec 05 2019 gulining<gulining1@huawei.com> - 1.2.6-2
|
* Thu Dec 05 2019 gulining<gulining1@huawei.com> - 1.2.6-2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user