File switch-to-pytest.patch of Package failed_python-datadiff
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")