diff --git a/python-datadiff.changes b/python-datadiff.changes index 87df0fc..11b11c1 100644 --- a/python-datadiff.changes +++ b/python-datadiff.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Sep 16 05:42:47 UTC 2021 - Steve Kowalik + +- Add patch switch-to-pytest.patch: + * Stop using nose imports, use pytest instead. + ------------------------------------------------------------------- Mon Oct 21 12:34:48 UTC 2019 - Martin Hauke diff --git a/python-datadiff.spec b/python-datadiff.spec index 2c5f255..dfea85c 100644 --- a/python-datadiff.spec +++ b/python-datadiff.spec @@ -1,6 +1,7 @@ # # spec file for package python-datadiff # +# Copyright (c) 2021 SUSE LLC # Copyright (c) 2019, Martin Hauke # # All modifications and additions to the file contributed by third parties @@ -22,18 +23,17 @@ Version: 2.2.0 Release: 0 Summary: DataDiff is a library to provide human-readable diffs of python data structures License: Apache-2.0 -Group: Development/Languages/Python URL: https://sourceforge.net/projects/datadiff/ #Source: https://files.pythonhosted.org/packages/source/d/datadiff/datadiff-%%{version}.tar.gz #Git-Clone: https://git.code.sf.net/p/datadiff/code Source: datadiff-%{version}.tar.xz Source1: https://www.apache.org/licenses/LICENSE-2.0.txt +Patch0: switch-to-pytest.patch BuildRequires: %{python_module setuptools} BuildRequires: fdupes BuildRequires: python-rpm-macros BuildArch: noarch # SECTION test requirements -BuildRequires: %{python_module nose} BuildRequires: %{python_module pytest} BuildRequires: %{python_module six} # /SECTION @@ -49,6 +49,7 @@ a nice data diff is shown, letting you easily pinpoint the root difference. %prep %setup -q -n datadiff-%{version} +%autopatch -p1 cp %{SOURCE1} . %build diff --git a/switch-to-pytest.patch b/switch-to-pytest.patch new file mode 100644 index 0000000..4b7655d --- /dev/null +++ b/switch-to-pytest.patch @@ -0,0 +1,355 @@ +Index: datadiff-2.2.0/test_datadiff.py +=================================================================== +--- datadiff-2.2.0.orig/test_datadiff.py ++++ datadiff-2.2.0/test_datadiff.py +@@ -5,7 +5,7 @@ from datetime import datetime + import sys + + import six +-from nose.tools import assert_raises, assert_equal, raises ++from pytest import raises + + from datadiff import diff, DataDiff, NotHashable, DiffNotImplementedForType, DiffTypeError + +@@ -28,9 +28,8 @@ def test_diff_objects(): + diff(Foo(), Foo(), fromfile="x", tofile="y") + except Exception: + e = sys.exc_info()[1] +- assert_equal(type(e), DiffNotImplementedForType, +- "Raised exception should be DiffNotImplementedForType") +- assert_equal(e.attempted_type, Foo) ++ assert type(e) is DiffNotImplementedForType ++ assert e.attempted_type is Foo + else: + raise AssertionError("Should've raised a DiffNotImplementedForType") + +@@ -39,9 +38,8 @@ def test_diff_oneline_strings(): + diff('foobar', 'baz', fromfile="x", tofile="y") + except Exception: + e = sys.exc_info()[1] +- assert_equal(type(e), DiffNotImplementedForType, +- "Raised exception should be DiffNotImplementedForType") +- assert_equal(e.attempted_type, str) ++ assert type(e) is DiffNotImplementedForType ++ assert e.attempted_type is str + else: + raise AssertionError("Should've raised a DiffNotImplementedForType") + +@@ -56,7 +54,7 @@ def test_diff_multiline_strings(): + abc + -def + ghi''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_unicode_vs_str(): + if six.PY3: +@@ -71,7 +69,7 @@ def test_diff_unicode_vs_str(): + abc + -def + ghi''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_list(): + a = [1,'xyz', 2, 3, 4, 5] +@@ -91,7 +89,7 @@ def test_diff_list(): + -5, + +6, + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_list_context(): + a = [1]*50 + [2, 3, 4, 5, 6, 7, 8] + [1]*10 +@@ -119,7 +117,7 @@ def test_diff_list_context(): + 1, + @@ @@ + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_list_2nd_longer(): + a = [3] +@@ -134,7 +132,7 @@ def test_diff_list_2nd_longer(): + +4, + +5, + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_list_list(): + a = [1, [2, 3], 4] +@@ -149,7 +147,7 @@ def test_diff_list_list(): + -[2, 3], + 4, + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_list_dict(): + a = [1, {'a': 'b'}, 4] +@@ -164,7 +162,7 @@ def test_diff_list_dict(): + -{'a': 'b'}, + 4, + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_list_set(): + a = [1, set([8, 9]), 4] +@@ -179,7 +177,7 @@ def test_diff_list_set(): + -%s8, 9%s, + 4, + ]''') % (set_start, set_end) +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_seq_objects(): + class FooSeq(object): +@@ -201,7 +199,7 @@ def test_diff_seq_objects(): + 1, + +2, + ])''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_almost_seq_objects(): + class FooSeq(object): +@@ -210,7 +208,7 @@ def test_diff_almost_seq_objects(): + def __iter__(self): + return iter(self.list) + +- assert_raises(DiffTypeError, diff, FooSeq([1]), FooSeq([1,2])) ++ raises(DiffTypeError, diff, FooSeq([1]), FooSeq([1,2])) + + def test_tuple(): + d = diff((1,2), (1,3), fromfile="x", tofile="y") +@@ -223,7 +221,7 @@ def test_tuple(): + -2, + +3, + )''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_dict(): + a = dict(zero=0, one=1, two=2, three=3, nine=9, ten=10) +@@ -251,7 +249,7 @@ def test_diff_dict(): + assert "-'zero': 0," in diff_str + assert "+'zero': '@'," in diff_str + context_pattern = "^ '\w+': \d+,$" +- assert_equal(_count_lines(context_pattern, diff_str), 3) ++ assert _count_lines(context_pattern, diff_str) == 3 + + def _count_lines(pattern, str): + """ +@@ -274,7 +272,7 @@ def test_diff_dict_keytypes(): + +2: 2, + +datetime.datetime(2010, 10, 28, 0, 0): 1, + }''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_dict_complex(): + a = dict(a=1, b=dict(foo='bar')) +@@ -287,7 +285,7 @@ def test_diff_dict_complex(): + 'a': 1, + -'b': {'foo': 'bar'}, + }''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_set(set_type=set): + a = set_type([1, 3, 5, 7, 'abc', 'def']) +@@ -305,7 +303,7 @@ def test_diff_set(set_type=set): + 'abc', + 7, + ])''') % set_type.__name__ +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_set_context(): + a = set([1, 2, 3, 4, 5, 6, 7, 8, 9]) +@@ -321,42 +319,42 @@ def test_diff_set_context(): + 3, + @@ @@ + ])''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_diff_frozenset(): + return test_diff_set(set_type=frozenset) + + def test_eval_bool(): + d = diff([1], [1], fromfile="x", tofile="y") +- assert_equal(bool(d), False) ++ assert bool(d) is False + + d = diff([1], [2], fromfile="x", tofile="y") +- assert_equal(bool(d), True) ++ assert bool(d) is True + + d = diff(dict(a=1), dict(a=1), fromfile="x", tofile="y") +- assert_equal(bool(d), False) ++ assert bool(d) is False + + def test_equal(): + d = diff([1], [1], fromfile="x", tofile="y") +- assert_equal(str(d), '') ++ assert str(d) == '' + +-@raises(DiffTypeError) + def test_diff_types(): +- d = diff([1], {1:1}, fromfile="x", tofile="y") ++ with raises(DiffTypeError): ++ d = diff([1], {1:1}, fromfile="x", tofile="y") + +-@raises(Exception) + def test_DataDiff_init_params(): +- DataDiff(list, '[') ++ with raises(Exception): ++ DataDiff(list, '[') + + def test_DataDiff_change_type(): + dd = DataDiff(list, '[', ']') + dd.multi('foobar', [1234]) +- assert_raises(Exception, str, dd) ++ raises(Exception, str, dd) + + def test_unhashable_type(): + a = [] + b = [slice(1)] +- assert_raises(NotHashable, diff, a, b) ++ raises(NotHashable, diff, a, b) + + def test_recursive_list(): + a = [1, [7, 8, 9, 10, 11], 3] +@@ -378,7 +376,7 @@ def test_recursive_list(): + ], + 3, + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_recursive_tuple_different_types(): + a = (1, (7, 8, 9, 10, 11), 3) +@@ -401,7 +399,7 @@ def test_recursive_tuple_different_types + ), + 3, + )''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_recursive_dict(): + a = dict(a=1, b=dict(foo=17, bar=19), c=3) +@@ -418,7 +416,7 @@ def test_recursive_dict(): + }, + 'c': 3, + }''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_recursive_set(): + a = set([1, 2, frozenset([3, 4, 5]), 8]) +@@ -435,7 +433,7 @@ def test_recursive_set(): + 2, + ])''' % (frozenset_start, frozenset_end, + frozenset_start, frozenset_end)) +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_nested_unhashable(): + # dict is unhashable, and nested in a list +@@ -457,7 +455,7 @@ def test_nested_unhashable(): + }, + ), + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected + + def test_nested_unhashable2(): + # dict is unhashable, and nested in another dict +@@ -477,4 +475,4 @@ def test_nested_unhashable2(): + }, + }, + ]''') +- assert_equal(str(d), expected) ++ assert str(d) == expected +Index: datadiff-2.2.0/test_datadiff_tools.py +=================================================================== +--- datadiff-2.2.0.orig/test_datadiff_tools.py ++++ datadiff-2.2.0/test_datadiff_tools.py +@@ -3,20 +3,18 @@ from textwrap import dedent + + from datadiff import tools + +-from test_datadiff import assert_equal +- + + def test_assert_equal_true(): + # nothing raised +- assert_equal(None, tools.assert_equals(7, 7)) ++ assert tools.assert_equals(7, 7) is None + + def test_assert_equal_false(): + try: + tools.assert_equals([3,4], [5,6]) + except: + e = sys.exc_info()[1] +- assert_equal(type(e), AssertionError) +- assert_equal(str(e), dedent('''\ ++ assert type(e) is AssertionError ++ assert str(e) == dedent('''\ + + --- a + +++ b +@@ -26,7 +24,7 @@ def test_assert_equal_false(): + -4, + +5, + +6, +- ]''')) ++ ]''') + else: + raise AssertionError("Should've raised an AssertionError") + +@@ -35,23 +33,21 @@ def test_assert_equal_msg(): + tools.assert_equals(3, 4, "whoops") + except: + e = sys.exc_info()[1] +- assert_equal(type(e), AssertionError, +- "Raised exception should be AssertionError") +- assert_equal(str(e), "whoops") ++ assert type(e) is AssertionError ++ assert str(e) == "whoops" + else: + raise AssertionError("Should've raised an AssertionError") + + def test_assert_equals(): +- assert_equal(tools.assert_equal, tools.assert_equals) ++ assert tools.assert_equal == tools.assert_equals + + def test_assert_equal_simple(): + try: + tools.assert_equals(True, False) + except: + e = sys.exc_info()[1] +- assert_equal(type(e), AssertionError) +- assert_equal(str(e), dedent('''\ +- True != False''')) ++ assert type(e) is AssertionError ++ assert str(e) == 'True != False' + else: + raise AssertionError("Should've raised an AssertionError") + +@@ -60,9 +56,8 @@ def test_assert_equal_simple_types(): + tools.assert_equals('a', 7) + except: + e = sys.exc_info()[1] +- assert_equal(type(e), AssertionError) +- assert_equal(str(e), dedent('''\ +- 'a' != 7''')) ++ assert type(e) is AssertionError ++ assert str(e) == "'a' != 7" + else: + raise AssertionError("Should've raised an AssertionError") +