Test that the payload archive function works as expected.
(tmp_path: Path)
| 224 | |
| 225 | @pytest.mark.skipif(sys.platform != "win32", reason="Windows only") |
| 226 | def test_payload_archive(tmp_path: Path): |
| 227 | """Test that the payload archive function works as expected.""" |
| 228 | info = mock_info.copy() |
| 229 | payload = Payload(info) |
| 230 | |
| 231 | foo_dir = tmp_path / "foo" |
| 232 | foo_dir.mkdir() |
| 233 | |
| 234 | expected_text = "some test text" |
| 235 | hello_file = foo_dir / "hello.txt" |
| 236 | hello_file.write_text(expected_text, encoding="utf-8") |
| 237 | |
| 238 | archive_path = payload.make_archive(foo_dir, tmp_path) |
| 239 | |
| 240 | with tarfile.open(archive_path, mode="r:gz") as tar: |
| 241 | member = tar.getmember("foo/hello.txt") |
| 242 | f = tar.extractfile(member) |
| 243 | assert f is not None |
| 244 | assert f.read().decode("utf-8") == expected_text |
| 245 | |
| 246 | |
| 247 | @pytest.mark.skipif(sys.platform != "win32", reason="Windows only") |
nothing calls this directly
no test coverage detected