@pytest.mark.docker
def test_dir_operations(tmp_path: Path):
    with DockerContainer(DEFAULT_IMAGE) as container:
        test_binary_data = bytes((random.randrange(256) for _ in range(1000)))
        original_test_file = (tmp_path / 'test.dat')
        original_test_file.write_bytes(test_binary_data)
        test_dir = (tmp_path / 'test_dir')
        test_dir.mkdir()
        test_file = (test_dir / 'test.dat')
        shutil.copyfile(original_test_file, test_file)
        dst_dir = PurePath('/tmp/test_dir')
        dst_file = (dst_dir / 'test.dat')
        container.copy_into(test_dir, dst_dir)
        output = container.call(['cat', dst_file], capture_output=True)
        assert (test_binary_data == bytes(output, encoding='utf8', errors='surrogateescape'))
        assert (container.glob(dst_dir, '*.dat') == [dst_file])
        new_test_dir = (tmp_path / 'test_dir_new')
        container.copy_out(dst_dir, new_test_dir)
        assert (test_binary_data == (new_test_dir / 'test.dat').read_bytes())
@pytest.mark.docker
def test_dir_operations(tmp_path: Path):
    with DockerContainer(DEFAULT_IMAGE) as container:
        test_binary_data = bytes((random.randrange(256) for _ in range(1000)))
        original_test_file = (tmp_path / 'test.dat')
        original_test_file.write_bytes(test_binary_data)
        test_dir = (tmp_path / 'test_dir')
        test_dir.mkdir()
        test_file = (test_dir / 'test.dat')
        shutil.copyfile(original_test_file, test_file)
        dst_dir = PurePath('/tmp/test_dir')
        dst_file = (dst_dir / 'test.dat')
        container.copy_into(test_dir, dst_dir)
        output = container.call(['cat', dst_file], capture_output=True)
        assert (test_binary_data == bytes(output, encoding='utf8', errors='surrogateescape'))
        assert (container.glob(dst_dir, '*.dat') == [dst_file])
        new_test_dir = (tmp_path / 'test_dir_new')
        container.copy_out(dst_dir, new_test_dir)
        assert (test_binary_data == (new_test_dir / 'test.dat').read_bytes())