Commit e41f6827 authored by maruel@chromium.org's avatar maruel@chromium.org

Workaround output variance in pprint.pformat.

TEST=fix unit tests
BUG=none

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@43952 0039d316-1c4b-4281-b951-d872f2087c98
parent 4b5b1779
......@@ -399,7 +399,12 @@ class GClient(object):
Args:
entries: A sequence of solution names.
"""
text = "entries = \\\n" + pprint.pformat(entries, 2) + '\n'
# Sometimes pprint.pformat will use {', sometimes it'll use { ' ... It
# makes testing a bit too fun.
result = pprint.pformat(entries, 2)
if result.startswith('{\''):
result[0:2] = '{ \''
text = "entries = \\\n" + result + '\n'
file_path = os.path.join(self._root_dir, self._options.entries_filename)
gclient_utils.FileWrite(file_path, text)
......
......@@ -6,7 +6,7 @@
"""Unit tests for gclient.py."""
# Fixes include path.
from super_mox import mox, IsOneOf, SuperMoxTestBase
from super_mox import mox, SuperMoxTestBase
import gclient
......@@ -364,14 +364,10 @@ class GClientClassTestCase(GclientTestCase):
) % (solution_name, self.url)
# pprint.pformat() is non-deterministic in this case!!
entries_content1 = (
entries_content = (
"entries = \\\n"
"{ '%s': '%s'}\n"
) % (solution_name, self.url)
entries_content2 = (
"entries = \\\n"
"{'%s': '%s'}\n"
) % (solution_name, self.url)
options = self.Options()
......@@ -398,7 +394,7 @@ class GClientClassTestCase(GclientTestCase):
# file.
gclient.gclient_utils.FileWrite(
gclient.os.path.join(self.root_dir, options.entries_filename),
IsOneOf((entries_content1, entries_content2)))
entries_content)
self.mox.ReplayAll()
client = self._gclient_gclient(self.root_dir, options)
......@@ -657,15 +653,10 @@ class GClientClassTestCase(GclientTestCase):
}, ]""" % (name, self.url)
# pprint.pformat() is non-deterministic in this case!!
entries_content1 = (
entries_content = (
"entries = \\\n"
"{ '%s': '%s'}\n"
) % (name, self.url)
entries_content2 = (
"entries = \\\n"
"{'%s': '%s'}\n"
) % (name, self.url)
options = self.Options()
gclient.os.path.exists(gclient.os.path.join(self.root_dir, name, '.git')
......@@ -681,7 +672,7 @@ class GClientClassTestCase(GclientTestCase):
).AndReturn("Boo = 'a'")
gclient.gclient_utils.FileWrite(
gclient.os.path.join(self.root_dir, options.entries_filename),
IsOneOf((entries_content1, entries_content2)))
entries_content)
self.mox.ReplayAll()
client = self._gclient_gclient(self.root_dir, options)
......@@ -1065,7 +1056,7 @@ deps = {
self.args + ["DEPS"], [])
gclient.gclient_utils.FileWrite(
gclient.os.path.join(self.root_dir, options.entries_filename),
"entries = \\\n{'%s': '%s'}\n" % (name, self.url))
"entries = \\\n{ '%s': '%s'}\n" % (name, self.url))
self.mox.ReplayAll()
client = self._gclient_gclient(self.root_dir, options)
......
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