Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
More pylint checks and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jmbowman committed Jun 22, 2016
1 parent dfc44b2 commit 85d613d
Show file tree
Hide file tree
Showing 33 changed files with 300 additions and 128 deletions.
2 changes: 2 additions & 0 deletions bok_choy/__init__.py
@@ -1,6 +1,8 @@
"""
bok-choy is a UI-level acceptance test framework
"""
from __future__ import absolute_import

import logging

# Suppress noisy loggers
Expand Down
1 change: 1 addition & 0 deletions bok_choy/a11y/__init__.py
@@ -1,6 +1,7 @@
"""
Accessibility audit feature
"""
from __future__ import absolute_import

from .a11y_audit import A11yAudit, AccessibilityError
from .axe_core_ruleset import AxeCoreAudit, AxeCoreAuditConfig
Expand Down
2 changes: 2 additions & 0 deletions bok_choy/a11y/a11y_audit.py
@@ -1,6 +1,8 @@
"""
Interface for running accessibility audits on a PageObject.
"""
from __future__ import absolute_import

import os
from abc import abstractmethod, abstractproperty, ABCMeta
import six
Expand Down
2 changes: 2 additions & 0 deletions bok_choy/a11y/axe_core_ruleset.py
Expand Up @@ -2,6 +2,8 @@
Interface for using the axe-core ruleset.
See: https://github.com/dequelabs/axe-core
"""
from __future__ import absolute_import

import json
import os

Expand Down
2 changes: 2 additions & 0 deletions bok_choy/a11y/axs_ruleset.py
Expand Up @@ -2,6 +2,8 @@
Interface for using the google accessibility ruleset.
See: https://github.com/GoogleChrome/accessibility-developer-tools
"""
from __future__ import absolute_import

import logging
import os

Expand Down
2 changes: 2 additions & 0 deletions bok_choy/browser.py
Expand Up @@ -2,6 +2,8 @@
Use environment variables to configure Selenium remote WebDriver.
For use with SauceLabs (via SauceConnect) or local browsers.
"""
from __future__ import absolute_import

import os
import logging
from json import dumps
Expand Down
2 changes: 2 additions & 0 deletions bok_choy/javascript.py
@@ -1,6 +1,8 @@
"""
Helpers for dealing with JavaScript synchronization issues.
"""
from __future__ import absolute_import

import functools
import json
from textwrap import dedent
Expand Down
2 changes: 2 additions & 0 deletions bok_choy/page_object.py
Expand Up @@ -2,6 +2,8 @@
Base implementation of the Page Object pattern.
See https://code.google.com/p/selenium/wiki/PageObjects
"""
from __future__ import absolute_import

