FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test(project): repair fingerprint fixtures and expand ordering test · pythonnative/pythonnative@a32240e · GitHub

Repository navigation

Commit a32240e

Browse files
committed
test(project): repair fingerprint fixtures and expand ordering test
1 parent 0831111 commit a32240e

1 file changed

Lines changed: 19 additions & 33 deletions

File tree

‎tests/project/test_fingerprint.py‎

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ def _write_tree(root: Path, files: dict[str, bytes]) -> None:
1515

1616
def test_identical_trees_under_different_roots_hash_equal(tmp_path: Path) -> None:
1717
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",
2223
}
2324
a = tmp_path / "a"
2425
b = tmp_path / "b"
@@ -31,17 +32,13 @@ def test_identical_trees_under_different_roots_hash_equal(tmp_path: Path) -> Non
3132

3233
def test_changing_bytes_or_renaming_changes_hash(tmp_path: Path) -> None:
3334
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"})
3736
original = hash_tree(root)
3837

39-
(root / "src" / "app.py").write_bytes(b"changed
40-
")
38+
(root / "src" / "app.py").write_bytes(b"changed\n")
4139
assert hash_tree(root) != original
4240

43-
(root / "src" / "app.py").write_bytes(b"one
44-
")
41+
(root / "src" / "app.py").write_bytes(b"one\n")
4542
assert hash_tree(root) == original
4643

4744
(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:
5148
def test_mtime_change_does_not_change_hash(tmp_path: Path) -> None:
5249
root = tmp_path / "proj"
5350
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"})
5652
original = hash_tree(root)
5753

5854
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:
6157

6258
def test_ignored_paths_do_not_change_hash(tmp_path: Path) -> None:
6359
root = tmp_path / "proj"
64-
_write_tree(root, {"src/app.py": b"code
65-
"})
60+
_write_tree(root, {"src/app.py": b"code\n"})
6661
original = hash_tree(root)
6762

6863
_write_tree(
6964
root,
7065
{
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",
8171
},
8272
)
8373
assert hash_tree(root) == original
8474

85-
(root / "src" / "extra.py").write_bytes(b"new
86-
")
75+
(root / "src" / "extra.py").write_bytes(b"new\n")
8776
assert hash_tree(root) != original
8877

8978

@@ -98,14 +87,11 @@ def test_missing_root_and_empty_directory_share_empty_digest(tmp_path: Path) ->
9887
def test_hashing_a_single_file(tmp_path: Path) -> None:
9988
file_a = tmp_path / "a.txt"
10089
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")
10391
file_b.parent.mkdir()
104-
file_b.write_bytes(b"same-bytes
105-
")
92+
file_b.write_bytes(b"same-bytes\n")
10693

10794
assert hash_tree(file_a) == hash_tree(file_b)
10895

109-
file_b.write_bytes(b"different
110-
")
96+
file_b.write_bytes(b"different\n")
11197
assert hash_tree(file_a) != hash_tree(file_b)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL