1120 lines
39 KiB
Diff
1120 lines
39 KiB
Diff
|
From 066fba05fcab35bf08fc87b388482ebc0ab0ccb9 Mon Sep 17 00:00:00 2001
|
||
|
From: Paolo Stivanin <info@paolostivanin.com>
|
||
|
Date: Thu, 26 Mar 2020 10:16:04 +0100
|
||
|
Subject: [PATCH] Fix tests
|
||
|
|
||
|
---
|
||
|
tests/{chai_test.py => test_chai.py} | 40 ++--
|
||
|
...{comparator_test.py => test_comparator.py} | 50 ++--
|
||
|
...xpectation_test.py => test_expectation.py} | 50 ++--
|
||
|
...{functional_test.py => test_functional.py} | 2 +-
|
||
|
tests/{mock_test.py => test_mock.py} | 22 +-
|
||
|
tests/{sample_test.py => test_sample.py} | 0
|
||
|
tests/{stub_test.py => test_stub.py} | 222 +++++++++---------
|
||
|
7 files changed, 193 insertions(+), 193 deletions(-)
|
||
|
rename tests/{chai_test.py => test_chai.py} (78%)
|
||
|
rename tests/{comparator_test.py => test_comparator.py} (80%)
|
||
|
rename tests/{expectation_test.py => test_expectation.py} (84%)
|
||
|
rename tests/{functional_test.py => test_functional.py} (98%)
|
||
|
rename tests/{mock_test.py => test_mock.py} (88%)
|
||
|
rename tests/{sample_test.py => test_sample.py} (100%)
|
||
|
rename tests/{stub_test.py => test_stub.py} (71%)
|
||
|
|
||
|
diff --git a/tests/chai_test.py b/tests/test_chai.py
|
||
|
similarity index 78%
|
||
|
rename from tests/chai_test.py
|
||
|
rename to tests/test_chai.py
|
||
|
index 71a93da..eb72600 100644
|
||
|
--- a/tests/chai_test.py
|
||
|
+++ b/tests/test_chai.py
|
||
|
@@ -59,8 +59,8 @@ class ChaiTest(unittest.TestCase):
|
||
|
def test_setup(self):
|
||
|
case = CupOf()
|
||
|
case.setup()
|
||
|
- self.assertEquals( deque(), case._stubs )
|
||
|
- self.assertEquals( deque(), case._mocks )
|
||
|
+ self.assertEqual( deque(), case._stubs )
|
||
|
+ self.assertEqual( deque(), case._mocks )
|
||
|
|
||
|
def test_teardown_closes_out_stubs_and_mocks(self):
|
||
|
class Stub(object):
|
||
|
@@ -76,8 +76,8 @@ class ChaiTest(unittest.TestCase):
|
||
|
case._stubs = deque([stub])
|
||
|
case._mocks = deque([(obj,'mock1','fee'), (obj,'mock2')])
|
||
|
case.teardown()
|
||
|
- self.assertEquals( 1, stub.calls )
|
||
|
- self.assertEquals( 'fee', obj.mock1 )
|
||
|
+ self.assertEqual( 1, stub.calls )
|
||
|
+ self.assertEqual( 'fee', obj.mock1 )
|
||
|
self.assertFalse( hasattr(obj, 'mock2') )
|
||
|
|
||
|
def test_stub(self):
|
||
|
@@ -87,14 +87,14 @@ class ChaiTest(unittest.TestCase):
|
||
|
case = CupOf()
|
||
|
milk = Milk()
|
||
|
case.setup()
|
||
|
- self.assertEquals( deque(), case._stubs )
|
||
|
+ self.assertEqual( deque(), case._stubs )
|
||
|
case.stub( milk.pour )
|
||
|
self.assertTrue( isinstance(milk.pour, Stub) )
|
||
|
- self.assertEquals( deque([milk.pour]), case._stubs )
|
||
|
+ self.assertEqual( deque([milk.pour]), case._stubs )
|
||
|
|
||
|
# Test it's only added once
|
||
|
case.stub( milk, 'pour' )
|
||
|
- self.assertEquals( deque([milk.pour]), case._stubs )
|
||
|
+ self.assertEqual( deque([milk.pour]), case._stubs )
|
||
|
|
||
|
def test_expect(self):
|
||
|
class Milk(object):
|
||
|
@@ -103,27 +103,27 @@ class ChaiTest(unittest.TestCase):
|
||
|
case = CupOf()
|
||
|
milk = Milk()
|
||
|
case.setup()
|
||
|
- self.assertEquals( deque(), case._stubs )
|
||
|
+ self.assertEqual( deque(), case._stubs )
|
||
|
case.expect( milk.pour )
|
||
|
- self.assertEquals( deque([milk.pour]), case._stubs )
|
||
|
+ self.assertEqual( deque([milk.pour]), case._stubs )
|
||
|
|
||
|
# Test it's only added once
|
||
|
case.expect( milk, 'pour' )
|
||
|
- self.assertEquals( deque([milk.pour]), case._stubs )
|
||
|
+ self.assertEqual( deque([milk.pour]), case._stubs )
|
||
|
|
||
|
- self.assertEquals( 2, len(milk.pour._expectations) )
|
||
|
+ self.assertEqual( 2, len(milk.pour._expectations) )
|
||
|
|
||
|
def test_mock_no_binding(self):
|
||
|
case = CupOf()
|
||
|
case.setup()
|
||
|
|
||
|
- self.assertEquals( deque(), case._mocks )
|
||
|
+ self.assertEqual( deque(), case._mocks )
|
||
|
mock1 = case.mock()
|
||
|
self.assertTrue( isinstance(mock1, Mock) )
|
||
|
- self.assertEquals( deque(), case._mocks )
|
||
|
+ self.assertEqual( deque(), case._mocks )
|
||
|
mock2 = case.mock()
|
||
|
self.assertTrue( isinstance(mock2, Mock) )
|
||
|
- self.assertEquals( deque(), case._mocks )
|
||
|
+ self.assertEqual( deque(), case._mocks )
|
||
|
self.assertNotEqual( mock1, mock2 )
|
||
|
|
||
|
def test_mock_with_attr_binding(self):
|
||
|
@@ -136,18 +136,18 @@ class ChaiTest(unittest.TestCase):
|
||
|
milk = Milk()
|
||
|
orig_pour = milk.pour
|
||
|
|
||
|
- self.assertEquals( deque(), case._mocks )
|
||
|
+ self.assertEqual( deque(), case._mocks )
|
||
|
mock1 = case.mock( milk, 'pour' )
|
||
|
self.assertTrue( isinstance(mock1, Mock) )
|
||
|
- self.assertEquals( deque([(milk,'pour',orig_pour)]), case._mocks )
|
||
|
+ self.assertEqual( deque([(milk,'pour',orig_pour)]), case._mocks )
|
||
|
mock2 = case.mock( milk, 'pour' )
|
||
|
self.assertTrue( isinstance(mock2, Mock) )
|
||
|
- self.assertEquals( deque([(milk,'pour',orig_pour),(milk,'pour',mock1)]), case._mocks )
|
||
|
+ self.assertEqual( deque([(milk,'pour',orig_pour),(milk,'pour',mock1)]), case._mocks )
|
||
|
self.assertNotEqual( mock1, mock2 )
|
||
|
|
||
|
mock3 = case.mock( milk, 'foo' )
|
||
|
self.assertTrue( isinstance(mock3, Mock) )
|
||
|
- self.assertEquals( deque([(milk,'pour',orig_pour),(milk,'pour',mock1),(milk,'foo')]), case._mocks )
|
||
|
+ self.assertEqual( deque([(milk,'pour',orig_pour),(milk,'pour',mock1),(milk,'foo')]), case._mocks )
|
||
|
|
||
|
def test_chai_class_use_metaclass(self):
|
||
|
obj = CupOf()
|
||
|
@@ -169,8 +169,8 @@ class ChaiTest(unittest.TestCase):
|
||
|
case._stubs = deque([stub])
|
||
|
|
||
|
case.test_local_definitions_work_and_are_global()
|
||
|
- self.assertEquals(1, stub.unmet_calls)
|
||
|
- self.assertEquals(1, stub.teardown_calls)
|
||
|
+ self.assertEqual(1, stub.unmet_calls)
|
||
|
+ self.assertEqual(1, stub.teardown_calls)
|
||
|
|
||
|
def test_raises_if_unmet_expectations(self):
|
||
|
class Milk(object):
|
||
|
diff --git a/tests/comparator_test.py b/tests/test_comparator.py
|
||
|
similarity index 80%
|
||
|
rename from tests/comparator_test.py
|
||
|
rename to tests/test_comparator.py
|
||
|
index 594b3b6..8899b0e 100644
|
||
|
--- a/tests/comparator_test.py
|
||
|
+++ b/tests/test_comparator.py
|
||
|
@@ -43,11 +43,11 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
|
||
|
def test_equals_repr(self):
|
||
|
comp = Equals(3)
|
||
|
- self.assertEquals(str(comp), "3")
|
||
|
+ self.assertEqual(str(comp), "3")
|
||
|
|
||
|
def test_eq(self):
|
||
|
comp = Equals(3)
|
||
|
- self.assertEquals( comp, 3 )
|
||
|
+ self.assertEqual( comp, 3 )
|
||
|
|
||
|
def test_is_a(self):
|
||
|
comp = IsA(str)
|
||
|
@@ -64,13 +64,13 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
|
||
|
def test_is_a_repr(self):
|
||
|
comp = IsA(str)
|
||
|
- self.assertEquals(repr(comp), "IsA(str)")
|
||
|
+ self.assertEqual(repr(comp), "IsA(str)")
|
||
|
|
||
|
def test_is_a_format_name(self):
|
||
|
comp = IsA(str)
|
||
|
- self.assertEquals(comp._format_name(), "str")
|
||
|
+ self.assertEqual(comp._format_name(), "str")
|
||
|
comp = IsA((str, list))
|
||
|
- self.assertEquals(comp._format_name(), "['str', 'list']")
|
||
|
+ self.assertEqual(comp._format_name(), "['str', 'list']")
|
||
|
|
||
|
def test_is(self):
|
||
|
class Test(object):
|
||
|
@@ -79,7 +79,7 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
obj1 = Test()
|
||
|
obj2 = Test()
|
||
|
comp = Is(obj1)
|
||
|
- self.assertEquals( obj1, obj2 )
|
||
|
+ self.assertEqual( obj1, obj2 )
|
||
|
self.assertTrue( comp.test(obj1) )
|
||
|
self.assertFalse( comp.test(obj2) )
|
||
|
|
||
|
@@ -90,7 +90,7 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
return "An Object"
|
||
|
|
||
|
obj = TestObj()
|
||
|
- self.assertEquals(repr(Is(obj)), "Is(An Object)" )
|
||
|
+ self.assertEqual(repr(Is(obj)), "Is(An Object)" )
|
||
|
|
||
|
def test_almost_equal(self):
|
||
|
comp = AlmostEqual(3.14159265, 3)
|
||
|
@@ -99,7 +99,7 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
|
||
|
def test_almost_equal_repr(self):
|
||
|
comp = AlmostEqual(3.14159265, 3)
|
||
|
- self.assertEquals(repr(comp), "AlmostEqual(value: 3.14159265, places: 3)")
|
||
|
+ self.assertEqual(repr(comp), "AlmostEqual(value: 3.14159265, places: 3)")
|
||
|
|
||
|
def test_regex(self):
|
||
|
comp = Regex('[wf][io]{2}')
|
||
|
@@ -109,7 +109,7 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
|
||
|
def test_regex_repr(self):
|
||
|
comp = Regex('[wf][io]{2}')
|
||
|
- self.assertEquals(repr(comp), "Regex(pattern: [wf][io]{2}, flags: 0)")
|
||
|
+ self.assertEqual(repr(comp), "Regex(pattern: [wf][io]{2}, flags: 0)")
|
||
|
|
||
|
def test_any(self):
|
||
|
comp = Any(1,2.3,str)
|
||
|
@@ -120,9 +120,9 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
def test_any_repr(self):
|
||
|
comp = Any(1,2,3,str)
|
||
|
if sys.version_info.major==2:
|
||
|
- self.assertEquals(repr(comp), "Any([1, 2, 3, Any([IsA(str), Is(<type 'str'>)])])")
|
||
|
+ self.assertEqual(repr(comp), "Any([1, 2, 3, Any([IsA(str), Is(<type 'str'>)])])")
|
||
|
else:
|
||
|
- self.assertEquals(repr(comp), "Any([1, 2, 3, Any([IsA(str), Is(<class 'str'>)])])")
|
||
|
+ self.assertEqual(repr(comp), "Any([1, 2, 3, Any([IsA(str), Is(<class 'str'>)])])")
|
||
|
|
||
|
def test_in(self):
|
||
|
comp = In(['foo', 'bar'])
|
||
|
@@ -149,7 +149,7 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
comp = All(IsA(bytearray), Equals('foo'.encode('ascii')))
|
||
|
self.assertTrue( comp.test(bytearray('foo'.encode('ascii'))) )
|
||
|
self.assertFalse( comp.test('foo') )
|
||
|
- self.assertEquals( 'foo'.encode('ascii'), bytearray('foo'.encode('ascii')) )
|
||
|
+ self.assertEqual( 'foo'.encode('ascii'), bytearray('foo'.encode('ascii')) )
|
||
|
|
||
|
def test_all_repr(self):
|
||
|
comp = All(IsA(bytearray), Equals('foobar'))
|
||
|
@@ -186,38 +186,38 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
|
||
|
def test_variable(self):
|
||
|
comp = Variable('foo')
|
||
|
- self.assertEquals( 0, len(Variable._cache) )
|
||
|
+ self.assertEqual( 0, len(Variable._cache) )
|
||
|
self.assertTrue( comp.test('bar') )
|
||
|
- self.assertEquals( 1, len(Variable._cache) )
|
||
|
+ self.assertEqual( 1, len(Variable._cache) )
|
||
|
self.assertTrue( comp.test('bar') )
|
||
|
self.assertFalse( comp.test('bar2') )
|
||
|
|
||
|
self.assertTrue( Variable('foo').test('bar') )
|
||
|
self.assertFalse( Variable('foo').test('bar2') )
|
||
|
- self.assertEquals( 1, len(Variable._cache) )
|
||
|
+ self.assertEqual( 1, len(Variable._cache) )
|
||
|
|
||
|
- self.assertEquals( 'bar', comp.value )
|
||
|
- self.assertEquals( 'bar', Variable('foo').value )
|
||
|
+ self.assertEqual( 'bar', comp.value )
|
||
|
+ self.assertEqual( 'bar', Variable('foo').value )
|
||
|
|
||
|
v = Variable('foo2')
|
||
|
- self.assertEquals( 1, len(Variable._cache) )
|
||
|
+ self.assertEqual( 1, len(Variable._cache) )
|
||
|
v.test('dog')
|
||
|
- self.assertEquals( 'dog', v.value )
|
||
|
- self.assertEquals( 2, len(Variable._cache) )
|
||
|
+ self.assertEqual( 'dog', v.value )
|
||
|
+ self.assertEqual( 2, len(Variable._cache) )
|
||
|
|
||
|
Variable.clear()
|
||
|
- self.assertEquals( 0, len(Variable._cache) )
|
||
|
+ self.assertEqual( 0, len(Variable._cache) )
|
||
|
|
||
|
def test_variable_repr(self):
|
||
|
v = Variable('foo')
|
||
|
- self.assertEquals( repr(v), "Variable('foo')" )
|
||
|
+ self.assertEqual( repr(v), "Variable('foo')" )
|
||
|
|
||
|
def test_like_init(self):
|
||
|
c = Like({'foo':'bar'})
|
||
|
- self.assertEquals( {'foo':'bar'}, c._src )
|
||
|
+ self.assertEqual( {'foo':'bar'}, c._src )
|
||
|
|
||
|
c = Like(['foo', 'bar'])
|
||
|
- self.assertEquals( ['foo','bar'], c._src )
|
||
|
+ self.assertEqual( ['foo','bar'], c._src )
|
||
|
|
||
|
def test_like_test(self):
|
||
|
c = Like({'foo':'bar'})
|
||
|
@@ -232,4 +232,4 @@ class ComparatorsTest(unittest.TestCase):
|
||
|
|
||
|
def test_like_repr(self):
|
||
|
c = Like({'foo':'bar'})
|
||
|
- self.assertEquals( repr(c), "Like({'foo': 'bar'})" )
|
||
|
+ self.assertEqual( repr(c), "Like({'foo': 'bar'})" )
|
||
|
diff --git a/tests/expectation_test.py b/tests/test_expectation.py
|
||
|
similarity index 84%
|
||
|
rename from tests/expectation_test.py
|
||
|
rename to tests/test_expectation.py
|
||
|
index 0abee54..b6c2ea6 100644
|
||
|
--- a/tests/expectation_test.py
|
||
|
+++ b/tests/test_expectation.py
|
||
|
@@ -87,45 +87,45 @@ class ExpectationRule(unittest.TestCase):
|
||
|
|
||
|
def test_times(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.times(3) )
|
||
|
- self.assertEquals( 3, exp._min_count )
|
||
|
- self.assertEquals( 3, exp._max_count )
|
||
|
+ self.assertEqual( exp, exp.times(3) )
|
||
|
+ self.assertEqual( 3, exp._min_count )
|
||
|
+ self.assertEqual( 3, exp._max_count )
|
||
|
|
||
|
def test_at_least_once(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.at_least_once() )
|
||
|
+ self.assertEqual( exp, exp.at_least_once() )
|
||
|
exp.test()
|
||
|
self.assertTrue(exp.closed(with_counts=True))
|
||
|
|
||
|
def test_at_least(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.at_least(10) )
|
||
|
+ self.assertEqual( exp, exp.at_least(10) )
|
||
|
for x in range(10):
|
||
|
exp.test()
|
||
|
self.assertTrue(exp.closed(with_counts=True))
|
||
|
|
||
|
def test_at_most_once(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.args(1).at_most_once() )
|
||
|
+ self.assertEqual( exp, exp.args(1).at_most_once() )
|
||
|
exp.test(1)
|
||
|
self.assertTrue(exp.closed(with_counts=True))
|
||
|
|
||
|
def test_at_most(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.args(1).at_most(10) )
|
||
|
+ self.assertEqual( exp, exp.args(1).at_most(10) )
|
||
|
for x in range(10):
|
||
|
exp.test(1)
|
||
|
self.assertTrue(exp.closed(with_counts=True))
|
||
|
|
||
|
def test_once(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.args(1).once() )
|
||
|
+ self.assertEqual( exp, exp.args(1).once() )
|
||
|
exp.test(1)
|
||
|
self.assertTrue(exp.closed())
|
||
|
|
||
|
def test_any_order(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.any_order().times(1) )
|
||
|
+ self.assertEqual( exp, exp.any_order().times(1) )
|
||
|
self.assertFalse( exp.closed() )
|
||
|
exp.close()
|
||
|
self.assertFalse( exp.closed() )
|
||
|
@@ -136,7 +136,7 @@ class ExpectationRule(unittest.TestCase):
|
||
|
|
||
|
def test_any_order_with_no_max(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.any_order().at_least_once() )
|
||
|
+ self.assertEqual( exp, exp.any_order().at_least_once() )
|
||
|
self.assertFalse( exp.closed() )
|
||
|
exp.close()
|
||
|
self.assertFalse( exp.closed() )
|
||
|
@@ -151,9 +151,9 @@ class ExpectationRule(unittest.TestCase):
|
||
|
foo.append('foo')
|
||
|
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.side_effect(effect) )
|
||
|
+ self.assertEqual( exp, exp.side_effect(effect) )
|
||
|
exp.test()
|
||
|
- self.assertEquals( ['foo'], called )
|
||
|
+ self.assertEqual( ['foo'], called )
|
||
|
|
||
|
def test_side_effect_with_args(self):
|
||
|
called = []
|
||
|
@@ -162,9 +162,9 @@ class ExpectationRule(unittest.TestCase):
|
||
|
called.append('foo')
|
||
|
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.side_effect(effect, 'a', b='c') )
|
||
|
+ self.assertEqual( exp, exp.side_effect(effect, 'a', b='c') )
|
||
|
exp.test()
|
||
|
- self.assertEquals( ['foo'], called )
|
||
|
+ self.assertEqual( ['foo'], called )
|
||
|
|
||
|
def test_side_effect_with_passed_args(self):
|
||
|
called = []
|
||
|
@@ -174,9 +174,9 @@ class ExpectationRule(unittest.TestCase):
|
||
|
|
||
|
exp = Expectation(self.stub)
|
||
|
exp.args('a', b='c')
|
||
|
- self.assertEquals( exp, exp.side_effect(effect) )
|
||
|
+ self.assertEqual( exp, exp.side_effect(effect) )
|
||
|
exp.test('a', b='c')
|
||
|
- self.assertEquals( ['foo'], called )
|
||
|
+ self.assertEqual( ['foo'], called )
|
||
|
|
||
|
def test_side_effect_with_an_exception(self):
|
||
|
called = []
|
||
|
@@ -185,9 +185,9 @@ class ExpectationRule(unittest.TestCase):
|
||
|
class Zono(Exception): pass
|
||
|
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.side_effect(effect).raises(Zono) )
|
||
|
+ self.assertEqual( exp, exp.side_effect(effect).raises(Zono) )
|
||
|
self.assertRaises( Zono, exp.test )
|
||
|
- self.assertEquals( ['foo'], called )
|
||
|
+ self.assertEqual( ['foo'], called )
|
||
|
|
||
|
def test_teardown(self):
|
||
|
called = []
|
||
|
@@ -199,7 +199,7 @@ class ExpectationRule(unittest.TestCase):
|
||
|
exp = Expectation( notastub() )
|
||
|
exp.teardown()
|
||
|
exp.test()
|
||
|
- self.assertEquals( ['foo'], called )
|
||
|
+ self.assertEqual( ['foo'], called )
|
||
|
|
||
|
def test_closed(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
@@ -223,7 +223,7 @@ class ExpectationRule(unittest.TestCase):
|
||
|
exp = Expectation(self.stub)
|
||
|
exp.returns(123)
|
||
|
|
||
|
- self.assertEquals(exp.test(), 123)
|
||
|
+ self.assertEqual(exp.test(), 123)
|
||
|
|
||
|
def test_return_value_with_variable(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
@@ -231,7 +231,7 @@ class ExpectationRule(unittest.TestCase):
|
||
|
Variable._cache['test'] = 123
|
||
|
exp.returns( var )
|
||
|
|
||
|
- self.assertEquals(exp.test(), 123)
|
||
|
+ self.assertEqual(exp.test(), 123)
|
||
|
Variable.clear()
|
||
|
|
||
|
def test_return_value_with_variable_in_tuple(self):
|
||
|
@@ -240,13 +240,13 @@ class ExpectationRule(unittest.TestCase):
|
||
|
Variable._cache['test'] = 123
|
||
|
exp.returns( (var,'foo') )
|
||
|
|
||
|
- self.assertEquals(exp.test(), (123,'foo'))
|
||
|
+ self.assertEqual(exp.test(), (123,'foo'))
|
||
|
Variable.clear()
|
||
|
|
||
|
def test_with_returns_return_value(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
with exp.returns(123) as num:
|
||
|
- self.assertEquals(num, 123)
|
||
|
+ self.assertEqual(num, 123)
|
||
|
|
||
|
def test_with_raises_exceptions(self):
|
||
|
exp = Expectation(self.stub)
|
||
|
@@ -261,7 +261,7 @@ class ExpectationRule(unittest.TestCase):
|
||
|
class CustomException(Exception): pass
|
||
|
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.raises(CustomException) )
|
||
|
+ self.assertEqual( exp, exp.raises(CustomException) )
|
||
|
|
||
|
self.assertRaises(CustomException, exp.test)
|
||
|
|
||
|
@@ -269,7 +269,7 @@ class ExpectationRule(unittest.TestCase):
|
||
|
class CustomException(Exception): pass
|
||
|
|
||
|
exp = Expectation(self.stub)
|
||
|
- self.assertEquals( exp, exp.raises(CustomException()) )
|
||
|
+ self.assertEqual( exp, exp.raises(CustomException()) )
|
||
|
|
||
|
self.assertRaises(CustomException, exp.test)
|
||
|
|
||
|
diff --git a/tests/functional_test.py b/tests/test_functional.py
|
||
|
similarity index 98%
|
||
|
rename from tests/functional_test.py
|
||
|
rename to tests/test_functional.py
|
||
|
index 4d9aae6..2bdc9a7 100644
|
||
|
--- a/tests/functional_test.py
|
||
|
+++ b/tests/test_functional.py
|
||
|
@@ -65,7 +65,7 @@ class FunctionalTest(Chai):
|
||
|
return x
|
||
|
f = Foo()
|
||
|
|
||
|
- assert_equals( 3, f.bar(3) )
|
||
|
+ assert_equals(3, f.bar(3))
|
||
|
|
||
|
expect( f.bar )
|
||
|
assert_equals( None, f.bar() )
|
||
|
diff --git a/tests/mock_test.py b/tests/test_mock.py
|
||
|
similarity index 88%
|
||
|
rename from tests/mock_test.py
|
||
|
rename to tests/test_mock.py
|
||
|
index 0fefcec..5e0d24b 100644
|
||
|
--- a/tests/mock_test.py
|
||
|
+++ b/tests/test_mock.py
|
||
|
@@ -17,10 +17,10 @@ class MockTest(unittest.TestCase):
|
||
|
# self.assertTrue( isinstance(m.foo, types.MethodType) )
|
||
|
def test_get_attribute_creates_a_mock_method(self):
|
||
|
m = Mock()
|
||
|
- self.assertEquals( 'mock', m._name )
|
||
|
+ self.assertEqual( 'mock', m._name )
|
||
|
self.assertTrue( isinstance(m.foo, Mock) )
|
||
|
self.assertFalse( m.foo is m )
|
||
|
- self.assertEquals( 'mock.foo', m.foo._name )
|
||
|
+ self.assertEqual( 'mock.foo', m.foo._name )
|
||
|
|
||
|
def test_get_attribute_caches_auto_methods(self):
|
||
|
m = Mock()
|
||
|
@@ -42,17 +42,17 @@ class MockTest(unittest.TestCase):
|
||
|
def test_get_attribute_auto_method_not_raises_unexpectedcall_when_stubbed(self):
|
||
|
m = Mock()
|
||
|
stub(m.foo).expect().returns('success')
|
||
|
- self.assertEquals( 'success', m.foo() )
|
||
|
+ self.assertEqual( 'success', m.foo() )
|
||
|
|
||
|
def test_get_attribute_auto_method_not_raises_unexpectedcall_multiple_depths(self):
|
||
|
m = Mock()
|
||
|
stub(m.foo.bar).expect().returns('success')
|
||
|
- self.assertEquals( 'success', m.foo.bar() )
|
||
|
+ self.assertEqual( 'success', m.foo.bar() )
|
||
|
|
||
|
def test_get_attribute_does_not_overwrite_existing_attr(self):
|
||
|
m = Mock()
|
||
|
m.foo = 42
|
||
|
- self.assertEquals( 42, m.foo )
|
||
|
+ self.assertEqual( 42, m.foo )
|
||
|
|
||
|
def test_call_raises_unexpectedcall_when_unstubbed(self):
|
||
|
m = Mock()
|
||
|
@@ -61,7 +61,7 @@ class MockTest(unittest.TestCase):
|
||
|
def test_call_not_raises_unexpectedcall_when_stubbed(self):
|
||
|
m = Mock()
|
||
|
stub(m).expect().returns('success')
|
||
|
- self.assertEquals( 'success', m() )
|
||
|
+ self.assertEqual( 'success', m() )
|
||
|
|
||
|
def test_nonzero_returns_true_when_unstubbed(self):
|
||
|
m = Mock()
|
||
|
@@ -97,13 +97,13 @@ class MockTest(unittest.TestCase):
|
||
|
stub( m.__reversed__ ).expect().returns( 'backwards' )
|
||
|
stub( m.__contains__ ).expect().args('foo').returns( True )
|
||
|
|
||
|
- self.assertEquals( 42, len(m) )
|
||
|
- self.assertEquals( 'getitem', m['foo'] )
|
||
|
+ self.assertEqual( 42, len(m) )
|
||
|
+ self.assertEqual( 'getitem', m['foo'] )
|
||
|
m['foo']='bar'
|
||
|
del m['foo']
|
||
|
- self.assertEquals( i, iter(m) )
|
||
|
- self.assertEquals( 'backwards', reversed(m) )
|
||
|
- self.assertEquals( True, 'foo' in m )
|
||
|
+ self.assertEqual( i, iter(m) )
|
||
|
+ self.assertEqual( 'backwards', reversed(m) )
|
||
|
+ self.assertEqual( True, 'foo' in m )
|
||
|
|
||
|
def test_context_manager_interface_when_unstubbed(self):
|
||
|
m = Mock()
|
||
|
diff --git a/tests/sample_test.py b/tests/test_sample.py
|
||
|
similarity index 100%
|
||
|
rename from tests/sample_test.py
|
||
|
rename to tests/test_sample.py
|
||
|
diff --git a/tests/stub_test.py b/tests/test_stub.py
|
||
|
similarity index 71%
|
||
|
rename from tests/stub_test.py
|
||
|
rename to tests/test_stub.py
|
||
|
index c5a655e..ceab5bc 100644
|
||
|
--- a/tests/stub_test.py
|
||
|
+++ b/tests/test_stub.py
|
||
|
@@ -80,8 +80,8 @@ class StubTest(unittest.TestCase):
|
||
|
f.bar = Mock()
|
||
|
res = stub(f, 'bar')
|
||
|
self.assertTrue(isinstance(res, StubMethod))
|
||
|
- self.assertEquals(res, f.bar.__call__)
|
||
|
- self.assertEquals(res, stub(f, 'bar'))
|
||
|
+ self.assertEqual(res, f.bar.__call__)
|
||
|
+ self.assertEqual(res, stub(f, 'bar'))
|
||
|
|
||
|
def test_stub_mock_with_obj_ref(self):
|
||
|
class Foo(object):
|
||
|
@@ -91,8 +91,8 @@ class StubTest(unittest.TestCase):
|
||
|
f.bar = Mock()
|
||
|
res = stub(f.bar)
|
||
|
self.assertTrue(isinstance(res, StubMethod))
|
||
|
- self.assertEquals(res, f.bar.__call__)
|
||
|
- self.assertEquals(res, stub(f.bar))
|
||
|
+ self.assertEqual(res, f.bar.__call__)
|
||
|
+ self.assertEqual(res, stub(f.bar))
|
||
|
|
||
|
def test_stub_type_with_obj_ref(self):
|
||
|
class Foo(object):
|
||
|
@@ -100,14 +100,14 @@ class StubTest(unittest.TestCase):
|
||
|
|
||
|
res = stub(Foo)
|
||
|
self.assertTrue(isinstance(res, StubNew))
|
||
|
- self.assertEquals(res, Foo.__new__)
|
||
|
- self.assertEquals(res, stub(Foo))
|
||
|
+ self.assertEqual(res, Foo.__new__)
|
||
|
+ self.assertEqual(res, stub(Foo))
|
||
|
|
||
|
# test that __init__ called only once
|
||
|
res.expect()
|
||
|
- self.assertEquals(1, len(res._expectations))
|
||
|
+ self.assertEqual(1, len(res._expectations))
|
||
|
res = stub(Foo)
|
||
|
- self.assertEquals(1, len(res._expectations))
|
||
|
+ self.assertEqual(1, len(res._expectations))
|
||
|
|
||
|
def test_stub_unbound_method_with_attr_name(self):
|
||
|
class Foo(object):
|
||
|
@@ -115,8 +115,8 @@ class StubTest(unittest.TestCase):
|
||
|
|
||
|
res = stub(Foo, 'bar')
|
||
|
self.assertTrue(isinstance(res,StubUnboundMethod))
|
||
|
- self.assertEquals(res, stub(Foo,'bar'))
|
||
|
- self.assertEquals(res, getattr(Foo,'bar'))
|
||
|
+ self.assertEqual(res, stub(Foo,'bar'))
|
||
|
+ self.assertEqual(res, getattr(Foo,'bar'))
|
||
|
|
||
|
@unittest.skipIf(sys.version_info.major==3, "can't stub unbound methods by reference in python 3")
|
||
|
def test_stub_unbound_method_with_obj_ref(self):
|
||
|
@@ -125,8 +125,8 @@ class StubTest(unittest.TestCase):
|
||
|
|
||
|
res = stub(Foo.bar)
|
||
|
self.assertTrue(isinstance(res,StubUnboundMethod))
|
||
|
- self.assertEquals(res, stub(Foo.bar))
|
||
|
- self.assertEquals(res, getattr(Foo,'bar'))
|
||
|
+ self.assertEqual(res, stub(Foo.bar))
|
||
|
+ self.assertEqual(res, getattr(Foo,'bar'))
|
||
|
|
||
|
def test_stub_bound_method_for_instance_with_attr_name(self):
|
||
|
class Foo(object):
|
||
|
@@ -136,11 +136,11 @@ class StubTest(unittest.TestCase):
|
||
|
orig = foo.bar
|
||
|
res = stub(foo, 'bar')
|
||
|
self.assertTrue(isinstance(res,StubMethod))
|
||
|
- self.assertEquals(res._instance, foo)
|
||
|
- self.assertEquals(res._obj, orig)
|
||
|
- self.assertEquals(res._attr, 'bar')
|
||
|
- self.assertEquals(res, stub(foo,'bar'))
|
||
|
- self.assertEquals(res, getattr(foo,'bar'))
|
||
|
+ self.assertEqual(res._instance, foo)
|
||
|
+ self.assertEqual(res._obj, orig)
|
||
|
+ self.assertEqual(res._attr, 'bar')
|
||
|
+ self.assertEqual(res, stub(foo,'bar'))
|
||
|
+ self.assertEqual(res, getattr(foo,'bar'))
|
||
|
|
||
|
def test_stub_bound_method_for_instance_with_obj_ref(self):
|
||
|
class Foo(object):
|
||
|
@@ -150,11 +150,11 @@ class StubTest(unittest.TestCase):
|
||
|
orig = foo.bar
|
||
|
res = stub(foo.bar)
|
||
|
self.assertTrue(isinstance(res,StubMethod))
|
||
|
- self.assertEquals(res._instance, foo)
|
||
|
- self.assertEquals(res._obj, orig)
|
||
|
- self.assertEquals(res._attr, 'bar')
|
||
|
- self.assertEquals(res, stub(foo.bar))
|
||
|
- self.assertEquals(res, getattr(foo,'bar'))
|
||
|
+ self.assertEqual(res._instance, foo)
|
||
|
+ self.assertEqual(res._obj, orig)
|
||
|
+ self.assertEqual(res._attr, 'bar')
|
||
|
+ self.assertEqual(res, stub(foo.bar))
|
||
|
+ self.assertEqual(res, getattr(foo,'bar'))
|
||
|
|
||
|
def test_stub_bound_method_for_classmethod_with_attr_name(self):
|
||
|
class Foo(object):
|
||
|
@@ -163,8 +163,8 @@ class StubTest(unittest.TestCase):
|
||
|
|
||
|
res = stub(Foo, 'bar')
|
||
|
self.assertTrue(isinstance(res,StubMethod))
|
||
|
- self.assertEquals(res, stub(Foo,'bar'))
|
||
|
- self.assertEquals(res, getattr(Foo,'bar'))
|
||
|
+ self.assertEqual(res, stub(Foo,'bar'))
|
||
|
+ self.assertEqual(res, getattr(Foo,'bar'))
|
||
|
|
||
|
def test_stub_bound_method_for_classmethod_with_obj_ref(self):
|
||
|
class Foo(object):
|
||
|
@@ -173,8 +173,8 @@ class StubTest(unittest.TestCase):
|
||
|
|
||
|
res = stub(Foo.bar)
|
||
|
self.assertTrue(isinstance(res,StubMethod))
|
||
|
- self.assertEquals(res, stub(Foo.bar))
|
||
|
- self.assertEquals(res, getattr(Foo,'bar'))
|
||
|
+ self.assertEqual(res, stub(Foo.bar))
|
||
|
+ self.assertEqual(res, getattr(Foo,'bar'))
|
||
|
|
||
|
@unittest.skipIf(IS_PYPY, "no method-wrapper in PyPy")
|
||
|
def test_stub_method_wrapper_with_attr_name(self):
|
||
|
@@ -183,8 +183,8 @@ class StubTest(unittest.TestCase):
|
||
|
foo = Foo()
|
||
|
res = stub(foo, '__hash__')
|
||
|
self.assertTrue(isinstance(res,StubMethodWrapper))
|
||
|
- self.assertEquals(res, stub(foo, '__hash__'))
|
||
|
- self.assertEquals(res, getattr(foo, '__hash__'))
|
||
|
+ self.assertEqual(res, stub(foo, '__hash__'))
|
||
|
+ self.assertEqual(res, getattr(foo, '__hash__'))
|
||
|
|
||
|
@unittest.skipIf(IS_PYPY, "no method-wrapper in PyPy")
|
||
|
def test_stub_method_wrapper_with_obj_ref(self):
|
||
|
@@ -193,22 +193,22 @@ class StubTest(unittest.TestCase):
|
||
|
foo = Foo()
|
||
|
res = stub(foo.__hash__)
|
||
|
self.assertTrue(isinstance(res,StubMethodWrapper))
|
||
|
- self.assertEquals(res, stub(foo.__hash__))
|
||
|
- self.assertEquals(res, getattr(foo, '__hash__'))
|
||
|
+ self.assertEqual(res, stub(foo.__hash__))
|
||
|
+ self.assertEqual(res, getattr(foo, '__hash__'))
|
||
|
|
||
|
def test_stub_module_function_with_attr_name(self):
|
||
|
res = stub(samples, 'mod_func_1')
|
||
|
self.assertTrue(isinstance(res,StubFunction))
|
||
|
- self.assertEquals(res, getattr(samples,'mod_func_1'))
|
||
|
- self.assertEquals(res, stub(samples,'mod_func_1'))
|
||
|
+ self.assertEqual(res, getattr(samples,'mod_func_1'))
|
||
|
+ self.assertEqual(res, stub(samples,'mod_func_1'))
|
||
|
res.teardown()
|
||
|
|
||
|
def test_stub_module_function_with_obj_ref(self):
|
||
|
res = stub(samples.mod_func_1)
|
||
|
self.assertTrue(isinstance(res,StubFunction))
|
||
|
- self.assertEquals(res, getattr(samples,'mod_func_1'))
|
||
|
- self.assertEquals(res, samples.mod_func_1)
|
||
|
- self.assertEquals(res, stub(samples.mod_func_1))
|
||
|
+ self.assertEqual(res, getattr(samples,'mod_func_1'))
|
||
|
+ self.assertEqual(res, samples.mod_func_1)
|
||
|
+ self.assertEqual(res, stub(samples.mod_func_1))
|
||
|
res.teardown()
|
||
|
|
||
|
class StubClassTest(unittest.TestCase):
|
||
|
@@ -217,9 +217,9 @@ class StubClassTest(unittest.TestCase):
|
||
|
###
|
||
|
def test_init(self):
|
||
|
s = Stub('obj','attr')
|
||
|
- self.assertEquals('obj', s._obj)
|
||
|
- self.assertEquals('attr', s._attr)
|
||
|
- self.assertEquals([], s._expectations)
|
||
|
+ self.assertEqual('obj', s._obj)
|
||
|
+ self.assertEqual('attr', s._attr)
|
||
|
+ self.assertEqual([], s._expectations)
|
||
|
|
||
|
def test_unment_expectations(self):
|
||
|
s = Stub('obj', 'attr')
|
||
|
@@ -231,15 +231,15 @@ class StubClassTest(unittest.TestCase):
|
||
|
s = Stub('obj')
|
||
|
s._expections = ['1','2']
|
||
|
s.teardown()
|
||
|
- self.assertEquals([], s._expectations)
|
||
|
+ self.assertEqual([], s._expectations)
|
||
|
|
||
|
def test_expect(self):
|
||
|
s = Stub('obj')
|
||
|
|
||
|
- self.assertEquals([], s._expectations)
|
||
|
+ self.assertEqual([], s._expectations)
|
||
|
e = s.expect()
|
||
|
- self.assertEquals([e], s._expectations)
|
||
|
- self.assertEquals(s, e._stub)
|
||
|
+ self.assertEqual([e], s._expectations)
|
||
|
+ self.assertEqual(s, e._stub)
|
||
|
|
||
|
def test_call_orig_raises_notimplemented(self):
|
||
|
s = Stub('obj')
|
||
|
@@ -259,7 +259,7 @@ class StubClassTest(unittest.TestCase):
|
||
|
|
||
|
s = Stub('obj')
|
||
|
s._expectations = [ Expect() ]
|
||
|
- self.assertEquals('success', s('foo'))
|
||
|
+ self.assertEqual('success', s('foo'))
|
||
|
|
||
|
def test_call_raises_unexpected_call_when_all_expectations_closed(self):
|
||
|
class Expect(object):
|
||
|
@@ -291,10 +291,10 @@ class StubClassTest(unittest.TestCase):
|
||
|
s = Stub('obj')
|
||
|
s._expectations = [ Expect(True), Expect(False) ]
|
||
|
self.assertRaises(UnexpectedCall, s, 'foo')
|
||
|
- self.assertEquals(0, s._expectations[0]._match_count)
|
||
|
- self.assertEquals(1, s._expectations[1]._match_count)
|
||
|
- self.assertEquals(0, s._expectations[0]._close_count)
|
||
|
- self.assertEquals(0, s._expectations[1]._close_count)
|
||
|
+ self.assertEqual(0, s._expectations[0]._match_count)
|
||
|
+ self.assertEqual(1, s._expectations[1]._match_count)
|
||
|
+ self.assertEqual(0, s._expectations[0]._close_count)
|
||
|
+ self.assertEqual(0, s._expectations[1]._close_count)
|
||
|
|
||
|
class StubPropertyTest(unittest.TestCase):
|
||
|
# FIXME: Need to test teardown and init, these test might be in the base stub tests.
|
||
|
@@ -305,7 +305,7 @@ class StubPropertyTest(unittest.TestCase):
|
||
|
def prop(self): return 3
|
||
|
|
||
|
s = StubProperty(Foo, 'prop')
|
||
|
- self.assertEquals(s.name, 'Foo.prop')
|
||
|
+ self.assertEqual(s.name, 'Foo.prop')
|
||
|
|
||
|
class StubMethodTest(unittest.TestCase):
|
||
|
|
||
|
@@ -316,29 +316,29 @@ class StubMethodTest(unittest.TestCase):
|
||
|
f = Foo()
|
||
|
orig = f.bar
|
||
|
s = StubMethod(f.bar)
|
||
|
- self.assertEquals(s._obj, orig)
|
||
|
- self.assertEquals(s._instance, f)
|
||
|
- self.assertEquals(s._attr, 'bar')
|
||
|
- self.assertEquals(s, getattr(f,'bar'))
|
||
|
+ self.assertEqual(s._obj, orig)
|
||
|
+ self.assertEqual(s._instance, f)
|
||
|
+ self.assertEqual(s._attr, 'bar')
|
||
|
+ self.assertEqual(s, getattr(f,'bar'))
|
||
|
|
||
|
f = Foo()
|
||
|
orig = f.bar
|
||
|
s = StubMethod(f, 'bar')
|
||
|
- self.assertEquals(s._obj, orig)
|
||
|
- self.assertEquals(s._instance, f)
|
||
|
- self.assertEquals(s._attr, 'bar')
|
||
|
- self.assertEquals(s, getattr(f,'bar'))
|
||
|
+ self.assertEqual(s._obj, orig)
|
||
|
+ self.assertEqual(s._instance, f)
|
||
|
+ self.assertEqual(s._attr, 'bar')
|
||
|
+ self.assertEqual(s, getattr(f,'bar'))
|
||
|
|
||
|
def test_name(self):
|
||
|
class Expect(object):
|
||
|
def closed(self): return False
|
||
|
obj = Expect()
|
||
|
s = StubMethod(obj.closed)
|
||
|
- self.assertEquals("Expect.closed", s.name)
|
||
|
+ self.assertEqual("Expect.closed", s.name)
|
||
|
s.teardown()
|
||
|
|
||
|
s = StubMethod(obj, 'closed')
|
||
|
- self.assertEquals("Expect.closed", s.name)
|
||
|
+ self.assertEqual("Expect.closed", s.name)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_call_orig(self):
|
||
|
@@ -350,9 +350,9 @@ class StubMethodTest(unittest.TestCase):
|
||
|
f = Foo(3)
|
||
|
sa = StubMethod(f.a)
|
||
|
sb = StubMethod(f.b)
|
||
|
- self.assertEquals(3, sa.call_orig())
|
||
|
+ self.assertEqual(3, sa.call_orig())
|
||
|
sb.call_orig(5)
|
||
|
- self.assertEquals(5, sa.call_orig())
|
||
|
+ self.assertEqual(5, sa.call_orig())
|
||
|
|
||
|
def test_teardown(self):
|
||
|
class Foo(object):
|
||
|
@@ -362,7 +362,7 @@ class StubMethodTest(unittest.TestCase):
|
||
|
orig = f.bar
|
||
|
s = StubMethod(f.bar)
|
||
|
s.teardown()
|
||
|
- self.assertEquals(orig, f.bar)
|
||
|
+ self.assertEqual(orig, f.bar)
|
||
|
|
||
|
def test_teardown_of_classmethods(self):
|
||
|
class Foo(object):
|
||
|
@@ -378,46 +378,46 @@ class StubMethodTest(unittest.TestCase):
|
||
|
orig = samples.mod_instance_foo
|
||
|
s = StubMethod(samples, 'mod_instance_foo')
|
||
|
s.teardown()
|
||
|
- self.assertEquals(orig, samples.mod_instance_foo)
|
||
|
+ self.assertEqual(orig, samples.mod_instance_foo)
|
||
|
|
||
|
class StubFunctionTest(unittest.TestCase):
|
||
|
|
||
|
def test_init(self):
|
||
|
s = StubFunction(samples.mod_func_1)
|
||
|
- self.assertEquals(s._instance, samples)
|
||
|
- self.assertEquals(s._attr, 'mod_func_1')
|
||
|
- self.assertEquals(s, samples.mod_func_1)
|
||
|
- self.assertEquals(False, s._was_object_method)
|
||
|
+ self.assertEqual(s._instance, samples)
|
||
|
+ self.assertEqual(s._attr, 'mod_func_1')
|
||
|
+ self.assertEqual(s, samples.mod_func_1)
|
||
|
+ self.assertEqual(False, s._was_object_method)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_init_with_object_method(self):
|
||
|
x = samples.SampleBase()
|
||
|
s = StubFunction(x, '__new__')
|
||
|
- self.assertEquals(True, s._was_object_method)
|
||
|
+ self.assertEqual(True, s._was_object_method)
|
||
|
|
||
|
def test_name(self):
|
||
|
s = StubFunction(samples.mod_func_1)
|
||
|
- self.assertEquals('tests.samples.mod_func_1', s.name)
|
||
|
+ self.assertEqual('tests.samples.mod_func_1', s.name)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_call_orig(self):
|
||
|
s = StubFunction(samples.mod_func_3)
|
||
|
- self.assertEquals(12, s.call_orig(4))
|
||
|
+ self.assertEqual(12, s.call_orig(4))
|
||
|
s.teardown()
|
||
|
|
||
|
def test_teardown(self):
|
||
|
orig = samples.mod_func_1
|
||
|
s = StubFunction(samples.mod_func_1)
|
||
|
s.teardown()
|
||
|
- self.assertEquals(orig, samples.mod_func_1)
|
||
|
+ self.assertEqual(orig, samples.mod_func_1)
|
||
|
|
||
|
def test_teardown_on_object_method(self):
|
||
|
x = samples.SampleBase()
|
||
|
- self.assertEquals(object.__new__, getattr(x, '__new__'))
|
||
|
+ self.assertEqual(object.__new__, getattr(x, '__new__'))
|
||
|
s = StubFunction(x, '__new__')
|
||
|
- self.assertNotEquals(object.__new__, getattr(x, '__new__'))
|
||
|
+ self.assertNotEqual(object.__new__, getattr(x, '__new__'))
|
||
|
s.teardown()
|
||
|
- self.assertEquals(object.__new__, getattr(x, '__new__'))
|
||
|
+ self.assertEqual(object.__new__, getattr(x, '__new__'))
|
||
|
|
||
|
class StubNewTest(unittest.TestCase):
|
||
|
|
||
|
@@ -425,19 +425,19 @@ class StubNewTest(unittest.TestCase):
|
||
|
def test_new(self):
|
||
|
class Foo(object): pass
|
||
|
|
||
|
- self.assertEquals(0, len(StubNew._cache))
|
||
|
+ self.assertEqual(0, len(StubNew._cache))
|
||
|
x = StubNew(Foo)
|
||
|
self.assertTrue(x is StubNew(Foo))
|
||
|
- self.assertEquals(1, len(StubNew._cache))
|
||
|
+ self.assertEqual(1, len(StubNew._cache))
|
||
|
StubNew._cache.clear()
|
||
|
|
||
|
def test_init(self):
|
||
|
class Foo(object): pass
|
||
|
|
||
|
s = StubNew(Foo)
|
||
|
- self.assertEquals(s._instance, Foo)
|
||
|
- self.assertEquals(s._attr, '__new__')
|
||
|
- self.assertEquals(s, Foo.__new__)
|
||
|
+ self.assertEqual(s._instance, Foo)
|
||
|
+ self.assertEqual(s._attr, '__new__')
|
||
|
+ self.assertEqual(s, Foo.__new__)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_call(self):
|
||
|
@@ -449,7 +449,7 @@ class StubNewTest(unittest.TestCase):
|
||
|
|
||
|
s = StubNew(Foo)
|
||
|
s._expectations = [ Expect() ]
|
||
|
- self.assertEquals('success', Foo('state', a='b'))
|
||
|
+ self.assertEqual('success', Foo('state', a='b'))
|
||
|
s.teardown()
|
||
|
|
||
|
@unittest.skipIf(sys.version_info.major==3, "can't stub unbound methods in python 3")
|
||
|
@@ -462,7 +462,7 @@ class StubNewTest(unittest.TestCase):
|
||
|
s = StubNew(Foo)
|
||
|
f = s.call_orig(3)
|
||
|
self.assertTrue(isinstance(f,Foo))
|
||
|
- self.assertEquals(3, f._val)
|
||
|
+ self.assertEqual(3, f._val)
|
||
|
s.teardown()
|
||
|
StubNew._cache.clear()
|
||
|
|
||
|
@@ -471,12 +471,12 @@ class StubNewTest(unittest.TestCase):
|
||
|
class Foo(object): pass
|
||
|
|
||
|
orig = Foo.__new__
|
||
|
- self.assertEquals(0, len(StubNew._cache))
|
||
|
+ self.assertEqual(0, len(StubNew._cache))
|
||
|
x = StubNew(Foo)
|
||
|
- self.assertEquals(1, len(StubNew._cache))
|
||
|
+ self.assertEqual(1, len(StubNew._cache))
|
||
|
x.teardown()
|
||
|
- self.assertEquals(0, len(StubNew._cache))
|
||
|
- self.assertEquals(orig, Foo.__new__)
|
||
|
+ self.assertEqual(0, len(StubNew._cache))
|
||
|
+ self.assertEqual(orig, Foo.__new__)
|
||
|
|
||
|
@unittest.skipIf(sys.version_info.major==3, "can't stub unbound methods in python 3")
|
||
|
def test_teardown_on_custom_new(self):
|
||
|
@@ -487,16 +487,16 @@ class StubNewTest(unittest.TestCase):
|
||
|
return rval
|
||
|
|
||
|
f1 = Foo('f1')
|
||
|
- self.assertEquals(('f1',), f1.args)
|
||
|
+ self.assertEqual(('f1',), f1.args)
|
||
|
orig = Foo.__new__
|
||
|
- self.assertEquals(0, len(StubNew._cache))
|
||
|
+ self.assertEqual(0, len(StubNew._cache))
|
||
|
x = StubNew(Foo)
|
||
|
- self.assertEquals(1, len(StubNew._cache))
|
||
|
+ self.assertEqual(1, len(StubNew._cache))
|
||
|
x.teardown()
|
||
|
- self.assertEquals(0, len(StubNew._cache))
|
||
|
- self.assertEquals(orig, Foo.__new__)
|
||
|
+ self.assertEqual(0, len(StubNew._cache))
|
||
|
+ self.assertEqual(orig, Foo.__new__)
|
||
|
f2 = Foo('f2')
|
||
|
- self.assertEquals(('f2',), f2.args)
|
||
|
+ self.assertEqual(('f2',), f2.args)
|
||
|
|
||
|
|
||
|
class StubUnboundMethodTest(unittest.TestCase):
|
||
|
@@ -506,16 +506,16 @@ class StubUnboundMethodTest(unittest.TestCase):
|
||
|
def bar(self): pass
|
||
|
|
||
|
s = StubUnboundMethod(Foo, 'bar')
|
||
|
- self.assertEquals(s._instance, Foo)
|
||
|
- self.assertEquals(s._attr, 'bar')
|
||
|
- self.assertEquals(s, getattr(Foo,'bar'))
|
||
|
+ self.assertEqual(s._instance, Foo)
|
||
|
+ self.assertEqual(s._attr, 'bar')
|
||
|
+ self.assertEqual(s, getattr(Foo,'bar'))
|
||
|
|
||
|
def test_name(self):
|
||
|
class Expect(object):
|
||
|
def closed(self): return False
|
||
|
|
||
|
s = StubUnboundMethod(Expect, 'closed')
|
||
|
- self.assertEquals("Expect.closed", s.name)
|
||
|
+ self.assertEqual("Expect.closed", s.name)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_teardown(self):
|
||
|
@@ -525,7 +525,7 @@ class StubUnboundMethodTest(unittest.TestCase):
|
||
|
orig = Foo.bar
|
||
|
s = StubUnboundMethod(Foo, 'bar')
|
||
|
s.teardown()
|
||
|
- self.assertEquals(orig, Foo.bar)
|
||
|
+ self.assertEqual(orig, Foo.bar)
|
||
|
|
||
|
def test_call_acts_as_any_instance(self):
|
||
|
class Foo(object):
|
||
|
@@ -544,7 +544,7 @@ class StubUnboundMethodTest(unittest.TestCase):
|
||
|
f2 = Foo()
|
||
|
f2.bar()
|
||
|
|
||
|
- self.assertEquals(2, s.calls)
|
||
|
+ self.assertEqual(2, s.calls)
|
||
|
|
||
|
class StubMethodWrapperTest(unittest.TestCase):
|
||
|
|
||
|
@@ -553,16 +553,16 @@ class StubMethodWrapperTest(unittest.TestCase):
|
||
|
foo = Foo()
|
||
|
|
||
|
s = StubMethodWrapper(foo.__hash__)
|
||
|
- self.assertEquals(s._instance, foo)
|
||
|
- self.assertEquals(s._attr, '__hash__')
|
||
|
- self.assertEquals(s, getattr(foo,'__hash__'))
|
||
|
+ self.assertEqual(s._instance, foo)
|
||
|
+ self.assertEqual(s._attr, '__hash__')
|
||
|
+ self.assertEqual(s, getattr(foo,'__hash__'))
|
||
|
|
||
|
def test_name(self):
|
||
|
class Foo(object):pass
|
||
|
foo = Foo()
|
||
|
|
||
|
s = StubMethodWrapper(foo.__hash__)
|
||
|
- self.assertEquals("Foo.__hash__", s.name)
|
||
|
+ self.assertEqual("Foo.__hash__", s.name)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_call_orig(self):
|
||
|
@@ -575,9 +575,9 @@ class StubMethodWrapperTest(unittest.TestCase):
|
||
|
sg = StubMethodWrapper(f.get)
|
||
|
ss = StubMethodWrapper(f.set)
|
||
|
|
||
|
- self.assertEquals(3, sg.call_orig())
|
||
|
+ self.assertEqual(3, sg.call_orig())
|
||
|
ss.call_orig(5)
|
||
|
- self.assertEquals(5, sg.call_orig())
|
||
|
+ self.assertEqual(5, sg.call_orig())
|
||
|
|
||
|
def test_teardown(self):
|
||
|
class Foo(object):pass
|
||
|
@@ -585,7 +585,7 @@ class StubMethodWrapperTest(unittest.TestCase):
|
||
|
orig = obj.__hash__
|
||
|
s = StubMethodWrapper(obj.__hash__)
|
||
|
s.teardown()
|
||
|
- self.assertEquals(orig, obj.__hash__)
|
||
|
+ self.assertEqual(orig, obj.__hash__)
|
||
|
|
||
|
@unittest.skipIf(IS_PYPY, "no method-wrapper in PyPy")
|
||
|
class StubWrapperDescriptionTest(unittest.TestCase):
|
||
|
@@ -593,26 +593,26 @@ class StubWrapperDescriptionTest(unittest.TestCase):
|
||
|
def test_init(self):
|
||
|
class Foo(object):pass
|
||
|
s = StubWrapperDescriptor(Foo, '__hash__')
|
||
|
- self.assertEquals(s._obj, Foo)
|
||
|
- self.assertEquals(s._attr, '__hash__')
|
||
|
- self.assertEquals(s, getattr(Foo,'__hash__'))
|
||
|
+ self.assertEqual(s._obj, Foo)
|
||
|
+ self.assertEqual(s._attr, '__hash__')
|
||
|
+ self.assertEqual(s, getattr(Foo,'__hash__'))
|
||
|
|
||
|
def test_name(self):
|
||
|
class Foo(object):pass
|
||
|
|
||
|
s = StubWrapperDescriptor(Foo, '__hash__')
|
||
|
- self.assertEquals("Foo.__hash__", s.name)
|
||
|
+ self.assertEqual("Foo.__hash__", s.name)
|
||
|
s.teardown()
|
||
|
|
||
|
def test_call_orig(self):
|
||
|
class Foo(object): pass
|
||
|
if sys.version_info < (3, 3):
|
||
|
- foo_str = "<class 'tests.stub_test.Foo'>"
|
||
|
+ foo_str = "<class 'test_stub.Foo'>"
|
||
|
else:
|
||
|
- foo_str = "<class 'tests.stub_test.StubWrapperDescriptionTest.test_call_orig.<locals>.Foo'>"
|
||
|
+ foo_str = "<class 'test_stub.StubWrapperDescriptionTest.test_call_orig.<locals>.Foo'>"
|
||
|
|
||
|
s = StubWrapperDescriptor(Foo, '__str__')
|
||
|
- self.assertEquals(foo_str, s.call_orig())
|
||
|
+ self.assertEqual(foo_str, s.call_orig())
|
||
|
s.teardown()
|
||
|
|
||
|
def test_teardown(self):
|
||
|
@@ -620,4 +620,4 @@ class StubWrapperDescriptionTest(unittest.TestCase):
|
||
|
orig = Foo.__hash__
|
||
|
s = StubWrapperDescriptor(Foo, '__hash__')
|
||
|
s.teardown()
|
||
|
- self.assertEquals(orig, Foo.__hash__)
|
||
|
+ self.assertEqual(orig, Foo.__hash__)
|
||
|
--
|
||
|
2.25.1
|
||
|
|