Created
June 24, 2015 14:23
-
-
Save avian2/3c7522e5ff55fd17ee44 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
### Hettinger's way | |
# robot.py | |
class Robot(object): | |
def move(self): | |
print('Movement') | |
class CleaningRobot(Robot): | |
def clean(self): | |
for i in range(3): | |
super().move() | |
# test.py | |
class MockBot(Robot): | |
def move(self): | |
print('Simulated movement') | |
class MockedCleaningRobot(CleaningRobot, MockBot): | |
pass | |
MockedCleaningRobot().clean() | |
### How I usually do it | |
# robot.py | |
class CleaningRobot(object): | |
def clean(self): | |
for i in range(3): | |
self.move() | |
def move(self): | |
print('Movement') | |
# test.py | |
class MockedCleaningRobot(CleaningRobot): | |
def move(self): | |
print('Simulated movement') | |
MockedCleaningRobot().clean() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment