Ubuntu Pastebin

Paste from rr at Wed, 26 Apr 2017 20:37:17 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
   def add_patch(self, target, attr):
        """Patches specified target object and sets it as attr on test
        instance also schedules cleanup"""
        m = mock.patch(target, autospec=True)
        p = m.start()
        self.addCleanup(m.stop)
        setattr(self, attr, p)

class TestCurtinVersion(CurtinVersionBase):

    def setUp(self):
        self.add_patch('subprocess.check_output', 'mock_subp')
        self.add_patch('os.path', 'mock_path')


then in test methods.  self.mock_path.FOO
Download as text