David James has posted comments on this change.
Change subject: Add tests for deploy_chrome and remote_access.
......................................................................
Patch Set 15: (21 inline comments)
Generally, like the approach
....................................................
File lib/commandline_unittest.py
Line 9: import optparse
W0611: 9: Unused import optparse
Line 67: self.assertRaisesRegexp(SystemExit, '2', self._RunGSPathTestCase,
This is new in Python 2.7:
E1101: 67:GSPathTest.testInvalidPath: Instance of 'GSPathTest' has no 'assertRaisesRegexp' member
....................................................
File lib/cros_build_lib_unittest.py
Line 36: def __init__(self, tempdir):
Please add docstrings for everything with descriptions of their arguments etc.
Line 46: result.output, result.error)
indentation
....................................................
File lib/cros_test_lib.py
Line 12: import contextlib
Lots of warnings / errors:
W0232:118:Comparator: Class has no __init__ method
W0703:146:In.equals: Catch "Exception"
W0703:168:Regex.equals: Catch "Exception"
W0703:190:ListRegex.equals: Catch "Exception"
E1101:189:ListRegex.equals: Instance of 'ListRegex' has no 'ProcessRhs' member
W0232:194:IgnoreArg: Class has no __init__ method
W0613:215:MockedCallResults.AddResultForParams: Unused argument 'side_effect'
W0612:230:MockedCallResults.AddResultForParams.filter_fn: Unused variable 'filter_fn'
W0611: 12: Unused import contextlib
Line 111: def predicate_split(func, iterable):
This should probably be private, also, naming convention is strange -- Wouldn't we call this PredicateSplit or _PredicateSplit ?
Line 118: class Comparator:
This should inherit from object, right?
Line 121: def equals(self, rhs):
Isn't our naming standard to use capital 'e' for these?
Line 125: def __eq__(self, rhs):
Can we avoid using __eq__ / __ne__ at all here?
The following is confusing:
>>> x = cros_test_lib.In('foo')
>>> y = cros_test_lib.IgnoreArg()
>>> x == y
False
>>> y == x
True
Line 146: except Exception:
Can we check the type of rhs instead?
Line 168: except Exception:
Please don't catch exception :)
Line 172: s = '<regular expression \'%s\'' % self.regex.pattern
Can you use %r instead of \'%s\' ? :)
Line 213: return pv if isinstance(pv, tuple) else (pv,)
Why are we converting everything into tuples?
Line 224: Arguments:
Docs for the arguments? Please also document what types the arguments should be.
Line 234: dup, filtered = predicate_split(lambda p_r: p_r[0] == params,
This duplicate replacement doesn't work consistently for me, likely because of the difference between x==y and y==x.
>>> results.AddResultForParams(cros_test_lib.In('baz'), 'baz')
>>> results.AddResultForParams(['foo', 'bar'], 'baz')
>>> results.AddResultForParams(ignore, 'ignored')
>>> results.mocked_cmds
[(((<sequence or map containing 'baz'>,), None), 'baz'), (((<IgnoreArg>,), None), 'ignored')]
Unit tests?
Line 242: def LookupResult(self, pv, hook_pv, hook_kv, kv=None):
Docstring ?
Line 314: self.results = MockedCallResults(self.ATTRS[0])
Any reason why 'self.results' isn't private? Child classes might use this, but I'd expect that users of the class wouldn't directly muck with .results
....................................................
File lib/remote_access_unittest.py
Line 18: # pylint: disable=W0212,W0233,E1101
Are all of these still needed?
Line 70: output=output, error=error)
Indentation?
....................................................
File scripts/deploy_chrome.py
Line 12: import time
************* Module scripts.deploy_chrome
W0611: 10: Unused import optparse
W0611: 13: Unused import urlparse
....................................................
File scripts/deploy_chrome_unittest.py
Line 70: def hook(inst, *args, **kwargs):
More warnings:
W0613: 70:DeployChromeMock.MockMountCmd.hook: Unused argument 'args'
W0613: 70:DeployChromeMock.MockMountCmd.hook: Unused argument 'inst'
W0613: 70:DeployChromeMock.MockMountCmd.hook: Unused argument 'kwargs'
Gerrit-MessageType: comment
Gerrit-Change-Id: I41a32158d7a96d90b6bdfff21d195991e5b174b7
Gerrit-PatchSet: 15
Gerrit-Project: chromiumos/chromite
Gerrit-Branch: master
Gerrit-Owner: Ryan Cui <
rc...@chromium.org>