comparison tests/test_util.py @ 851:9ce00cb1d676

Merge alternate tunnel schemes.
author Augie Fackler <durin42@gmail.com>
date Sat, 25 Feb 2012 14:51:22 -0600
parents e9af7eba88db
children 04729f3a3d17
comparison
equal deleted inserted replaced
850:d3bc067c0f72 851:9ce00cb1d676
41 41
42 # Documentation for Subprocess.Popen() says: 42 # Documentation for Subprocess.Popen() says:
43 # "Note that on Windows, you cannot set close_fds to true and 43 # "Note that on Windows, you cannot set close_fds to true and
44 # also redirect the standard handles by setting stdin, stdout or 44 # also redirect the standard handles by setting stdin, stdout or
45 # stderr." 45 # stderr."
46 canCloseFds='win32' not in sys.platform 46 canCloseFds = 'win32' not in sys.platform
47 47
48 if not 'win32' in sys.platform: 48 if not 'win32' in sys.platform:
49 def kill_process(popen_obj): 49 def kill_process(popen_obj):
50 os.kill(popen_obj.pid, 9) 50 os.kill(popen_obj.pid, 9)
51 else: 51 else:
73 DWORD, 'dwDesiredAccess', 73 DWORD, 'dwDesiredAccess',
74 BOOL, 'bInheritHandle', 74 BOOL, 'bInheritHandle',
75 DWORD, 'dwProcessId', 75 DWORD, 'dwProcessId',
76 ) 76 )
77 77
78 CloseHandle = WINAPI(BOOL, ctypes.windll.kernel32.CloseHandle, 78 CloseHandle = WINAPI(BOOL, ctypes.windll.kernel32.CloseHandle,
79 HANDLE, 'hObject' 79 HANDLE, 'hObject'
80 ) 80 )
81 81
82 TerminateProcess = WINAPI(BOOL, ctypes.windll.kernel32.TerminateProcess, 82 TerminateProcess = WINAPI(BOOL, ctypes.windll.kernel32.TerminateProcess,
83 HANDLE, 'hProcess', 83 HANDLE, 'hProcess',
161 def load_svndump_fixture(path, fixture_name): 161 def load_svndump_fixture(path, fixture_name):
162 '''Loads an svnadmin dump into a fresh repo at path, which should not 162 '''Loads an svnadmin dump into a fresh repo at path, which should not
163 already exist. 163 already exist.
164 ''' 164 '''
165 if os.path.exists(path): rmtree(path) 165 if os.path.exists(path): rmtree(path)
166 subprocess.call(['svnadmin', 'create', path,], 166 subprocess.call(['svnadmin', 'create', path, ],
167 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 167 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
168 inp = open(os.path.join(FIXTURES, fixture_name)) 168 inp = open(os.path.join(FIXTURES, fixture_name))
169 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, 169 proc = subprocess.Popen(['svnadmin', 'load', path, ], stdin=inp,
170 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 170 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
171 proc.communicate() 171 proc.communicate()
172 172
173 def dispatch(cmd): 173 def dispatch(cmd):
174 try: 174 try:
246 246
247 class TestBase(unittest.TestCase): 247 class TestBase(unittest.TestCase):
248 def setUp(self): 248 def setUp(self):
249 _verify_our_modules() 249 _verify_our_modules()
250 250
251 self.oldenv = dict([(k, os.environ.get(k, None), ) for k in 251 self.oldenv = dict([(k, os.environ.get(k, None),) for k in
252 ('LANG', 'LC_ALL', 'HGRCPATH', )]) 252 ('LANG', 'LC_ALL', 'HGRCPATH',)])
253 self.oldt = i18n.t 253 self.oldt = i18n.t
254 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' 254 os.environ['LANG'] = os.environ['LC_ALL'] = 'C'
255 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) 255 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True)
256 256
257 self.oldwd = os.getcwd() 257 self.oldwd = os.getcwd()