Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(506)

Side by Side Diff: testing_support/super_mox.py

Issue 1158043003: Remove most svn related testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix typo in doc Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « testing_support/local_rietveld.py ('k') | tests/checkout_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Simplify unit tests based on pymox.""" 5 """Simplify unit tests based on pymox."""
6 6
7 import os 7 import os
8 import random 8 import random
9 import shutil 9 import shutil
10 import string 10 import string
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 return self.Strings(max_arg_count, 48 return self.Strings(max_arg_count,
49 self._RANDOM_RANDINT(1, max_arg_length)) 49 self._RANDOM_RANDINT(1, max_arg_length))
50 50
51 def _DirElts(self, max_elt_count=4, max_elt_length=8): 51 def _DirElts(self, max_elt_count=4, max_elt_length=8):
52 return self._OS_SEP.join(self.Strings(max_elt_count, max_elt_length)) 52 return self._OS_SEP.join(self.Strings(max_elt_count, max_elt_length))
53 53
54 def Dir(self, max_elt_count=4, max_elt_length=8): 54 def Dir(self, max_elt_count=4, max_elt_length=8):
55 return (self._RANDOM_CHOICE((self._OS_SEP, '')) + 55 return (self._RANDOM_CHOICE((self._OS_SEP, '')) +
56 self._DirElts(max_elt_count, max_elt_length)) 56 self._DirElts(max_elt_count, max_elt_length))
57 57
58 def SvnUrl(self, max_elt_count=4, max_elt_length=8):
59 return ('svn://random_host:port/a' +
60 self._DirElts(max_elt_count, max_elt_length
61 ).replace(self._OS_SEP, '/'))
62
63 def RootDir(self, max_elt_count=4, max_elt_length=8): 58 def RootDir(self, max_elt_count=4, max_elt_length=8):
64 return self._OS_SEP + self._DirElts(max_elt_count, max_elt_length) 59 return self._OS_SEP + self._DirElts(max_elt_count, max_elt_length)
65 60
66 def compareMembers(self, obj, members): 61 def compareMembers(self, obj, members):
67 """If you add a member, be sure to add the relevant test!""" 62 """If you add a member, be sure to add the relevant test!"""
68 # Skip over members starting with '_' since they are usually not meant to 63 # Skip over members starting with '_' since they are usually not meant to
69 # be for public use. 64 # be for public use.
70 actual_members = [x for x in sorted(dir(obj)) 65 actual_members = [x for x in sorted(dir(obj))
71 if not x.startswith('_')] 66 if not x.startswith('_')]
72 expected_members = sorted(members) 67 expected_members = sorted(members)
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 except TypeError, e: 141 except TypeError, e:
147 raise TypeError( 142 raise TypeError(
148 'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e)) 143 'Couldn\'t mock %s in %s: %s' % (item, parent.__name__, e))
149 144
150 def UnMock(self, obj, name): 145 def UnMock(self, obj, name):
151 """Restore an object inside a test.""" 146 """Restore an object inside a test."""
152 for (parent, old_child, child_name) in self.mox.stubs.cache: 147 for (parent, old_child, child_name) in self.mox.stubs.cache:
153 if parent == obj and child_name == name: 148 if parent == obj and child_name == name:
154 setattr(parent, child_name, old_child) 149 setattr(parent, child_name, old_child)
155 break 150 break
OLDNEW
« no previous file with comments | « testing_support/local_rietveld.py ('k') | tests/checkout_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698