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

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

Date: Mon, 02 Jan 2012 14:47:22 -0000

To: Thomas Jost, Dmitry Kurochkin, notmuch@notmuchmail.org

Cc:

From: Patrick Totzke


Quoting Thomas Jost (2011-12-13 17:21:34)
>On Sun, 11 Dec 2011 18:58:18 +0400, Dmitry Kurochkin <dmitry.kurochkin@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

Thread: