comparison svnwrap/tests/test_svnwrap.py @ 309:9ad5cf45e30c

svnwrap/tests: use the subprocess module rather than the popen module. The output from the command is supressed. Use check_call() to ensure the detection of failures.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Sun, 03 May 2009 18:25:48 +0200
parents bfbce70a9a57
children 4f4db3d2fdbb
comparison
equal deleted inserted replaced
308:41aa4c3f789e 309:9ad5cf45e30c
1 import os 1 import os
2 import popen2 2 import subprocess
3 import shutil 3 import shutil
4 import tempfile 4 import tempfile
5 import unittest 5 import unittest
6 6
7 from nose import tools 7 from nose import tools
12 def setUp(self): 12 def setUp(self):
13 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 13 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
14 self.repo_path = '%s/testrepo' % self.tmpdir 14 self.repo_path = '%s/testrepo' % self.tmpdir
15 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', 15 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create',
16 self.repo_path,]) 16 self.repo_path,])
17 proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,])
18 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', 17 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
19 'project_root_at_repo_root.svndump')) 18 'project_root_at_repo_root.svndump'))
20 proc.tochild.write(inp.read()) 19 proc = subprocess.check_call(['svnadmin', 'load', self.repo_path,],
21 proc.tochild.close() 20 stdin=inp, close_fds=True,
22 proc.wait() 21 stdout=subprocess.PIPE,
22 stderr=subprocess.STDOUT)
23 self.repo = svnwrap.SubversionRepo('file://%s' % self.repo_path) 23 self.repo = svnwrap.SubversionRepo('file://%s' % self.repo_path)
24 24
25 def tearDown(self): 25 def tearDown(self):
26 shutil.rmtree(self.tmpdir) 26 shutil.rmtree(self.tmpdir)
27 27
57 def setUp(self): 57 def setUp(self):
58 self.tmpdir = tempfile.mkdtemp('svnwrap_test') 58 self.tmpdir = tempfile.mkdtemp('svnwrap_test')
59 self.repo_path = '%s/testrepo' % self.tmpdir 59 self.repo_path = '%s/testrepo' % self.tmpdir
60 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create', 60 os.spawnvp(os.P_WAIT, 'svnadmin', ['svnadmin', 'create',
61 self.repo_path,]) 61 self.repo_path,])
62 proc = popen2.Popen4(['svnadmin', 'load', self.repo_path,])
63 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures', 62 inp = open(os.path.join(os.path.dirname(__file__), 'fixtures',
64 'project_root_not_repo_root.svndump')) 63 'project_root_not_repo_root.svndump'))
65 proc.tochild.write(inp.read()) 64 subprocess.check_call(['svnadmin', 'load', self.repo_path,],
66 proc.tochild.close() 65 stdin=inp, close_fds=True,
67 proc.wait() 66 stdout=subprocess.PIPE,
67 stderr=subprocess.STDOUT)
68 self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' % 68 self.repo = svnwrap.SubversionRepo('file://%s/dummyproj' %
69 self.repo_path) 69 self.repo_path)