From bcc6f99f9c3ca4f3dffe2215ed574693c02561d0 Mon Sep 17 00:00:00 2001 From: CM Lubinski Date: Mon, 22 May 2017 17:06:07 -0700 Subject: [PATCH] Linting fixes for rtd_test module. --- prospector-more.yml | 1 - readthedocs/rtd_tests/base.py | 3 ++- readthedocs/rtd_tests/mocks/environment.py | 3 +-- readthedocs/rtd_tests/mocks/mock_api.py | 9 ++++++--- readthedocs/rtd_tests/mocks/paths.py | 1 + readthedocs/rtd_tests/utils.py | 1 + 6 files changed, 11 insertions(+), 7 deletions(-) diff --git a/prospector-more.yml b/prospector-more.yml index f51db9a550f..fa80c27334b 100644 --- a/prospector-more.yml +++ b/prospector-more.yml @@ -13,7 +13,6 @@ ignore-paths: - projects/ - redirects/ - restapi/ - - rtd_tests/ - search/ pylint: diff --git a/readthedocs/rtd_tests/base.py b/readthedocs/rtd_tests/base.py index 3f08f9f6b4a..82e3ce6902c 100644 --- a/readthedocs/rtd_tests/base.py +++ b/readthedocs/rtd_tests/base.py @@ -1,3 +1,4 @@ +"""Base classes and mixins for unit tests.""" import os import shutil import logging @@ -18,7 +19,7 @@ def setUp(self): self.original_DOCROOT = settings.DOCROOT self.cwd = os.path.dirname(__file__) self.build_dir = os.path.join(self.cwd, 'builds') - log.info("build dir: %s" % self.build_dir) + log.info("build dir: %s", self.build_dir) if not os.path.exists(self.build_dir): os.makedirs(self.build_dir) settings.DOCROOT = self.build_dir diff --git a/readthedocs/rtd_tests/mocks/environment.py b/readthedocs/rtd_tests/mocks/environment.py index 04014764fc5..06f4ce90181 100644 --- a/readthedocs/rtd_tests/mocks/environment.py +++ b/readthedocs/rtd_tests/mocks/environment.py @@ -1,7 +1,6 @@ +# pylint: disable=missing-docstring import mock -from readthedocs.doc_builder.environments import BuildEnvironment - class EnvironmentMockGroup(object): diff --git a/readthedocs/rtd_tests/mocks/mock_api.py b/readthedocs/rtd_tests/mocks/mock_api.py index 9dce73cbd84..f7d9dc1fd5f 100644 --- a/readthedocs/rtd_tests/mocks/mock_api.py +++ b/readthedocs/rtd_tests/mocks/mock_api.py @@ -1,3 +1,4 @@ +"""Mock versions of many API-related classes.""" from contextlib import contextmanager import json import mock @@ -14,6 +15,7 @@ def put(self, x=None): def mock_version(repo): + """Construct and return a class implementing the Version interface.""" class MockVersion(object): def __init__(self, x=None): pass @@ -22,6 +24,7 @@ def put(self, x=None): return x def get(self, **kwargs): + """Returns mock data to emulate real Version objects.""" # SCIENTIST DOG version = json.loads(""" { @@ -76,13 +79,13 @@ class MockApi(object): def __init__(self, repo): self.version = mock_version(repo) - def project(self, x): + def project(self, _): return ProjectData() - def build(self, x): + def build(self, _): return mock.Mock(**{'get.return_value': {'id': 123, 'state': 'triggered'}}) - def command(self, x): + def command(self, _): return mock.Mock(**{'get.return_value': {}}) diff --git a/readthedocs/rtd_tests/mocks/paths.py b/readthedocs/rtd_tests/mocks/paths.py index b156ebc8379..12bac13610b 100644 --- a/readthedocs/rtd_tests/mocks/paths.py +++ b/readthedocs/rtd_tests/mocks/paths.py @@ -1,3 +1,4 @@ +"""Context managers to patch os.path.exists calls.""" import os import re import mock diff --git a/readthedocs/rtd_tests/utils.py b/readthedocs/rtd_tests/utils.py index 0327e53c249..02c14df61de 100644 --- a/readthedocs/rtd_tests/utils.py +++ b/readthedocs/rtd_tests/utils.py @@ -1,3 +1,4 @@ +"""Utility functions for use in tests.""" import logging from os import chdir, environ, getcwd from os.path import abspath, join as pjoin