Changes between Version 11 and Version 12 of HowToWriteTests
- Timestamp:
- 2020-07-14T15:39:01Z (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
HowToWriteTests
v11 v12 8 8 9 9 {{{ 10 python setup.py trial -sallmydata.test.test_fname10 python -m twisted.trial trial allmydata.test.test_fname 11 11 }}} 12 12 13 Okay, so it didn't work, because there is no file by that name. Create such a file, withthese contents:13 Okay, so that was boring because there are no tests in the file. Add these contents: 14 14 15 15 {{{ 16 from twisted.trial import unittest 16 from testtools.matchers import ( 17 Never, 18 ) 19 from .common import ( 20 TestCase, 21 ) 17 22 18 class T( unittest.TestCase):23 class T(TestCase): 19 24 def test_a(self): 20 pass25 self.assertThat("a", Never()) 21 26 }}} 22 27 … … 28 33 29 34 {{{ 30 python setup.py trial --coverage -sallmydata.test.test_fname35 python -m coverage run -m twisted.trial allmydata.test.test_fname 31 36 }}} 32 37 33 This does the same as running the tests without coverage -- print a list of what happened when each test was run. It also writes out a file named {{{.coverage }}} into the current directory. Run the following command to read that file and produce nice HTML pages:38 This does the same as running the tests without coverage -- print a list of what happened when each test was run. It also writes out a file named {{{.coverage.<something>}}} into the current directory. Run the following command to read that file and produce nice HTML pages: 34 39 35 40 {{{ 36 coverage html 37 }}} 38 39 If you installed coverage from Debian or Ubuntu then you have to name it {{{python-coverage}}}, like this: 40 {{{ 41 python-coverage html 41 python -m coverage combine 42 python -m coverage html 42 43 }}} 43 44