Fix up variable names instead of disabling pylint naming rule. Makes variables able to be a single letter in pylintrc

This commit is contained in:
jaypipes@gmail.com
2010-08-09 12:37:15 -04:00
parent 6ef8b2d7fd
commit e2f5dd9968
2 changed files with 20 additions and 15 deletions

View File

@@ -1,5 +1,4 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # vim: tabstop=4 shiftwidth=4 softtabstop=4
# pylint: disable-msg=C0103
# Copyright 2010 United States Government as represented by the # Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration. # Administrator of the National Aeronautics and Space Administration.
@@ -54,7 +53,7 @@ def skip_if_fake(func):
class TrialTestCase(unittest.TestCase): class TrialTestCase(unittest.TestCase):
"""Test case base class for all unit tests""" """Test case base class for all unit tests"""
def setUp(self): def setUp(self): # pylint: disable-msg=C0103
"""Run before each test method to initialize test environment""" """Run before each test method to initialize test environment"""
super(TrialTestCase, self).setUp() super(TrialTestCase, self).setUp()
@@ -64,7 +63,7 @@ class TrialTestCase(unittest.TestCase):
self.stubs = stubout.StubOutForTesting() self.stubs = stubout.StubOutForTesting()
self.flag_overrides = {} self.flag_overrides = {}
def tearDown(self): def tearDown(self): # pylint: disable-msg=C0103
"""Runs after each test method to finalize/tear down test environment""" """Runs after each test method to finalize/tear down test environment"""
super(TrialTestCase, self).tearDown() super(TrialTestCase, self).tearDown()
self.reset_flags() self.reset_flags()
@@ -96,7 +95,7 @@ class TrialTestCase(unittest.TestCase):
class BaseTestCase(TrialTestCase): class BaseTestCase(TrialTestCase):
# TODO(jaypipes): Can this be moved into the TrialTestCase class? # TODO(jaypipes): Can this be moved into the TrialTestCase class?
"""Base test case class for all unit tests.""" """Base test case class for all unit tests."""
def setUp(self): # pylint: disable-msg=W0511 def setUp(self): # pylint: disable-msg=C0103
"""Run before each test method to initialize test environment""" """Run before each test method to initialize test environment"""
super(BaseTestCase, self).setUp() super(BaseTestCase, self).setUp()
# TODO(termie): we could possibly keep a more global registry of # TODO(termie): we could possibly keep a more global registry of
@@ -108,7 +107,7 @@ class BaseTestCase(TrialTestCase):
self._done_waiting = False self._done_waiting = False
self._timed_out = False self._timed_out = False
def tearDown(self): def tearDown(self):# pylint: disable-msg=C0103
"""Runs after each test method to finalize/tear down test environment""" """Runs after each test method to finalize/tear down test environment"""
super(BaseTestCase, self).tearDown() super(BaseTestCase, self).tearDown()
for x in self.injected: for x in self.injected:
@@ -116,7 +115,7 @@ class BaseTestCase(TrialTestCase):
if FLAGS.fake_rabbit: if FLAGS.fake_rabbit:
fakerabbit.reset_all() fakerabbit.reset_all()
def _waitForTest(self, timeout=60): def _wait_for_test(self, timeout=60):
""" Push the ioloop along to wait for our test to complete. """ """ Push the ioloop along to wait for our test to complete. """
self._waiting = self.ioloop.add_timeout(time.time() + timeout, self._waiting = self.ioloop.add_timeout(time.time() + timeout,
self._timeout) self._timeout)
@@ -146,7 +145,7 @@ class BaseTestCase(TrialTestCase):
self._waiting = None self._waiting = None
self._done_waiting = True self._done_waiting = True
def _maybeInlineCallbacks(self, f): def _maybe_inline_callbacks(self, func):
""" If we're doing async calls in our tests, wait on them. """ If we're doing async calls in our tests, wait on them.
This is probably the most complicated hunk of code we have so far. This is probably the most complicated hunk of code we have so far.
@@ -169,7 +168,7 @@ class BaseTestCase(TrialTestCase):
d.addCallback(_describe) d.addCallback(_describe)
d.addCallback(_checkDescribe) d.addCallback(_checkDescribe)
d.addCallback(lambda x: self._done()) d.addCallback(lambda x: self._done())
self._waitForTest() self._wait_for_test()
Example (inline callbacks! yay!): Example (inline callbacks! yay!):
@@ -183,16 +182,16 @@ class BaseTestCase(TrialTestCase):
# TODO(termie): this can be a wrapper function instead and # TODO(termie): this can be a wrapper function instead and
# and we can make a metaclass so that we don't # and we can make a metaclass so that we don't
# have to copy all that "run" code below. # have to copy all that "run" code below.
g = f() g = func()
if not hasattr(g, 'send'): if not hasattr(g, 'send'):
self._done() self._done()
return defer.succeed(g) return defer.succeed(g)
inlined = defer.inlineCallbacks(f) inlined = defer.inlineCallbacks(func)
d = inlined() d = inlined()
return d return d
def _catchExceptions(self, result, failure): def _catch_exceptions(self, result, failure):
"""Catches all exceptions and handles keyboard interrupts.""" """Catches all exceptions and handles keyboard interrupts."""
exc = (failure.type, failure.value, failure.getTracebackObject()) exc = (failure.type, failure.value, failure.getTracebackObject())
if isinstance(failure.value, self.failureException): if isinstance(failure.value, self.failureException):
@@ -213,7 +212,7 @@ class BaseTestCase(TrialTestCase):
"""Runs the test case""" """Runs the test case"""
result.startTest(self) result.startTest(self)
testMethod = getattr(self, self._testMethodName) test_method = getattr(self, self._testMethodName)
try: try:
try: try:
self.setUp() self.setUp()
@@ -225,10 +224,10 @@ class BaseTestCase(TrialTestCase):
ok = False ok = False
try: try:
d = self._maybeInlineCallbacks(testMethod) d = self._maybe_inline_callbacks(test_method)
d.addErrback(lambda x: self._catchExceptions(result, x)) d.addErrback(lambda x: self._catch_exceptions(result, x))
d.addBoth(lambda x: self._done() and x) d.addBoth(lambda x: self._done() and x)
self._waitForTest() self._wait_for_test()
ok = True ok = True
except self.failureException: except self.failureException:
result.addFailure(self, sys.exc_info()) result.addFailure(self, sys.exc_info())

View File

@@ -1,4 +1,10 @@
[Basic] [Basic]
# Variables can be 1 to 31 characters long, with
# lowercase and underscores
variable-rgx=[a-z_][a-z0-9_]{0,30}$
# Method names should be at least 3 characters long
# and be lowecased with underscores
method-rgx=[a-z_][a-z0-9_]{2,50}$ method-rgx=[a-z_][a-z0-9_]{2,50}$
[MESSAGES CONTROL] [MESSAGES CONTROL]