Created
July 17, 2020 14:23
-
-
Save nsheridan/a08dc79a84cc2974710b7a02b78ff77b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import testslide | |
class AClass: | |
def a_method(self): | |
print("a_method") | |
def b_method(self): | |
print("b_method") | |
class AChild(AClass): | |
def b_method(self): | |
print("child_b_method") | |
class TestThing(testslide.TestCase): | |
def test_parent(self): | |
aclass = testslide.StrictMock(AClass) | |
self.mock_constructor(sys.modules[__name__], "AClass").to_return_value(aclass) | |
self.mock_callable(aclass, "a_method").to_return_value(None) | |
def test_child(self): | |
achild = testslide.StrictMock(AChild) | |
self.mock_constructor(sys.modules[__name__], "AChild").to_return_value(achild) | |
self.mock_callable(achild, "a_method").to_return_value(None) | |
def test_parent_and_child_no_override(self): | |
achild = testslide.StrictMock(AChild) | |
self.mock_constructor(sys.modules[__name__], "AChild").to_return_value(achild) | |
aclass = testslide.StrictMock(AClass) | |
self.mock_constructor(sys.modules[__name__], "AClass").to_return_value(aclass) | |
self.mock_callable(achild, "a_method").to_return_value(None) | |
def test_parent_and_child_override(self): | |
achild = testslide.StrictMock(AChild) | |
self.mock_constructor(sys.modules[__name__], "AChild").to_return_value(achild) | |
aclass = testslide.StrictMock(AClass) | |
self.mock_constructor(sys.modules[__name__], "AClass").to_return_value(aclass) | |
self.mock_callable(achild, "b_method").to_return_value(None) | |
def test_parent_and_child_no_override_careful_ordering(self): | |
achild = testslide.StrictMock(AChild) | |
self.mock_constructor(sys.modules[__name__], "AChild").to_return_value(achild) | |
self.mock_callable(achild, "a_method").to_return_value(None) | |
aclass = testslide.StrictMock(AClass) | |
self.mock_constructor(sys.modules[__name__], "AClass").to_return_value(aclass) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment