diff --git a/tests/test_subreddit.py b/tests/test_subreddit.py index 1e4f8d5..99a5388 100644 --- a/tests/test_subreddit.py +++ b/tests/test_subreddit.py @@ -736,9 +736,9 @@ def test_subreddit_page__create_format(terminal, subreddit_page): data = { 'index': '1', 'title': 'Without saying what the category is, what are your top five?', - 'score': '144655 pts', + 'score': '144655', 'likes': True, - 'comments': '26584 comments', + 'comments': '26584', 'created': '10month', 'edited': '(edit 5month)', 'author': 'reddit_user', @@ -858,7 +858,8 @@ def test_subreddit_page__create_format(terminal, subreddit_page): assert format_list[6][0](data) == expected_str['%n'] + ' ' else: # General case - assert format_list[1][0](data) == expected_str[fmt] + assert format_list[1][0](data) == expected_str[fmt], \ + "On specifier {0}".format(fmt) format_list[1][1](data) terminal.attr.assert_called_with(expected_attr[fmt]) diff --git a/tuir/content.py b/tuir/content.py index e1b984f..4f36413 100644 --- a/tuir/content.py +++ b/tuir/content.py @@ -152,7 +152,7 @@ class Content(object): data['body'] = comment.body data['html'] = comment.body_html data['created'] = cls.humanize_timestamp(comment.created_utc) - data['score'] = '{0} pts'.format( + data['score'] = '{0}'.format( '-' if comment.score_hidden else comment.score) data['author'] = name data['is_author'] = (name == sub_name) @@ -187,7 +187,7 @@ class Content(object): data['nsfw'] = comment.over_18 data['subreddit'] = six.text_type(comment.subreddit) data['url_type'] = 'selfpost' - data['score'] = '{0} pts'.format( + data['score'] = '{0}'.format( '-' if comment.score_hidden else comment.score) data['likes'] = comment.likes data['created'] = cls.humanize_timestamp(comment.created_utc) @@ -233,8 +233,8 @@ class Content(object): data['html'] = sub.selftext_html or '' data['created'] = cls.humanize_timestamp(sub.created_utc) data['created_long'] = cls.humanize_timestamp(sub.created_utc, True) - data['comments'] = '{0} comments'.format(sub.num_comments) - data['score'] = '{0} pts'.format('-' if sub.hide_score else sub.score) + data['comments'] = sub.num_comments + data['score'] = '{0}'.format('-' if sub.hide_score else sub.score) data['author'] = name data['permalink'] = sub.permalink data['subreddit'] = six.text_type(sub.subreddit) diff --git a/tuir/submission_page.py b/tuir/submission_page.py index 6f5db44..d97a467 100644 --- a/tuir/submission_page.py +++ b/tuir/submission_page.py @@ -284,7 +284,7 @@ class SubmissionPage(Page): attr = self.term.attr('Score') self.term.add_space(win) - self.term.add_line(win, '{score}'.format(**data), attr=attr) + self.term.add_line(win, '{score} pts'.format(**data), attr=attr) attr = self.term.attr('Created') self.term.add_space(win) @@ -385,7 +385,7 @@ class SubmissionPage(Page): row = len(data['split_title']) + len(split_text) + 3 attr = self.term.attr('Score') - self.term.add_line(win, '{score}'.format(**data), row, 1, attr=attr) + self.term.add_line(win, '{score} pts'.format(**data), row, 1, attr=attr) arrow, attr = self.term.get_arrow(data['likes']) self.term.add_space(win) @@ -393,7 +393,7 @@ class SubmissionPage(Page): attr = self.term.attr('CommentCount') self.term.add_space(win) - self.term.add_line(win, '{comments}'.format(**data), attr=attr) + self.term.add_line(win, '{comments} comments'.format(**data), attr=attr) if data['gold']: attr = self.term.attr('Gold') diff --git a/tuir/subreddit_page.py b/tuir/subreddit_page.py index 9bb5f4c..b7953c9 100644 --- a/tuir/subreddit_page.py +++ b/tuir/subreddit_page.py @@ -316,7 +316,7 @@ class SubredditPage(Page): lambda data: self._submission_attr(data), first)) elif item == "%s": # Need to cut off the characters that aren't the score number - form.append((lambda data: data['score'][:-4], + form.append((lambda data: str(data['score']), lambda data: self.term.attr('Score'), first)) elif item == "%v": # This isn't great, self.term.get_arrow gets called twice @@ -324,7 +324,7 @@ class SubredditPage(Page): lambda data: self.term.get_arrow(data['likes'])[1], first)) elif item == "%c": form.append(( - lambda data: '{0}'.format(data['comments'][:-9]) + lambda data: data['comments'] if data['comments'] else None, # Don't try to subscript null items lambda data: self.term.attr('CommentCount'), first)) @@ -483,7 +483,7 @@ class SubredditPage(Page): if row in valid_rows: attr = self.term.attr('Score') - self.term.add_line(win, '{score}'.format(**data), row, 1, attr) + self.term.add_line(win, '{score} pts'.format(**data), row, 1, attr) self.term.add_space(win) arrow, attr = self.term.get_arrow(data['likes']) @@ -500,7 +500,7 @@ class SubredditPage(Page): attr = self.term.attr('CommentCount') self.term.add_space(win) - self.term.add_line(win, '{comments}'.format(**data), attr=attr) + self.term.add_line(win, '{comments} comments'.format(**data), attr=attr) if data['saved']: attr = self.term.attr('Saved')