from abc import ABCMeta, abstractmethod, abstractproperty
from collections import defaultdict
from functools import wraps
Expand Down
2 changes: 2 additions & 0 deletions bok_choy/promise.py
Expand Up @@ -2,6 +2,8 @@
Variation on the "promise" design pattern.
Promises make it easier to handle asynchronous operations correctly.
"""
from __future__ import absolute_import

import time
import logging

Expand Down
1 change: 1 addition & 0 deletions bok_choy/query.py
@@ -1,6 +1,7 @@
"""
Tools for interacting with the DOM inside a browser.
"""
from __future__ import absolute_import

from copy import copy
from collections import Sequence
Expand Down
6 changes: 4 additions & 2 deletions bok_choy/web_app_test.py
@@ -1,24 +1,26 @@
"""
Base class for testing a web application.
"""
from __future__ import absolute_import

from abc import ABCMeta
import sys
from unittest import SkipTest
from uuid import uuid4

from needle.cases import NeedleTestCase, import_from_string
import six

from .browser import browser, save_screenshot, save_driver_logs, save_source


@six.add_metaclass(ABCMeta)
class WebAppTest(NeedleTestCase):

"""
Base class for testing a web application.
"""

__metaclass__ = ABCMeta

# Execute tests in parallel!
_multiprocess_can_split_ = True

Expand Down
53 changes: 42 additions & 11 deletions pylintrc
Expand Up @@ -2,17 +2,48 @@
# ** DO NOT EDIT THIS FILE **
# ***************************
#
# It is generated by:
# $ edx_lint write pylintrc
# This file was generated by edx-lint: http://github.com/edx.edx-lint
#
# If you want to change this file, you have two choices, depending on whether
# you want to make a local change that applies only to this repo, or whether
# you want to make a central change that applies to all repos using edx-lint.
#
# LOCAL CHANGE:
#
# 1. Edit the local pylintrc_tweaks file to add changes just to this
# repo's file.
#
# 2. Run:
#
# $ edx_lint write pylintrc
#
# 3. This will modify the local file. Submit a pull request to get it
# checked in so that others will benefit.
#
#
# STAY AWAY!
# CENTRAL CHANGE:
#
# 1. Edit the pylintrc file in the edx-lint repo at
# https://github.com/edx/edx-lint/blob/master/edx_lint/files/pylintrc
#
# 2. Make a new version of edx_lint, which involves the usual steps of
# incrementing the version number, submitting and reviewing a pull
# request, and updating the edx-lint version reference in this repo.
#
# 3. Install the newer version of edx-lint.
#
# 4. Run:
#
# $ edx_lint write pylintrc
#
# 5. This will modify the local file. Submit a pull request to get it
# checked in so that others will benefit.
#
#
#
#
#
# STAY AWAY FROM THIS FILE!
#
#
#
Expand All @@ -22,21 +53,22 @@
#
# ------------------------------
[MASTER]
profile = no
ignore =
persistent = yes
load-plugins = edx_lint.pylint

[MESSAGES CONTROL]
disable =
locally-disabled,
locally-enabled,
too-few-public-methods,
bad-builtin,
star-args,
abstract-class-not-used,
abstract-class-little-used,
no-init,
fixme,
logging-format-interpolation,
too-many-lines,
no-self-use,
too-many-ancestors,
Expand All @@ -47,22 +79,21 @@ disable =
too-many-branches,
too-many-arguments,
too-many-locals,
unused-wildcard-import,
duplicate-code

[REPORTS]
output-format = text
files-output = no
reports = no
evaluation = 10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10)
comment = no

[BASIC]
required-attributes =
bad-functions = map,filter,apply,input
module-rgx = (([a-z_][a-z0-9_]*)|([A-Z][a-zA-Z0-9]+))$
const-rgx = (([A-Z_][A-Z0-9_]*)|(__.*__)|log|urlpatterns)$
class-rgx = [A-Z_][a-zA-Z0-9]+$
function-rgx = ([a-z_][a-z0-9_]{2,30}|test_[a-z0-9_]+)$
function-rgx = ([a-z_][a-z0-9_]{2,40}|test_[a-z0-9_]+)$
method-rgx = ([a-z_][a-z0-9_]{2,40}|setUp|set[Uu]pClass|tearDown|tear[Dd]ownClass|assert[A-Z]\w*|maxDiff|test_[a-z0-9_]+)$
attr-rgx = [a-z_][a-z0-9_]{2,30}$
argument-rgx = [a-z_][a-z0-9_]{2,30}$
Expand All @@ -71,7 +102,7 @@ class-attribute-rgx = ([A-Za-z_][A-Za-z0-9_]{2,30}|(__.*__))$
inlinevar-rgx = [A-Za-z_][A-Za-z0-9_]*$
good-names = f,i,j,k,db,ex,Run,_,__
bad-names = foo,bar,baz,toto,tutu,tata
no-docstring-rgx = __.*__|test_.+|setUp|tearDown
no-docstring-rgx = __.*__$|test_.+|setUp$|setUpClass$|tearDown$|tearDownClass$|Meta$
docstring-min-length = -1

[FORMAT]
Expand All @@ -94,7 +125,7 @@ ignore-imports = no
[TYPECHECK]
ignore-mixin-members = yes
ignored-classes = SQLObject
zope = no
unsafe-load-any-extension = yes
generated-members =
REQUEST,
acl_users,
Expand All @@ -117,14 +148,14 @@ generated-members =
name,
revision,
_meta,
ignored-modules = six.moves

[VARIABLES]
init-import = no
dummy-variables-rgx = _|dummy|unused|.*_unused
additional-builtins =

[CLASSES]
ignore-iface-methods = isImplementedBy,deferred,extends,names,namesAndDescriptions,queryDescriptionFor,getBases,getDescriptionFor,getDoc,getName,getTaggedValue,getTaggedValueTags,isEqualOrExtendedBy,setTaggedValue,isImplementedByInstancesOf,adaptWith,is_implemented_by
defining-attr-methods = __init__,__new__,setUp
valid-classmethod-first-arg = cls
valid-metaclass-classmethod-first-arg = mcs
Expand All @@ -150,4 +181,4 @@ int-import-graph =
[EXCEPTIONS]
overgeneral-exceptions = Exception

# 83766d9270122cf771ec25aea5d1de31bf3f5433
# 48d621494d47dc6153299ac76757cd666f4c1818
5 changes: 5 additions & 0 deletions pylintrc_tweaks
@@ -0,0 +1,5 @@
[MASTER]
load-plugins = edx_lint.pylint

[TYPECHECK]
ignored-modules=six.moves
9 changes: 7 additions & 2 deletions tests/conftest.py
@@ -1,4 +1,8 @@
from __future__ import unicode_literals
"""
pytest configuration and fixtures
"""

from __future__ import absolute_import, unicode_literals

from multiprocessing import Process
import os
Expand All @@ -10,7 +14,7 @@
REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))


def pytest_configure(config):
def pytest_configure(config): # pylint: disable=unused-argument
"""Set some environment variables to default values if absent"""
if 'SCREENSHOT_DIR' not in os.environ:
os.environ['SCREENSHOT_DIR'] = REPO_ROOT
Expand All @@ -26,6 +30,7 @@ def test_server(request):
server = Process(target=start_test_server)

def fin():
"""Stop the test server"""
server.terminate()
request.addfinalizer(fin)
server.start()
19 changes: 13 additions & 6 deletions tests/http_server.py
Expand Up @@ -3,21 +3,24 @@
a configurable delay that can be passed as a
query parameter in a GET request.
"""
from __future__ import absolute_import, print_function

