| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0831111 commit a32240e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,10 +15,11 @@ def _write_tree(root: Path, files: dict[str, bytes]) -> None: | |||
| 15 | 15 | ||
| 16 | 16 | def test_identical_trees_under_different_roots_hash_equal(tmp_path: Path) -> None: | |
| 17 | 17 | files = { | |
| 18 | - "src/app.py": b"print('hello') | ||
| 19 | - ", | ||
| 20 | - "readme.txt": b"notes | ||
| 21 | - ", | ||
| 18 | + "src/app.py": b"print('hello')\n", | ||
| 19 | + "src/util.py": b"HELPER = True\n", | ||
| 20 | + "assets/icon.txt": b"icon\n", | ||
| 21 | + "readme.txt": b"notes\n", | ||
| 22 | + "license.txt": b"license\n", | ||
| 22 | 23 | } | |
| 23 | 24 | a = tmp_path / "a" | |
| 24 | 25 | b = tmp_path / "b" | |
@@ -31,17 +32,13 @@ def test_identical_trees_under_different_roots_hash_equal(tmp_path: Path) -> Non | |||
| 31 | 32 | ||
| 32 | 33 | def test_changing_bytes_or_renaming_changes_hash(tmp_path: Path) -> None: | |
| 33 | 34 | root = tmp_path / "proj" | |
| 34 | - _write_tree(root, {"src/app.py": b"one | ||
| 35 | - ", "src/util.py": b"two | ||
| 36 | - "}) | ||
| 35 | + _write_tree(root, {"src/app.py": b"one\n", "src/util.py": b"two\n"}) | ||
| 37 | 36 | original = hash_tree(root) | |
| 38 | 37 | ||
| 39 | - (root / "src" / "app.py").write_bytes(b"changed | ||
| 40 | - ") | ||
| 38 | + (root / "src" / "app.py").write_bytes(b"changed\n") | ||
| 41 | 39 | assert hash_tree(root) != original | |
| 42 | 40 | ||
| 43 | - (root / "src" / "app.py").write_bytes(b"one | ||
| 44 | - ") | ||
| 41 | + (root / "src" / "app.py").write_bytes(b"one\n") | ||
| 45 | 42 | assert hash_tree(root) == original | |
| 46 | 43 | ||
| 47 | 44 | (root / "src" / "app.py").rename(root / "src" / "main.py") | |
@@ -51,8 +48,7 @@ def test_changing_bytes_or_renaming_changes_hash(tmp_path: Path) -> None: | |||
| 51 | 48 | def test_mtime_change_does_not_change_hash(tmp_path: Path) -> None: | |
| 52 | 49 | root = tmp_path / "proj" | |
| 53 | 50 | target = root / "src" / "app.py" | |
| 54 | - _write_tree(root, {"src/app.py": b"stable | ||
| 55 | - "}) | ||
| 51 | + _write_tree(root, {"src/app.py": b"stable\n"}) | ||
| 56 | 52 | original = hash_tree(root) | |
| 57 | 53 | ||
| 58 | 54 | os.utime(target, (1_700_000_000, 1_700_000_000)) | |
@@ -61,29 +57,22 @@ def test_mtime_change_does_not_change_hash(tmp_path: Path) -> None: | |||
| 61 | 57 | ||
| 62 | 58 | def test_ignored_paths_do_not_change_hash(tmp_path: Path) -> None: | |
| 63 | 59 | root = tmp_path / "proj" | |
| 64 | - _write_tree(root, {"src/app.py": b"code | ||
| 65 | - "}) | ||
| 60 | + _write_tree(root, {"src/app.py": b"code\n"}) | ||
| 66 | 61 | original = hash_tree(root) | |
| 67 | 62 | ||
| 68 | 63 | _write_tree( | |
| 69 | 64 | root, | |
| 70 | 65 | { | |
| 71 | - "build/out.bin": b"artifact | ||
| 72 | - ", | ||
| 73 | - "__pycache__/app.cpython-313.pyc": b"bytecode | ||
| 74 | - ", | ||
| 75 | - ".git/HEAD": b"ref: refs/heads/main | ||
| 76 | - ", | ||
| 77 | - "src/app.pyc": b"bytecode-file | ||
| 78 | - ", | ||
| 79 | - "src/.DS_Store": b"finder | ||
| 80 | - ", | ||
| 66 | + "build/out.bin": b"artifact\n", | ||
| 67 | + "__pycache__/app.cpython-313.pyc": b"bytecode\n", | ||
| 68 | + ".git/HEAD": b"ref: refs/heads/main\n", | ||
| 69 | + "src/app.pyc": b"bytecode-file\n", | ||
| 70 | + "src/.DS_Store": b"finder\n", | ||
| 81 | 71 | }, | |
| 82 | 72 | ) | |
| 83 | 73 | assert hash_tree(root) == original | |
| 84 | 74 | ||
| 85 | - (root / "src" / "extra.py").write_bytes(b"new | ||
| 86 | - ") | ||
| 75 | + (root / "src" / "extra.py").write_bytes(b"new\n") | ||
| 87 | 76 | assert hash_tree(root) != original | |
| 88 | 77 | ||
| 89 | 78 | ||
@@ -98,14 +87,11 @@ def test_missing_root_and_empty_directory_share_empty_digest(tmp_path: Path) -> | |||
| 98 | 87 | def test_hashing_a_single_file(tmp_path: Path) -> None: | |
| 99 | 88 | file_a = tmp_path / "a.txt" | |
| 100 | 89 | file_b = tmp_path / "other" / "a.txt" | |
| 101 | - file_a.write_bytes(b"same-bytes | ||
| 102 | - ") | ||
| 90 | + file_a.write_bytes(b"same-bytes\n") | ||
| 103 | 91 | file_b.parent.mkdir() | |
| 104 | - file_b.write_bytes(b"same-bytes | ||
| 105 | - ") | ||
| 92 | + file_b.write_bytes(b"same-bytes\n") | ||
| 106 | 93 | ||
| 107 | 94 | assert hash_tree(file_a) == hash_tree(file_b) | |
| 108 | 95 | ||
| 109 | - file_b.write_bytes(b"different | ||
| 110 | - ") | ||
| 96 | + file_b.write_bytes(b"different\n") | ||
| 111 | 97 | assert hash_tree(file_a) != hash_tree(file_b) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments