From 5a0932f6d3aca11ab0441063adf932ce9d587af5 Mon Sep 17 00:00:00 2001 From: Michael Lazar Date: Thu, 3 Dec 2015 00:20:20 -0800 Subject: [PATCH] PEP8 fixes. --- rtv/__main__.py | 1 + rtv/config.py | 2 ++ rtv/objects.py | 1 + rtv/subreddit.py | 2 -- rtv/terminal.py | 3 +-- tests/conftest.py | 1 - tests/test_content.py | 2 +- tests/test_oauth.py | 3 +-- tests/test_page.py | 4 ++-- tests/test_submission.py | 2 +- tests/test_subreddit.py | 1 - 11 files changed, 10 insertions(+), 12 deletions(-) diff --git a/rtv/__main__.py b/rtv/__main__.py index 551332b..44d849e 100644 --- a/rtv/__main__.py +++ b/rtv/__main__.py @@ -16,6 +16,7 @@ from .objects import curses_session from .subreddit import SubredditPage from .__version__ import __version__ + _logger = logging.getLogger(__name__) # Pycharm debugging note: diff --git a/rtv/config.py b/rtv/config.py index d34635f..b0ba012 100644 --- a/rtv/config.py +++ b/rtv/config.py @@ -4,10 +4,12 @@ from __future__ import unicode_literals import os import codecs import argparse + from six.moves import configparser from . import docs, __version__ + HOME = os.path.expanduser('~') PACKAGE = os.path.dirname(__file__) XDG_HOME = os.getenv('XDG_CONFIG_HOME', os.path.join(HOME, '.config')) diff --git a/rtv/objects.py b/rtv/objects.py index 55c5ad3..c4b419f 100644 --- a/rtv/objects.py +++ b/rtv/objects.py @@ -17,6 +17,7 @@ import requests from . import exceptions + _logger = logging.getLogger(__name__) diff --git a/rtv/subreddit.py b/rtv/subreddit.py index 8df44b0..b010ad9 100644 --- a/rtv/subreddit.py +++ b/rtv/subreddit.py @@ -4,8 +4,6 @@ from __future__ import unicode_literals import time import curses -import six - from . import docs from .content import SubredditContent from .page import Page, PageController, logged_in diff --git a/rtv/terminal.py b/rtv/terminal.py index bc9b200..5b92fb0 100644 --- a/rtv/terminal.py +++ b/rtv/terminal.py @@ -318,8 +318,7 @@ class Terminal(object): with codecs.open(fp.name, 'r', 'utf-8') as fp2: text = ''.join(line for line in fp2 if not line.startswith('#')) text = text.rstrip() - - return text + return text def text_input(self, window, allow_resize=False): """ diff --git a/tests/conftest.py b/tests/conftest.py index b694901..6632c31 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,7 +11,6 @@ import pytest from vcr import VCR from six.moves.urllib.parse import urlparse, parse_qs -from rtv.page import Page from rtv.oauth import OAuthHelper from rtv.config import Config from rtv.terminal import Terminal diff --git a/tests/test_content.py b/tests/test_content.py index dc34bb8..0c0931b 100644 --- a/tests/test_content.py +++ b/tests/test_content.py @@ -173,7 +173,7 @@ def test_content_subreddit_load_more(reddit, terminal): assert content.get(50)['type'] == 'Submission' assert len(content._submission_data) == 51 - for data in islice(content.iterate(0, 1, 70), 0, 50): + for data in islice(content.iterate(0, 1), 0, 50): assert all(k in data for k in ('object', 'n_rows', 'offset', 'type', 'index', 'title', 'split_title')) # All text should be converted to unicode by this point diff --git a/tests/test_oauth.py b/tests/test_oauth.py index 2aba076..ac072cb 100644 --- a/tests/test_oauth.py +++ b/tests/test_oauth.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import os - from tornado.web import Application from tornado.testing import AsyncHTTPTestCase from praw.errors import OAuthException @@ -155,6 +153,7 @@ def test_oauth_authorize(oauth, reddit, stdscr, refresh_token): stdscr.derwin().addstr.assert_called_with(1, 1, message) assert not oauth.config.save_refresh_token.called + def test_oauth_clear_data(oauth): oauth.config.refresh_token = 'secrettoken' diff --git a/tests/test_page.py b/tests/test_page.py index 3820348..01978d9 100644 --- a/tests/test_page.py +++ b/tests/test_page.py @@ -17,7 +17,7 @@ def test_page_logged_in(terminal): page.term = terminal @logged_in - def func(page): + def func(_): raise RuntimeError() # Logged in runs the function @@ -45,7 +45,7 @@ def test_page_unauthenticated(reddit, terminal, config, oauth): mock.patch.object(page, 'draw'): # Loop - def func(ch): + def func(_): page.active = False with mock.patch.object(page, 'controller'): page.controller.trigger = mock.MagicMock(side_effect=func) diff --git a/tests/test_submission.py b/tests/test_submission.py index 5305438..0deff58 100644 --- a/tests/test_submission.py +++ b/tests/test_submission.py @@ -80,7 +80,7 @@ def test_submission_unauthenticated(submission_page, terminal): def test_submission_open(submission_page, terminal): - # Open the selected link with the web browser + # Open the selected link with the web browser with mock.patch.object(terminal, 'open_browser'): submission_page.controller.trigger(terminal.RETURN) assert terminal.open_browser.called diff --git a/tests/test_subreddit.py b/tests/test_subreddit.py index 1fa741e..b4b3203 100644 --- a/tests/test_subreddit.py +++ b/tests/test_subreddit.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals from rtv.subreddit import SubredditPage -from rtv.content import SubmissionContent try: from unittest import mock