Hi,

In a.py we have a function:
def _change_file_mode(filepath):
utils.execute('chmod', '600', filepath, run_as_root=True)

In test_xxx.py, there is a testclass:
class xxxxDriverTestCase(test.TestCase):
def test_a(self)
    ...
    Call a. _change_file_mode
...

def test_b(self)
    ...
    Call a. _change_file_mode
...

I have tried to mock like mock out function _change_file_mode like this:
@mock.patch.object(a, '_change_file_mode', return_value=None)
class xxxxDriverTestCase(test.TestCase):
def test_a(self)
    ...
    Call a. _change_file_mode
...

def test_b(self)
    ...
    Call a. _change_file_mode
...

But the mock takes no effort, the real function _change_file_mode is still 
executed.
So how to make a mock effactive for all method of a testclass?
Thanks for any input!

Wilson Liu
__________________________________________________________________________
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: [email protected]?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev

Reply via email to