[PATCH 1/2] test: add a function to run Python tests

Patrick Totzke patricktotzke at googlemail.com
Mon Jan 2 06:47:22 PST 2012


Quoting Thomas Jost (2011-12-13 17:21:34)
>On Sun, 11 Dec 2011 18:58:18 +0400, Dmitry Kurochkin <dmitry.kurochkin at gmail.com> wrote:
>> Perhaps we should have a test-lib.py for test-specific stuff like this
>> (similar to test-lib.el)?  I think it would be cleaner and makes it easy
>> to add more Python test auxiliary functions later.
>
>Well, right now that would probably be overkill: the stdout-to-file
>redirection takes 3 lines at most. Besides we would still need to set
>some environment variables to run python with the correct directories.
>But of course if we need to add more helper functions for running python
>tests, then a test-lib.py would be nice.

I agree that a test-lib python module that contains some helpers would be useful.
Specifically, we could use a "test_expect_success" helper that
wraps a given script into a try/except block.

>Maybe we could even think about using one of Python's unit test libs for
>that: doctest, unittest (both in the standard library) and nose seem to
>be the most popular ones.
never used any of these.

I cleaned up the initial test a bit (see the following messages for the patches).
Here are a few suggestions for tests we should implement later:

test_begin_subtest "tag messages" # add_tag/remove_tag 
test_begin_subtest "add messages" # compare msg.get_filename to original 
test_begin_subtest "find message" 
test_begin_subtest "remove messages" 
test_begin_subtest "list tags" # get_all_tags() 
test_begin_subtest "count messages" # count_messages() 
test_begin_subtest "count threads" # MISSING in the bindings!  count_messages() 
test_begin_subtest "count messages in thread" # get_total_messages compare with notmuch search messages |wc 
test_begin_subtest "exceptions" # ReadOnlyDatabaseError, XapianError. 
test_begin_subtest "format message content" # format_message_as_text(indent=0)

best,
/p


More information about the notmuch mailing list