comparison test/test_builder.py @ 185:e1c7cd896310

Rework test/filesupport.py so that test cases always use their own temporary directory. Before, the test cases had to ensure this themselves. Adapt the test cases.
author Bernhard Herzog <bh@intevation.de>
date Thu, 26 Jun 2008 16:23:26 +0000
parents 72e41b27f224
children 2622bf5ed5bd
comparison
equal deleted inserted replaced
184:83c77307ffb1 185:e1c7cd896310
43 43
44 class TestPBuilder(PBuilderTests): 44 class TestPBuilder(PBuilderTests):
45 45
46 def test_init_pbuilder(self): 46 def test_init_pbuilder(self):
47 """Tests the PBuilder.init_pbuilder method.""" 47 """Tests the PBuilder.init_pbuilder method."""
48 basedir = self.create_temp_dir(self.id()) 48 basedir = self.create_temp_dir("pbuilder")
49 pbuilderrc = os.path.join(basedir, "pbuilderrc") 49 pbuilderrc = os.path.join(basedir, "pbuilderrc")
50 builder = PBuilder(pbuilderrc, self.root_command) 50 builder = PBuilder(pbuilderrc, self.root_command)
51 old_stdout = sys.stdout 51 old_stdout = sys.stdout
52 sys.stdout = captured_stdout = StringIO.StringIO() 52 sys.stdout = captured_stdout = StringIO.StringIO()
53 try: 53 try:
104 % dict(basedir_repr=repr(basedir)[1:-1])) 104 % dict(basedir_repr=repr(basedir)[1:-1]))
105 105
106 def test_init_pbuilder_run_twice(self): 106 def test_init_pbuilder_run_twice(self):
107 """Tests whether PBuilder.init_pbuilder prints an error when run twice. 107 """Tests whether PBuilder.init_pbuilder prints an error when run twice.
108 """ 108 """
109 basedir = self.create_temp_dir(self.id()) 109 basedir = self.create_temp_dir("pbuilder")
110 110
111 # run it once 111 # run it once
112 pbuilderrc = os.path.join(basedir, "pbuilderrc") 112 pbuilderrc = os.path.join(basedir, "pbuilderrc")
113 builder = PBuilder(pbuilderrc, self.root_command) 113 builder = PBuilder(pbuilderrc, self.root_command)
114 old_stdout = sys.stdout 114 old_stdout = sys.stdout
218 def test_build_with_extra_env(self): 218 def test_build_with_extra_env(self):
219 """Tests the PBuilder.build method with the extra_env parameter""" 219 """Tests the PBuilder.build method with the extra_env parameter"""
220 binary_dir_name = self.temp_file_name("binary") 220 binary_dir_name = self.temp_file_name("binary")
221 if os.path.exists(binary_dir_name): 221 if os.path.exists(binary_dir_name):
222 os.rmdir(binary_dir_name) 222 os.rmdir(binary_dir_name)
223 env_test_file = self.temp_file_name(self.id() + "_envtest", remove=True) 223 env_test_file = self.temp_file_name("envtest")
224 # sanity check: the binary directory must not exist yet. 224 # sanity check: the binary directory must not exist yet.
225 self.failIf(os.path.exists(binary_dir_name)) 225 self.failIf(os.path.exists(binary_dir_name))
226 # sanity check: the environment variable TREEPKG_TEST must not 226 # sanity check: the environment variable TREEPKG_TEST must not
227 # be set yet 227 # be set yet
228 self.failIf("TREEPKG_TEST" in os.environ) 228 self.failIf("TREEPKG_TEST" in os.environ)
339 pbuilder_files = [("pbuilderrc", ""), 339 pbuilder_files = [("pbuilderrc", ""),
340 ("extra-pkg", [])] 340 ("extra-pkg", [])]
341 341
342 def setUp(self): 342 def setUp(self):
343 PBuilderTests.setUp(self) 343 PBuilderTests.setUp(self)
344 self.temp_base_dir = self.create_temp_dir(self.id()) 344 self.temp_base_dir = self.create_temp_dir("pbuilder")
345 self.minimal_packge_dir = os.path.join(self.temp_base_dir, 345 self.minimal_packge_dir = os.path.join(self.temp_base_dir,
346 "minimal-1.0") 346 "minimal-1.0")
347 self.create_files(self.minimal_packge_dir, self.minimal_package) 347 self.create_files(self.minimal_packge_dir, self.minimal_package)
348 call(["dpkg-buildpackage", "-rfakeroot", "-b", "-uc"], 348 call(["dpkg-buildpackage", "-rfakeroot", "-b", "-uc"],
349 cwd=self.minimal_packge_dir, suppress_output=True) 349 cwd=self.minimal_packge_dir, suppress_output=True)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)