def test_docker_is_running_process_error(): with mock.patch( 'pre_commit.languages.docker.cmd_output_b', side_effect=CalledProcessError(*(None, ) * 4), ): assert docker.docker_is_running() is False
def cmd_output_mocked_pre_commit_home( *args, tempdir_factory, pre_commit_home=None, env=None, **kwargs, ): if pre_commit_home is None: pre_commit_home = tempdir_factory.get() env = env if env is not None else os.environ kwargs.setdefault('stderr', subprocess.STDOUT) # Don't want to write to the home directory env = dict(env, PRE_COMMIT_HOME=pre_commit_home) ret, out, _ = cmd_output(*args, env=env, **kwargs) return ret, out.replace('\r\n', '\n'), None skipif_cant_run_docker = pytest.mark.skipif( os.name == 'nt' or not docker_is_running(), reason="Docker isn't running or can't be accessed", ) skipif_cant_run_swift = pytest.mark.skipif( parse_shebang.find_executable('swift') is None, reason="swift isn't installed or can't be found", ) xfailif_windows_no_ruby = pytest.mark.xfail( os.name == 'nt', reason='Ruby support not yet implemented on windows.', ) xfailif_windows = pytest.mark.xfail(os.name == 'nt', reason='windows') def supports_venv(): # pragma: no cover (platform specific) try:
return True except jsonschema.exceptions.ValidationError: return False def cmd_output_mocked_pre_commit_home(*args, **kwargs): # keyword-only argument tempdir_factory = kwargs.pop('tempdir_factory') pre_commit_home = kwargs.pop('pre_commit_home', tempdir_factory.get()) # Don't want to write to the home directory env = dict(kwargs.pop('env', os.environ), PRE_COMMIT_HOME=pre_commit_home) return cmd_output(*args, env=env, **kwargs) skipif_cant_run_docker = pytest.mark.skipif( docker_is_running() is False, reason='Docker isn\'t running or can\'t be accessed') skipif_slowtests_false = pytest.mark.skipif( os.environ.get('slowtests') == 'false', reason='slowtests=false', ) skipif_cant_run_swift = pytest.mark.skipif( parse_shebang.find_executable('swift') is None, reason='swift isn\'t installed or can\'t be found') xfailif_windows_no_ruby = pytest.mark.xfail( os.name == 'nt', reason='Ruby support not yet implemented on windows.', )
def test_docker_is_running_process_error(): with mock.patch( 'pre_commit.languages.docker.cmd_output', side_effect=CalledProcessError(*(None,) * 4) ): assert docker.docker_is_running() is False
def get_head_sha(dir): with cwd(dir): return cmd_output('git', 'rev-parse', 'HEAD')[1].strip() def cmd_output_mocked_pre_commit_home(*args, **kwargs): # keyword-only argument tempdir_factory = kwargs.pop('tempdir_factory') pre_commit_home = kwargs.pop('pre_commit_home', tempdir_factory.get()) # Don't want to write to the home directory env = dict(kwargs.pop('env', os.environ), PRE_COMMIT_HOME=pre_commit_home) return cmd_output(*args, env=env, **kwargs) skipif_cant_run_docker = pytest.mark.skipif( docker_is_running() is False, reason='Docker isn\'t running or can\'t be accessed', ) skipif_slowtests_false = pytest.mark.skipif( os.environ.get('slowtests') == 'false', reason='slowtests=false', ) skipif_cant_run_swift = pytest.mark.skipif( parse_shebang.find_executable('swift') is None, reason='swift isn\'t installed or can\'t be found', ) xfailif_windows_no_ruby = pytest.mark.xfail( os.name == 'nt',
def get_resource_path(path): return os.path.join(TESTING_DIR, 'resources', path) def cmd_output_mocked_pre_commit_home(*args, **kwargs): # keyword-only argument tempdir_factory = kwargs.pop('tempdir_factory') pre_commit_home = kwargs.pop('pre_commit_home', tempdir_factory.get()) # Don't want to write to the home directory env = dict(kwargs.pop('env', os.environ), PRE_COMMIT_HOME=pre_commit_home) return cmd_output(*args, env=env, **kwargs) skipif_cant_run_docker = pytest.mark.skipif( os.name == 'nt' or not docker_is_running(), reason="Docker isn't running or can't be accessed", ) skipif_cant_run_swift = pytest.mark.skipif( parse_shebang.find_executable('swift') is None, reason='swift isn\'t installed or can\'t be found', ) xfailif_windows_no_ruby = pytest.mark.xfail( os.name == 'nt', reason='Ruby support not yet implemented on windows.', ) def broken_deep_listdir(): # pragma: no cover (platform specific)