to use your own changes right away.
For development you also need [mypy](https://github.com/python/mypy), for type
-checking, [pytest](https://github.com/pytest-dev/pytest), to run tests, and
-[black](https://github.com/psf/black), for code formatting. We check tests,
-typing and code formatting in CI (see `.github/workflows`), but you can run the
+checking, and [pytest](https://github.com/pytest-dev/pytest), to run tests.
+We check tests and typing in CI (see `.github/workflows`), but you can run the
tests locally as well.
## zipapp
def format_rlimit(rlimit: int) -> str:
- limits = resource.getrlimit(rlimit)
- soft = "infinity" if limits[0] == resource.RLIM_INFINITY else str(limits[0])
- hard = "infinity" if limits[1] == resource.RLIM_INFINITY else str(limits[1])
- return f"{soft}:{hard}"
+ limits = resource.getrlimit(rlimit)
+ soft = "infinity" if limits[0] == resource.RLIM_INFINITY else str(limits[0])
+ hard = "infinity" if limits[1] == resource.RLIM_INFINITY else str(limits[1])
+ return f"{soft}:{hard}"
def nspawn_rlimit_params() -> Sequence[str]:
def test_copy_file(tmpdir: Path) -> None:
- dir_path = Path(tmpdir)
- file_1 = Path(dir_path) / "file_1.txt"
- file_2 = Path(dir_path) / "file_2.txt"
- file_1.touch()
- file_2.touch()
-
- # Copying two empty files.
- mkosi.copy_file(file_1, file_2)
- assert filecmp.cmp(file_1, file_2)
-
- # Copying content from one file.
- file_1.write_text("Testing copying content from this file to file_2.")
- mkosi.copy_file(file_1, file_2)
- assert filecmp.cmp(file_1, file_2)
-
- # Giving a non existing path/file.
- with pytest.raises(OSError):
- mkosi.copy_file("nullFilePath", file_1)
-
- # Copying when there's already content in both files.
- file_2.write_text("Testing copying content from file_1 to file_2, with previous data.")
- mkosi.copy_file(file_1, file_2)
- assert filecmp.cmp(file_1, file_2)
+ dir_path = Path(tmpdir)
+ file_1 = Path(dir_path) / "file_1.txt"
+ file_2 = Path(dir_path) / "file_2.txt"
+ file_1.touch()
+ file_2.touch()
+
+ # Copying two empty files.
+ mkosi.copy_file(file_1, file_2)
+ assert filecmp.cmp(file_1, file_2)
+
+ # Copying content from one file.
+ file_1.write_text("Testing copying content from this file to file_2.")
+ mkosi.copy_file(file_1, file_2)
+ assert filecmp.cmp(file_1, file_2)
+
+ # Giving a non existing path/file.
+ with pytest.raises(OSError):
+ mkosi.copy_file("nullFilePath", file_1)
+
+ # Copying when there's already content in both files.
+ file_2.write_text("Testing copying content from file_1 to file_2, with previous data.")
+ mkosi.copy_file(file_1, file_2)
+ assert filecmp.cmp(file_1, file_2)
def test_parse_bytes() -> None: