@@ -13,52 +13,53 @@ Some general rules of testing:
1313 correct.
1414
1515- Each test unit must be fully independent. Each of them must be able to run
16- alone, and also within the test suite, regardless of the order they are called.
17- The implication of this rule is that each test must be loaded with a fresh
18- dataset and may have to do some cleanup afterwards. This is usually
19- handled by :meth: `setUp() ` and :meth: `tearDown() ` methods.
16+ alone, and also within the test suite, regardless of the order they are
17+ called. The implication of this rule is that each test must be loaded with
18+ a fresh dataset and may have to do some cleanup afterwards. This is
19+ usually handled by :meth: `setUp() ` and :meth: `tearDown() ` methods.
2020
2121- Try hard to make tests that run fast. If one single test needs more than a
22- few millisecond to run, development will be slowed down or the tests will not
23- be run as often as desirable. In some cases, tests can't be fast because they
24- need a complex data structure to work on, and this data structure must be
25- loaded every time the test runs. Keep these heavier tests in a separate test
26- suite that is run by some scheduled task, and run all other tests as often
27- as needed.
22+ few millisecond to run, development will be slowed down or the tests will
23+ not be run as often as desirable. In some cases, tests can't be fast because
24+ they need a complex data structure to work on, and this data structure must
25+ be loaded every time the test runs. Keep these heavier tests in a separate
26+ test suite that is run by some scheduled task, and run all other tests as
27+ often as needed.
2828
2929- Learn your tools and learn how to run a single test or a test case. Then,
3030 when developing a function inside a module, run this function's tests very
3131 often, ideally automatically when you save the code.
3232
3333- Always run the full test suite before a coding session, and run it again
34- after. This will give you more confidence that you did not break anything in
35- the rest of the code.
34+ after. This will give you more confidence that you did not break anything
35+ in the rest of the code.
3636
37- - It is a good idea to implement a hook that runs all tests before pushing code
38- to a shared repository.
37+ - It is a good idea to implement a hook that runs all tests before pushing
38+ code to a shared repository.
3939
40- - If you are in the middle of a development session and have to interrupt your work, it
41- is a good idea to write a broken unit test about what you want to develop next.
42- When coming back to work, you will have a pointer to where you were and get
43- back on track faster.
40+ - If you are in the middle of a development session and have to interrupt
41+ your work, it is a good idea to write a broken unit test about what you
42+ want to develop next. When coming back to work, you will have a pointer
43+ to where you were and get back on track faster.
4444
4545- The first step when you are debugging your code is to write a new test
4646 pinpointing the bug. While it is not always possible to do, those bug
4747 catching test are among the most valuable pieces of code in your project.
4848
49- - Use long and descriptive names for testing functions. The style guide here is
50- slightly different than that of running code, where short names are often
51- preferred. The reason is testing functions are never called explicitly.
49+ - Use long and descriptive names for testing functions. The style guide here
50+ is slightly different than that of running code, where short names are
51+ often preferred. The reason is testing functions are never called explicitly.
5252 ``square() `` or even ``sqr() `` is ok in running code, but in testing code you
5353 would have names such as ``test_square_of_number_2() ``,
54- ``test_square_negative_number() ``. These function names are displayed when a
55- test fail, and should be as descriptive as possible.
56-
57- - When something goes wrong or has to be changed, and if your code has a good
58- set of tests, you or other maintainers will rely largely on the testing suite
59- to fix the problem or modify a given behavior. Therefore the testing code will
60- be read as much as or even more than the running code. A unit test whose
61- purpose is unclear is not very helpful is this case.
54+ ``test_square_negative_number() ``. These function names are displayed when
55+ a test fails, and should be as descriptive as possible.
56+
57+ - When something goes wrong or has to be changed, and if your code has a
58+ good set of tests, you or other maintainers will rely largely on the
59+ testing suite to fix the problem or modify a given behavior. Therefore
60+ the testing code will be read as much as or even more than the running
61+ code. A unit test whose purpose is unclear is not very helpful is this
62+ case.
6263
6364- Another use of the testing code is as an introduction to new developers. When
6465 someone will have to work on the code base, running and reading the related
0 commit comments