def test_err(self): "Should pass up the err" def raiser(*args, **kwargs): raise ValueError() with patch.object(ffs.os, 'makedirs') as pmkd: pmkd.side_effect = raiser with self.assertRaises(ValueError): ffs.mkdir_p('/ihd/lost/pairing') pmkd.assert_called_once_with('/ihd/lost/pairing')
def test_EEXIST(self): "Already exists" def raiser(*args, **kwargs): err = OSError() err.errno = errno.EEXIST raise err with patch.object(ffs.os, 'makedirs') as pmkd: pmkd.side_effect = raiser ffs.mkdir_p('/ihd/lost/pairing') pmkd.assert_called_once_with('/ihd/lost/pairing')
def test_mkdirs(self): "Simple case" with patch.object(ffs.os, 'makedirs') as pmkd: ffs.mkdir_p('/ihd/lost/pairing') pmkd.assert_called_once_with('/ihd/lost/pairing')