Esempio n. 1
0
    def test_fails(self):
        def mock_run_cmd(tokens):
            command = ' '.join(tokens)
            raise subprocess.CalledProcessError(1, command, '')

        run_cmd_swap = self.swap_with_checks(
            common, 'run_cmd', mock_run_cmd,
            expected_args=[
                (['google-chrome', '--version'],),
            ])

        with run_cmd_swap:
            with self.assertRaisesRegexp(
                subprocess.CalledProcessError,
                'Command \'google-chrome --version\' returned non-zero exit '
                'status 1'
            ):
                install_chrome_for_ci.get_chrome_version()
Esempio n. 2
0
    def test_real_example(self):
        def mock_run_cmd(unused_tokens):
            return 'Google Chrome 88.0.4324.96 '

        run_cmd_swap = self.swap_with_checks(
            common, 'run_cmd', mock_run_cmd,
            expected_args=[
                (['google-chrome', '--version'],),
            ])

        with run_cmd_swap:
            version = install_chrome_for_ci.get_chrome_version()
            self.assertEqual(version, '88.0.4324.96')