From f353b1a1bf0ce2dafaf6f13de8719700fa0b2f14 Mon Sep 17 00:00:00 2001 From: David Paz Date: Sun, 17 Jul 2022 11:55:54 +0200 Subject: [PATCH] Deal with platform line ending in tests --- tests/prepare_commit_msg_test.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/prepare_commit_msg_test.py b/tests/prepare_commit_msg_test.py index a997139..b35c4ec 100644 --- a/tests/prepare_commit_msg_test.py +++ b/tests/prepare_commit_msg_test.py @@ -1,5 +1,7 @@ from __future__ import annotations +from os import linesep + import pytest from pre_commit_hooks.prepare_commit_msg import get_current_branch @@ -58,13 +60,14 @@ TESTS = ( ), ( b'', - b'\n\nRelates: #AA-01\n\n', + f'{linesep}{linesep}Relates: #AA-01{linesep}{linesep}'.encode(), 'feature/AA-01', get_template_path('prepare_commit_msg_append.j2'), ), ( b'Initial message', - b'Initial message\n\nRelates: #AA-02\n\n', + f'Initial message{linesep}{linesep}Relates: #AA-02{linesep}{linesep}' + .encode(), 'feature/AA-02', get_template_path('prepare_commit_msg_append.j2'), ), @@ -120,15 +123,18 @@ def test_main( TESTS_TEMPLATES = ( ( - b'Initial Message\n\n# Git commented\n# output simulated', - b'[1.0.0] Initial Message\n\n# Git commented\n# output simulated', + f'Initial Message{linesep}{linesep}# Git commented{linesep}# ' + f'output simulated'.encode(), + f'[1.0.0] Initial Message{linesep}{linesep}# Git commented{linesep}# ' + f'output simulated'.encode(), 'release/1.0.0', # but this should get_template_path('prepare_commit_msg_prepend.j2'), ), ( - b'Initial Message\n# Git commented\n# output simulated', - b'Initial Message\n\nRelates: #1.0.0\n\n' - b'# Git commented\n# output simulated', + f'Initial Message{linesep}# Git commented{linesep}# output ' + f'simulated'.encode(), + f'Initial Message{linesep}{linesep}Relates: #1.0.0{linesep}{linesep}' + f'# Git commented{linesep}# output simulated'.encode(), 'release/1.0.0', # but this should get_template_path('prepare_commit_msg_append.j2'), ),