| 1 |
Description: Tweak tests, required by pytest >= 5.0 |
| 2 |
Author: jenisys <[email protected]> |
| 3 |
Bug-Debian: https://bugs.debian.org/977057 |
| 4 |
Origin: https://github.com/behave/behave/commit/66fcadb23bea79e60f370e66bf7588de2f1934e3 |
| 5 |
Forwarded: no |
| 6 |
Reviewed-By: João Paulo Lima de Oliveira <[email protected]> |
| 7 |
Last-Update: 2021-02-18 |
| 8 |
|
| 9 |
Index: behave-1.2.6/tests/issues/test_issue0458.py |
| 10 |
=================================================================== |
| 11 |
--- behave-1.2.6.orig/tests/issues/test_issue0458.py |
| 12 |
+++ behave-1.2.6/tests/issues/test_issue0458.py |
| 13 |
@@ -48,7 +48,7 @@ def test_issue(exception_class, message) |
| 14 |
raise_exception(exception_class, message) |
| 15 |
|
| 16 |
# -- SHOULD NOT RAISE EXCEPTION HERE: |
| 17 |
- text = _text(e) |
| 18 |
+ text = _text(e.value) |
| 19 |
# -- DIAGNOSTICS: |
| 20 |
print(u"text"+ text) |
| 21 |
print(u"exception: %s" % e) |
| 22 |
Index: behave-1.2.6/tests/unit/test_context_cleanups.py |
| 23 |
=================================================================== |
| 24 |
--- behave-1.2.6.orig/tests/unit/test_context_cleanups.py |
| 25 |
+++ behave-1.2.6/tests/unit/test_context_cleanups.py |
| 26 |
@@ -153,7 +153,7 @@ class TestContextCleanup(object): |
| 27 |
with pytest.raises(AssertionError) as e: |
| 28 |
with scoped_context_layer(context): |
| 29 |
context.add_cleanup(non_callable) |
| 30 |
- assert "REQUIRES: callable(cleanup_func)" in str(e) |
| 31 |
+ assert "REQUIRES: callable(cleanup_func)" in str(e.value) |
| 32 |
|
| 33 |
def test_on_cleanup_error__prints_error_by_default(self, capsys): |
| 34 |
def bad_cleanup_func(): |
| 35 |
Index: behave-1.2.6/tests/unit/test_textutil.py |
| 36 |
=================================================================== |
| 37 |
--- behave-1.2.6.orig/tests/unit/test_textutil.py |
| 38 |
+++ behave-1.2.6/tests/unit/test_textutil.py |
| 39 |
@@ -212,9 +212,11 @@ class TestObjectToTextConversion(object) |
| 40 |
with pytest.raises(AssertionError) as e: |
| 41 |
assert False, message |
| 42 |
|
| 43 |
- text2 = text(e) |
| 44 |
- expected = u"AssertionError: %s" % message |
| 45 |
- assert text2.endswith(expected) |
| 46 |
+ # -- FOR: pytest < 5.0 |
| 47 |
+ # expected = u"AssertionError: %s" % message |
| 48 |
+ text2 = text(e.value) |
| 49 |
+ assert u"AssertionError" in text(e) |
| 50 |
+ assert message in text2, "OOPS: text=%r" % text2 |
| 51 |
|
| 52 |
@requires_python2 |
| 53 |
@pytest.mark.parametrize("message", [ |
| 54 |
@@ -240,10 +242,13 @@ class TestObjectToTextConversion(object) |
| 55 |
with pytest.raises(exception_class) as e: |
| 56 |
raise exception_class(message) |
| 57 |
|
| 58 |
- text2 = text(e) |
| 59 |
+ # -- FOR: pytest < 5.0 |
| 60 |
+ # expected = u"AssertionError: %s" % message |
| 61 |
+ text2 = text(e.value) |
| 62 |
expected = u"%s: %s" % (exception_class.__name__, message) |
| 63 |
assert isinstance(text2, six.text_type) |
| 64 |
- assert text2.endswith(expected) |
| 65 |
+ assert exception_class.__name__ in str(e) |
| 66 |
+ assert message in text2, "OOPS: text=%r" % text2 |
| 67 |
|
| 68 |
@requires_python2 |
| 69 |
@pytest.mark.parametrize("exception_class, message", [ |
| 70 |
@@ -257,7 +262,7 @@ class TestObjectToTextConversion(object) |
| 71 |
with pytest.raises(exception_class) as e: |
| 72 |
raise exception_class(bytes_message) |
| 73 |
|
| 74 |
- text2 = text(e) |
| 75 |
+ text2 = text(e.value) |
| 76 |
unicode_message = bytes_message.decode(self.ENCODING) |
| 77 |
expected = u"%s: %s" % (exception_class.__name__, unicode_message) |
| 78 |
assert isinstance(text2, six.text_type) |