def test_gitignore_should_append_newline_to_gitignore(self, git, repo_dir): git = Git(repo_dir._root_dir) foo_ignore_pattern = "/foo" bar_ignore_pattern = "/bar" bar_path = os.path.join(repo_dir._root_dir, repo_dir.BAR) gitignore = os.path.join(repo_dir._root_dir, Git.GITIGNORE) with open(gitignore, "w") as fobj: fobj.write(foo_ignore_pattern) with open(gitignore, "r") as fobj: last = fobj.readlines()[-1] assert not last.endswith("\n") git.ignore(bar_path) with open(gitignore, "r") as fobj: lines = list(fobj.readlines()) assert len(lines) == 2 for l in lines: assert l.endswith("\n") assert lines[0].strip() == foo_ignore_pattern assert lines[1].strip() == bar_ignore_pattern
def test(self): git = Git(self._root_dir) git.ignore('foo') self.assertTrue(os.path.isfile(Git.GITIGNORE)) self.assertEqual(self._count_gitignore(), 1) git.ignore('foo') self.assertEqual(self._count_gitignore(), 1) git.ignore_remove('foo') self.assertEqual(self._count_gitignore(), 0)
def test_ignore(self): git = Git(self._root_dir) foo = os.path.join(self._root_dir, self.FOO) git.ignore(foo) self.assertTrue(os.path.isfile(Git.GITIGNORE)) self.assertEqual(self._count_gitignore(), 1) git.ignore(foo) self.assertEqual(self._count_gitignore(), 1) git.ignore_remove(foo) self.assertEqual(self._count_gitignore(), 0)
def test_ignore(self, git, repo_dir): git = Git(repo_dir._root_dir) foo = os.path.join(repo_dir._root_dir, repo_dir.FOO) target = "/" + repo_dir.FOO git.ignore(foo) assert os.path.isfile(Git.GITIGNORE) assert self._count_gitignore_entries(target) == 1 git.ignore(foo) assert os.path.isfile(Git.GITIGNORE) assert self._count_gitignore_entries(target) == 1 git.ignore_remove(foo) assert self._count_gitignore_entries(target) == 0
def test_gitignore_should_end_with_newline(self, git, repo_dir): git = Git(repo_dir._root_dir) foo = os.path.join(repo_dir._root_dir, repo_dir.FOO) bar = os.path.join(repo_dir._root_dir, repo_dir.BAR) gitignore = os.path.join(repo_dir._root_dir, Git.GITIGNORE) git.ignore(foo) with open(gitignore, "r") as fobj: last = fobj.readlines()[-1] assert last.endswith("\n") git.ignore(bar) with open(gitignore, "r") as fobj: last = fobj.readlines()[-1] assert last.endswith("\n")