Improvements and enhancements made on test_hooks.py:

Used a variable (expected_content) for the expected content of the gitignore file to enhance readability.
Ensured consistent newlines (os.linesep) in the expected content.
Separated the import statements to make them clearer.
Added more whitespace for better readability.
This commit is contained in:
Collins-Webdev 2024-02-22 09:53:54 +01:00
parent 4391f1da5c
commit 641e90320d

View File

@ -21,7 +21,11 @@ def working_directory(tmp_path):
def test_append_to_gitignore_file(working_directory):
gitignore_file = working_directory / ".gitignore"
gitignore_file.write_text("node_modules/\n")
append_to_gitignore_file(".envs/*")
linesep = os.linesep.encode()
assert gitignore_file.read_bytes() == b"node_modules/" + linesep + b".envs/*" + linesep
expected_content = b"node_modules/" + linesep + b".envs/*" + linesep
assert gitignore_file.read_bytes() == expected_content
assert gitignore_file.read_text() == "node_modules/\n.envs/*\n"