@patch('os.link')
def test_temporary_docker_directory_uses_copy_if_hard_link_fails(mock_link):
    mock_link.side_effect = OSError
    with tempfile.TemporaryDirectory() as td:
        os.chdir(td)
        with open('hello', 'w') as fp:
            fp.write('world')
        with utils.temporary_docker_directory(files=['hello'], name='t', metadata=None, extra_options=None, branch=None, template_dir=None, plugins_dir=None, static=[], install=[], spatialite=False, version_note=None, secret=None) as temp_docker:
            hello = os.path.join(temp_docker, 'hello')
            with open(hello) as fp:
                assert ('world' == fp.read())
            assert (1 == os.stat(hello).st_nlink)
@patch('os.link')
def test_temporary_docker_directory_uses_copy_if_hard_link_fails(mock_link):
    mock_link.side_effect = OSError
    with tempfile.TemporaryDirectory() as td:
        os.chdir(td)
        with open('hello', 'w') as fp:
            fp.write('world')
        with utils.temporary_docker_directory(files=['hello'], name='t', metadata=None, extra_options=None, branch=None, template_dir=None, plugins_dir=None, static=[], install=[], spatialite=False, version_note=None, secret=None) as temp_docker:
            hello = os.path.join(temp_docker, 'hello')
            with open(hello) as fp:
                assert ('world' == fp.read())
            assert (1 == os.stat(hello).st_nlink)