Mercurial > treepkg > treepkg
comparison test/test_builder.py @ 344:f06f707d9fda
merged branches/scratchbox into trunk
#### IMPORTANT FOR ALL TREEPKGS #####
pbuilderrc config variable name changed to builderconfig
author | Bjoern Ricks <bricks@intevation.de> |
---|---|
date | Fri, 23 Apr 2010 07:43:29 +0000 |
parents | ce7be2fb93ee |
children |
comparison
equal
deleted
inserted
replaced
343:c0808837fc64 | 344:f06f707d9fda |
---|---|
42 | 42 |
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_builder method.""" |
48 basedir = self.create_temp_dir("pbuilder") | 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: |
54 builder.init_pbuilder(distribution="etch", | 54 builder.init_builder(distribution="etch", |
55 mirrorsite="http://example.com/debian", | 55 mirrorsite="http://example.com/debian", |
56 extramirrors=None) | 56 extramirrors=None) |
57 finally: | 57 finally: |
58 sys.stdout = old_stdout | 58 sys.stdout = old_stdout |
59 | 59 |
60 # check whether the necessary directories were created | 60 # check whether the necessary directories were created |
61 missing = [dirname for dirname in ["base", "build", "result", | 61 missing = [dirname for dirname in ["base", "build", "result", |
62 "aptcache", "extra-pkg"] | 62 "aptcache", "extra-pkg"] |
63 if not os.path.isdir(os.path.join(basedir, dirname))] | 63 if not os.path.isdir(os.path.join(basedir, dirname))] |
64 if missing: | 64 if missing: |
65 self.fail("init_pbuilder did not create these directories: %s" | 65 self.fail("init_builder did not create these directories: %s" |
66 % " ".join(missing)) | 66 % " ".join(missing)) |
67 | 67 |
68 # check the pbuilderrc. This test is a little too strict | 68 # check the pbuilderrc. This test is a little too strict |
69 # because it checks the exact contents of the file. Instread it | 69 # because it checks the exact contents of the file. Instread it |
70 # should normalize the contents in some way and check that. | 70 # should normalize the contents in some way and check that. |
102 "turning the extra-pkg dir into a debian archive\n" | 102 "turning the extra-pkg dir into a debian archive\n" |
103 "running pbuilder create\n" | 103 "running pbuilder create\n" |
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_builder prints an error when run twice. |
108 """ | 108 """ |
109 basedir = self.create_temp_dir("pbuilder") | 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 |
115 sys.stdout = captured_stdout = StringIO.StringIO() | 115 sys.stdout = captured_stdout = StringIO.StringIO() |
116 try: | 116 try: |
117 builder.init_pbuilder(distribution="etch", | 117 builder.init_builder(distribution="etch", |
118 mirrorsite="http://example.com/debian", | 118 mirrorsite="http://example.com/debian", |
119 extramirrors=None) | 119 extramirrors=None) |
120 finally: | 120 finally: |
121 sys.stdout = old_stdout | 121 sys.stdout = old_stdout |
122 | 122 |
125 # message and exit with exit code 1. | 125 # message and exit with exit code 1. |
126 old_stderr = sys.stderr | 126 old_stderr = sys.stderr |
127 sys.stderr = captured_stderr = StringIO.StringIO() | 127 sys.stderr = captured_stderr = StringIO.StringIO() |
128 try: | 128 try: |
129 try: | 129 try: |
130 builder.init_pbuilder(distribution="etch", | 130 builder.init_builder(distribution="etch", |
131 mirrorsite="http://example.com/debian", | 131 mirrorsite="http://example.com/debian", |
132 extramirrors=None) | 132 extramirrors=None) |
133 except SystemExit, exc: | 133 except SystemExit, exc: |
134 self.assertEquals(exc.code, 1) | 134 self.assertEquals(exc.code, 1) |
135 finally: | 135 finally: |