/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to tests/__init__.py

  • Committer: Curtis Hovey
  • Date: 2012-01-23 16:52:40 UTC
  • mto: This revision was merged to the branch mainline in revision 772.
  • Revision ID: sinzui.is@verizon.net-20120123165240-afawof5uuy6niivw
Moved MockMethod to a common module.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    basic_tests.addTest(loader.loadTestsFromModuleNames(
32
32
            ["%s.%s" % (__name__, tmn) for tmn in testmod_names]))
33
33
    return basic_tests
 
34
 
 
35
 
 
36
class MockMethod():
 
37
 
 
38
    @classmethod
 
39
    def bind(klass, test_instance, obj, method_name):
 
40
        original_method = getattr(obj, method_name)
 
41
        test_instance.addCleanup(setattr, obj, method_name, original_method)
 
42
        setattr(obj, method_name, klass())
 
43
 
 
44
    def __init__(self):
 
45
        self.called = False
 
46
        self.args = None
 
47
        self.kwargs = None
 
48
 
 
49
    def __call__(self, *args, **kwargs):
 
50
        self.called = True
 
51
        self.args = args
 
52
        self.kwargs = kwargs