def testGetChromePathCheckExists(self): """checks that existence of explicitly CHROME_PATH is checked.""" mock_location = '/bin/ls' if getos.GetPlatform() == 'win': mock_location = 'c:\\nowhere' with mock.patch.dict('os.environ', {'CHROME_PATH': mock_location}): with mock.patch('os.path.exists') as mock_exists: chrome = getos.GetChromePath() self.assertEqual(chrome, mock_location) mock_exists.assert_called_with(chrome)
def testGetChromePathEnv(self): """honors CHROME_PATH environment.""" with mock.patch.dict('os.environ', {'CHROME_PATH': '/dummy/file'}): expect = "Invalid CHROME_PATH.*/dummy/file" if hasattr(self, 'assertRaisesRegexp'): with self.assertRaisesRegexp(getos.Error, expect): getos.GetChromePath() else: # TODO(sbc): remove this path once we switch to python2.7 everywhere self.assertRaises(getos.Error, getos.GetChromePath)