~0x44/nova/bug838466

« back to all changes in this revision

Viewing changes to nova/test.py

  • Committer: Brian Waldon
  • Date: 2011-07-29 19:26:14 UTC
  • mto: This revision was merged to the branch mainline in revision 1364.
  • Revision ID: brian.waldon@rackspace.com-20110729192614-68rrnpbg9i27dooi
adding more on return_type in docstrings

Show diffs side-by-side

added added

removed removed

Lines of Context:
99
99
        self.flag_overrides = {}
100
100
        self.injected = []
101
101
        self._services = []
 
102
        self._monkey_patch_attach()
102
103
        self._original_flags = FLAGS.FlagValuesDict()
 
104
        rpc.ConnectionPool = rpc.Pool(max_size=FLAGS.rpc_conn_pool_size)
103
105
 
104
106
    def tearDown(self):
105
107
        """Runs after each test method to tear down test environment."""
124
126
            # Reset any overriden flags
125
127
            self.reset_flags()
126
128
 
 
129
            # Reset our monkey-patches
 
130
            rpc.Consumer.attach_to_eventlet = self.original_attach
 
131
 
127
132
            # Stop any timers
128
133
            for x in self.injected:
129
134
                try:
167
172
        self._services.append(svc)
168
173
        return svc
169
174
 
 
175
    def _monkey_patch_attach(self):
 
176
        self.original_attach = rpc.Consumer.attach_to_eventlet
 
177
 
 
178
        def _wrapped(inner_self):
 
179
            rv = self.original_attach(inner_self)
 
180
            self.injected.append(rv)
 
181
            return rv
 
182
 
 
183
        _wrapped.func_name = self.original_attach.func_name
 
184
        rpc.Consumer.attach_to_eventlet = _wrapped
 
185
 
170
186
    # Useful assertions
171
187
    def assertDictMatch(self, d1, d2, approx_equal=False, tolerance=0.001):
172
188
        """Assert two dicts are equivalent.