Commit 3c74bc9d authored by maruel@chromium.org's avatar maruel@chromium.org

Fix member lookup to be more stable.

Add regression test.

R=dpranke@chromium.org
BUG=
TEST=


Review URL: http://codereview.chromium.org/7891061

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@101351 0039d316-1c4b-4281-b951-d872f2087c98
parent fae707be
......@@ -585,11 +585,15 @@ class Dependency(GClientKeywords, gclient_utils.WorkItem):
def __str__(self):
out = []
for i in ('name', 'url', 'parsed_url', 'safesync_url', 'custom_deps',
'custom_vars', 'deps_hooks', '_file_list', 'should_process',
'custom_vars', 'deps_hooks', 'file_list', 'should_process',
'processed', 'hooks_ran', 'deps_parsed', 'requirements'):
# 'deps_file'
if self.__dict__[i]:
out.append('%s: %s' % (i, self.__dict__[i]))
# First try the native property if it exists.
if hasattr(self, '_' + i):
value = getattr(self, '_' + i, False)
else:
value = getattr(self, i, False)
if value:
out.append('%s: %s' % (i, value))
for d in self.dependencies:
out.extend([' ' + x for x in str(d).splitlines()])
......
......@@ -203,6 +203,34 @@ class GclientTest(trial_dir.TestCase):
None, '', True)
self.assertEquals('proto://host/path@revision', d.url)
def testStr(self):
# Make sure __str__() works fine.
# pylint: disable=W0212
parser = gclient.Parser()
options, _ = parser.parse_args([])
obj = gclient.GClient('foo', options)
obj.dependencies.append(
gclient.Dependency(obj, 'foo', 'url', None, None, None, 'DEPS', True))
obj.dependencies.append(
gclient.Dependency(obj, 'bar', 'url', None, None, None, 'DEPS', True))
obj.dependencies[0].dependencies.append(
gclient.Dependency(
obj.dependencies[0], 'foo/dir1', 'url', None, None, None, 'DEPS',
True))
obj.dependencies[0].dependencies.append(
gclient.Dependency(
obj.dependencies[0], 'foo/dir2',
gclient.GClientKeywords.FromImpl('bar'), None, None, None, 'DEPS',
True))
obj.dependencies[0].dependencies.append(
gclient.Dependency(
obj.dependencies[0], 'foo/dir3',
gclient.GClientKeywords.FileImpl('url'), None, None, None, 'DEPS',
True))
obj.dependencies[0]._file_list.append('foo')
self.assertEquals(434, len(str(obj)), '%d\n%s' % (len(str(obj)), str(obj)))
if __name__ == '__main__':
logging.basicConfig(
level=[logging.ERROR, logging.WARNING, logging.INFO, logging.DEBUG][
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment