(tmp_path, set_env_variables)
| 106 | |
| 107 | @pytest.fixture() |
| 108 | def archiver(tmp_path, set_env_variables): |
| 109 | archiver = ArchiverSetup() |
| 110 | archiver.archiver = not archiver.FORK_DEFAULT and Archiver() or None |
| 111 | archiver.tmpdir = tmp_path |
| 112 | archiver.repository_path = os.fspath(tmp_path / "repository") |
| 113 | archiver.repository_location = archiver.repository_path |
| 114 | archiver.input_path = os.fspath(tmp_path / "input") |
| 115 | archiver.output_path = os.fspath(tmp_path / "output") |
| 116 | archiver.keys_path = os.fspath(tmp_path / "keys") |
| 117 | archiver.cache_path = os.fspath(tmp_path / "cache") |
| 118 | archiver.exclude_file_path = os.fspath(tmp_path / "excludes") |
| 119 | archiver.patterns_file_path = os.fspath(tmp_path / "patterns") |
| 120 | os.environ["BORG_KEYS_DIR"] = archiver.keys_path |
| 121 | os.environ["BORG_CACHE_DIR"] = archiver.cache_path |
| 122 | os.mkdir(archiver.input_path) |
| 123 | # avoid troubles with fakeroot / FUSE: |
| 124 | os.chmod(archiver.input_path, 0o777) # nosec B103 |
| 125 | os.mkdir(archiver.output_path) |
| 126 | os.mkdir(archiver.keys_path) |
| 127 | os.mkdir(archiver.cache_path) |
| 128 | with open(archiver.exclude_file_path, "wb") as fd: |
| 129 | fd.write(b"input/file2\n# A comment line, then a blank line\n\n") |
| 130 | with open(archiver.patterns_file_path, "wb") as fd: |
| 131 | fd.write(b"+input/file_important\n- input/file*\n# A comment line, then a blank line\n\n") |
| 132 | old_wd = os.getcwd() |
| 133 | os.chdir(archiver.tmpdir) |
| 134 | yield archiver |
| 135 | os.chdir(old_wd) |
| 136 | shutil.rmtree(archiver.tmpdir, ignore_errors=True) # clean up |
| 137 | |
| 138 | |
| 139 | @pytest.fixture() |
nothing calls this directly
no test coverage detected