From 4fd2e964b39ecf14ffbfb65ec144742982ed0d4b Mon Sep 17 00:00:00 2001 From: Olivier Mangin Date: Thu, 22 May 2014 18:41:26 +0200 Subject: [PATCH] FIX bug in tag command (multiple line printed instead of one). --- pubs/commands/tag_cmd.py | 4 +--- tests/test_usecase.py | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/pubs/commands/tag_cmd.py b/pubs/commands/tag_cmd.py index ea1fc8f..203a5c7 100644 --- a/pubs/commands/tag_cmd.py +++ b/pubs/commands/tag_cmd.py @@ -83,9 +83,7 @@ def command(args): rp = Repository(config()) if citekeyOrTag is None: - for tag in rp.get_tags(): - ui.print_(color.dye(' '.join(rp.get_tags()), - color=color.blue)) + ui.print_(color.dye(' '.join(rp.get_tags()), color=color.blue)) else: if rp.databroker.exists(citekeyOrTag): p = rp.pull_paper(citekeyOrTag) diff --git a/tests/test_usecase.py b/tests/test_usecase.py index e5ce87a..e6d7c42 100644 --- a/tests/test_usecase.py +++ b/tests/test_usecase.py @@ -249,7 +249,7 @@ class TestUsecase(DataCommandTestCase): correct = [b'Initializing pubs in /paper_first\n', b'', b'[Page99] Page, Lawrence et al. "The PageRank Citation Ranking: Bringing Order to the Web." (1999) \n', - b'', + b'\n', b'', b'search network\n', b'[Page99] Page, Lawrence et al. "The PageRank Citation Ranking: Bringing Order to the Web." (1999) search network\n' @@ -293,6 +293,29 @@ class TestUsecase(DataCommandTestCase): print(self.fs['os'].listdir(docdir)) self.assertNotIn('turing-mind-1950.pdf', self.fs['os'].listdir(docdir)) + def test_tag_list(self): + correct = [b'Initializing pubs in /paper_first\n', + b'', + b'', + b'', + b'search network\n', + ] + + cmds = ['pubs init -p paper_first/', + 'pubs add -d data/pagerank.pdf data/pagerank.bib', + 'pubs tag', + 'pubs tag Page99 network+search', + 'pubs tag', + ] + + out = self.execute_cmds(cmds) + + def clean(s): + return set(s.strip().split(' ')) + + self.assertEqual(clean(correct[2]), clean(out[2])) + self.assertEqual(clean(correct[4]), clean(out[4])) + def test_editor_abort(self): with self.assertRaises(SystemExit): cmds = ['pubs init',