Changeset 79:d49b898f3abd
- Timestamp:
- 04/12/07 17:50:27 (20 months ago)
- Author:
- Tarek Ziad?? <tarek@…>
- Message:
-
added example
- Location:
- RuPy
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r78
|
r79
|
|
| 282 | 282 | import unittest |
| 283 | 283 | |
| | 284 | # let's say, division function is in division module |
| | 285 | from division import division |
| | 286 | |
| 284 | 287 | class DivisionTestCase(unittest.TestCase): |
| 285 | 288 | |
| … |
… |
|
| 292 | 295 | def test_suite(): |
| 293 | 296 | suite = unittest.TestSuite() |
| 294 | | suite.addTest(DivisionTestCase) |
| | 297 | suite.addTests(unittest.makeSuite(DivisionTestCase)) |
| 295 | 298 | return suite |
| 296 | 299 | |
| … |
… |
|
| 298 | 301 | unittest.main(defaultTest='test_suite') |
| 299 | 302 | |
| | 303 | How to write tests in Python |
| | 304 | ============================ |
| | 305 | |
| | 306 | Running the tests with the Python interpreter:: |
| | 307 | |
| | 308 | |
| | 309 | dabox:~ tarek$ python test_division.py |
| | 310 | .. |
| | 311 | ------------------------------------------------------------------ |
| | 312 | Ran 2 tests in 0.000s |
| | 313 | |
| | 314 | OK |
| 300 | 315 | |
| 301 | 316 | How to write tests in Python |