Merge lp:~andrea-crotti-0/mailman/test_doc into lp:mailman

Proposed by Andrea Crotti
Status: Rejected
Rejected by: Barry Warsaw
Proposed branch: lp:~andrea-crotti-0/mailman/test_doc
Merge into: lp:mailman
Diff against target: 97 lines (+82/-0)
2 files modified
README.rst (+1/-0)
src/mailman/docs/CONTRIBUTING.rst (+81/-0)
To merge this branch: bzr merge lp:~andrea-crotti-0/mailman/test_doc
Reviewer Review Type Date Requested Status
Barry Warsaw Needs Fixing
Review via email: mp+98295@code.launchpad.net

Description of the change

Added some doc from the Testing instructions in the e-mail.

This is far from perfect but I don't know much about it yet, so please give me some feedback about how it should be structured and what I should add..

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

Thanks for taking a shot at this! Here are some comments:

Notice that there is a template.py file in the top level directory. This is a great way to start any new .py file (except __init__.py files which are typically empty). So if you're adding a new test_foo.py file, start with the template.

You might describe how to run a single test, e.g.

    $ bin/test -t test_simple_wrap

will run just that one test, while

    $ bin/test -t test_headers

will run all the tests in the test_headers.py file.

    $ bin/test -t users.rst

will run that doctest. This isn't really Mailman specific; it's all zope.testing.

Also perhaps describe the -vv option, which I use all the time.

From there, I'd say you could describe some some about how the project is managed, e.g.

 - Branches and merge proposals are preferred over patches (though patches may be accepted)
 - I prefer a branch/merge-proposal to be attached to a bug since then we can milestone it and include a note in the NEWS.rst file.
 - Please include a test in every branch. Documentation is nice too, as is a NEWS.rst file entry (but the latter is optional, especially if there is a bug report).

Please make sure to run the full test suite to make sure your branch doesn't regress.

That's probably it for now. This is a great start and could eventually be expanded to explain other aspects for contributors. But we can wait on that. :)

review: Needs Fixing
Revision history for this message
Barry Warsaw (barry) wrote :

This branch is pretty far out of date with trunk. Thanks for the contribution, but I'm going to close this merge proposal.

Unmerged revisions

7126. By Andrea Crotti

- refactor the testing information
- add CONTRIBUTING to the TOC

7125. By Andrea Crotti

add first sample of documentation for testing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'README.rst'
2--- README.rst 2012-03-14 20:49:09 +0000
3+++ README.rst 2012-03-19 22:12:19 +0000
4@@ -38,6 +38,7 @@
5 src/mailman/docs/DATABASE
6 src/mailman/docs/MTA
7 src/mailman/docs/8-miles-high
8+ src/mailman/docs/CONTRIBUTING
9 src/mailman/bin/docs/*
10 src/mailman/commands/docs/*
11 src/mailman/database/docs/*
12
13=== added file 'src/mailman/docs/CONTRIBUTING.rst'
14--- src/mailman/docs/CONTRIBUTING.rst 1970-01-01 00:00:00 +0000
15+++ src/mailman/docs/CONTRIBUTING.rst 2012-03-19 22:12:19 +0000
16@@ -0,0 +1,81 @@
17+============
18+Contributing
19+============
20+
21+Tests
22+=====
23+
24+Setup
25+-----
26+
27+First make sure you set up your buildout correctly with:
28+
29+::
30+
31+ python bootstrap.py && bin/buildout
32+
33+This will generate the *bin/test* script, which is the main script to run the project tests.
34+
35+
36+Layout
37+------
38+
39+Essentially all unittests live in a test_foo.py module inside a tests/
40+directory (which has an __init__.py so it's a package).
41+
42+unittest.TestCase subclasses are named TestFoo and individual tests
43+inside there as test_foo() methods.
44+
45+.. It's only a little extra work if you have to create a new tests/
46+.. subdirectory or test_foo.py module, but again, it should be pretty
47+.. straightforward.
48+
49+::
50+
51+ class TestListLifecycleEvents(unittest.TestCase):
52+ layer = ConfigLayer
53+
54+ def setUp(self):
55+ self._ant = create_list('ant@example.com')
56+ self._bee = create_list('bee@example.com')
57+ self._usermanager = getUtility(IUserManager)
58+
59+
60+Tests are automatically discovered by the zope.testing framework, and
61+we use *layers* to set up expensive resources among a suite of tests.
62+
63+E.g. if you need the rest server to be started, you'd use the
64+RESTLayer (see mailman.testing.layers for what's currently defined).
65+
66+To enable a layer, you just need to set the `layer` attribute of the
67+TestFoo class.
68+
69+Almost all the tests will require at least the ConfigLayer since that
70+brings up the Zope component architecture, connfiguration system.
71+
72+Note that doctests are all set up in test_documentation.py so they're
73+not really all that special.
74+
75+
76+Possible issues
77+---------------
78+
79+zope.testing is a bit weird here because the normal rules of subclasses don't
80+actually apply. E.g. the LMTPLayer derives from ConfigLayer which derives
81+from MockAndMonkeyLayer.
82+
83+All the appropriate setUp()s get called by zope.testing so you don't
84+need to up-call explicitly in the layer class.
85+
86+.. too much magic and would be good to switch to something else
87+
88+
89+Test coverage
90+=============
91+
92+You can see the tests coverage using
93+
94+
95+::
96+
97+ bin/test coverage=coveragepy