From 641e90320d4fdf6adb5c4c143d33a6e0d51272ad Mon Sep 17 00:00:00 2001 From: Collins-Webdev Date: Thu, 22 Feb 2024 09:53:54 +0100 Subject: [PATCH] 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. --- tests/test_hooks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 2ccac84b2..920fb4f67 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -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"