OLD | NEW |
1 """ | 1 """ |
2 TestCommon.py: a testing framework for commands and scripts | 2 TestCommon.py: a testing framework for commands and scripts |
3 with commonly useful error handling | 3 with commonly useful error handling |
4 | 4 |
5 The TestCommon module provides a simple, high-level interface for writing | 5 The TestCommon module provides a simple, high-level interface for writing |
6 tests of executable commands and scripts, especially commands and scripts | 6 tests of executable commands and scripts, especially commands and scripts |
7 that interact with the file system. All methods throw exceptions and | 7 that interact with the file system. All methods throw exceptions and |
8 exit on failure, with useful error messages. This makes a number of | 8 exit on failure, with useful error messages. This makes a number of |
9 explicit checks unnecessary, making the test scripts themselves simpler | 9 explicit checks unnecessary, making the test scripts themselves simpler |
10 to write and easier to read. | 10 to write and easier to read. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return existing, missing | 190 return existing, missing |
191 | 191 |
192 def _failed(self, status = 0): | 192 def _failed(self, status = 0): |
193 if self.status is None or status is None: | 193 if self.status is None or status is None: |
194 return None | 194 return None |
195 try: | 195 try: |
196 return _status(self) not in status | 196 return _status(self) not in status |
197 except TypeError: | 197 except TypeError: |
198 # status wasn't an iterable | 198 # status wasn't an iterable |
199 return _status(self) != status | 199 return _status(self) != status |
| 200 |
200 def _status(self): | 201 def _status(self): |
201 return self.status | 202 return self.status |
202 | 203 |
203 class TestCommon(TestCmd): | 204 class TestCommon(TestCmd): |
204 | 205 |
205 # Additional methods from the Perl Test::Cmd::Common module | 206 # Additional methods from the Perl Test::Cmd::Common module |
206 # that we may wish to add in the future: | 207 # that we may wish to add in the future: |
207 # | 208 # |
208 # $test->subdir('subdir', ...); | 209 # $test->subdir('subdir', ...); |
209 # | 210 # |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
560 else: | 561 else: |
561 # We're under the development directory for this change, | 562 # We're under the development directory for this change, |
562 # so this is an Aegis invocation; pass the test (exit 0). | 563 # so this is an Aegis invocation; pass the test (exit 0). |
563 self.pass_test() | 564 self.pass_test() |
564 | 565 |
565 # Local Variables: | 566 # Local Variables: |
566 # tab-width:4 | 567 # tab-width:4 |
567 # indent-tabs-mode:nil | 568 # indent-tabs-mode:nil |
568 # End: | 569 # End: |
569 # vim: set expandtab tabstop=4 shiftwidth=4: | 570 # vim: set expandtab tabstop=4 shiftwidth=4: |
OLD | NEW |