Skip to content

Commit

Permalink
Fixing tests for #18
Browse files Browse the repository at this point in the history
  • Loading branch information
awestendorf committed Jun 8, 2014
1 parent 695093d commit 6dd8d8a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion chai/chai.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ def wrapper(self, *args, **kwargs):


class ChaiBase(unittest.TestCase):

'''
Base class for all tests
'''

# Load in the comparators
equals = Equals
almost_equals = AlmostEqual
Expand Down Expand Up @@ -164,6 +164,18 @@ def setUp(self):
def tearDown(self):
super(ChaiBase, self).tearDown()

for cls in inspect.getmro(self.__class__):
if cls.__module__.startswith('chai'):
break
mod = sys.modules[cls.__module__]

if getattr(mod,'stub',None) == self.stub:
delattr(mod, 'stub')
if getattr(mod,'expect',None) == self.expect:
delattr(mod, 'expect')
if getattr(mod,'mock',None) == self.mock:
delattr(mod, 'mock')

# Docs insist that this will be called no matter what happens in
# runTest(), so this should be a safe spot to unstub everything.
# Even with teardown at the end of test_wrapper, tear down here in
Expand Down

0 comments on commit 6dd8d8a

Please sign in to comment.