Mercurial > piecrust2
comparison tests/conftest.py @ 567:a65f04ddbea2
showconfig: Don't crash when the whole config should be shown.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Tue, 13 Oct 2015 22:46:05 -0700 |
parents | b95977d97652 |
children | d8d9e0424a72 |
comparison
equal
deleted
inserted
replaced
566:8073ae8cb164 | 567:a65f04ddbea2 |
---|---|
147 argv = self.spec['args'] | 147 argv = self.spec['args'] |
148 if isinstance(argv, str): | 148 if isinstance(argv, str): |
149 argv = argv.split(' ') | 149 argv = argv.split(' ') |
150 | 150 |
151 expected_code = self.spec.get('code', 0) | 151 expected_code = self.spec.get('code', 0) |
152 expected_out = self.spec.get('out', '') | 152 expected_out = self.spec.get('out', None) |
153 | 153 |
154 with mock_fs_scope(fs): | 154 with mock_fs_scope(fs): |
155 memstream = io.StringIO() | 155 memstream = io.StringIO() |
156 hdl = logging.StreamHandler(stream=memstream) | 156 hdl = logging.StreamHandler(stream=memstream) |
157 logging.getLogger().addHandler(hdl) | 157 logging.getLogger().addHandler(hdl) |
163 finally: | 163 finally: |
164 logging.getLogger().removeHandler(hdl) | 164 logging.getLogger().removeHandler(hdl) |
165 | 165 |
166 assert expected_code == exit_code | 166 assert expected_code == exit_code |
167 | 167 |
168 actual_out = memstream.getvalue() | 168 if expected_out is not None: |
169 if self.spec.get('replace_out_path_sep'): | 169 actual_out = memstream.getvalue() |
170 expected_out = expected_out.replace('/', os.sep) | 170 if self.spec.get('replace_out_path_sep'): |
171 assert expected_out == actual_out | 171 expected_out = expected_out.replace('/', os.sep) |
172 assert expected_out == actual_out | |
172 | 173 |
173 def reportinfo(self): | 174 def reportinfo(self): |
174 return self.fspath, 0, "bake: %s" % self.name | 175 return self.fspath, 0, "bake: %s" % self.name |
175 | 176 |
176 def repr_failure(self, excinfo): | 177 def repr_failure(self, excinfo): |