From 63dd3f2c2585ef150bdad4bddd61ccdcf152961c Mon Sep 17 00:00:00 2001 From: Andrew Grigorev Date: Thu, 21 Mar 2019 01:51:35 +0300 Subject: [PATCH] tests: fix get_gitignore_content readlines() returns entries with \n on the end --- tests/test_add.py | 2 +- tests/test_scm.py | 3 +-- tests/utils/__init__.py | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_add.py b/tests/test_add.py index e0618424c..995846d4a 100644 --- a/tests/test_add.py +++ b/tests/test_add.py @@ -475,7 +475,7 @@ class TestShouldCleanUpAfterFailedAdd(TestDvc): self.assertFalse(os.path.exists(bar_stage_file)) gitignore_content = get_gitignore_content() - self.assertFalse(any(self.BAR in line for line in gitignore_content)) + self.assertNotIn("/" + self.BAR, gitignore_content) class TestShouldNotTrackGitInternalFiles(TestDvc): diff --git a/tests/test_scm.py b/tests/test_scm.py index 2e901d9ef..885b9c613 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -64,8 +64,7 @@ class TestSCMGitSubmodule(TestGitSubmodule): class TestIgnore(TestGit): def _count_gitignore(self): lines = get_gitignore_content() - - return len(list(filter(lambda x: x.strip() == "/" + self.FOO, lines))) + return len([i for i in lines if i == "/" + self.FOO]) def test_ignore(self): git = Git(self._root_dir) diff --git a/tests/utils/__init__.py b/tests/utils/__init__.py index 39bb8be57..7f3d5e282 100644 --- a/tests/utils/__init__.py +++ b/tests/utils/__init__.py @@ -20,7 +20,7 @@ def spy(method_to_decorate): def get_gitignore_content(): with open(Git.GITIGNORE, "r") as gitignore: - return gitignore.readlines() + return gitignore.read().splitlines() def load_stage_file(path):