import os
import sys
from time import sleep
import six
from six.moves import BaseHTTPServer
from six.moves.SimpleHTTPServer import SimpleHTTPRequestHandler
from six.moves.urllib_parse import urlparse, parse_qs
from six.moves import BaseHTTPServer


class DelayedRequestHandler(SimpleHTTPRequestHandler):
"""
Request handler with a configurable delay for testing
"""
def do_GET(self):
def __init__(self, *args, **kwargs):
SimpleHTTPRequestHandler.__init__(self, *args, **kwargs)
self.path = None

def do_GET(self): # pylint: disable=invalid-name
"""
Check parameters to see if a delay was specified.
If so then wait and then serve the GET request.
Expand All @@ -41,15 +44,19 @@ def do_GET(self):


def main():
"""
Start an HTTP server on the port specified in the SERVER_PORT
environment variable. Serves the files located under ``tests/site``.
"""
handler_class = DelayedRequestHandler
handler_class.protocol_version = "HTTP/1.0"
server_class = BaseHTTPServer.HTTPServer
port = int(os.environ['SERVER_PORT'])
server_address = ('', port)
httpd = server_class(server_address, handler_class)

sa = httpd.socket.getsockname()
print("Serving HTTP on", sa[0], "port", sa[1], "...")
address = httpd.socket.getsockname()
print("Serving HTTP on", address[0], "port", address[1], "...")
httpd.serve_forever()

if __name__ == "__main__":
Expand Down

0 comments on commit 85d613d

Please sign in to comment.