testing hg using subprocess.Popen()

Augie Fackler raf at durin42.com
Thu Dec 26 14:19:16 UTC 2013


On Dec 23, 2013, at 9:42 PM, Chris Jerdonek <chris.jerdonek at gmail.com> wrote:

> I have a need to write some tests that can check more than what
> "unified tests" currently allow.  For example, I would like to use
> Python to compare the stdout of `hg` against some
> dynamically-evaluated Python expressions.  Also, some of the
> substrings I would like to check vary across multiple lines which
> isn't currently supported by the per-line "filtering" functionality
> (glob, re, etc).
> 
> So as not to add new test scripts, my idea was to convert an existing
> unified test into a "pure unit test" (i.e. the kind of test mentioned
> at the end of this section [2]), and then use subprocess.Popen() to
> invoke `hg`.
> 
> Does anyone have any thoughts on this?  I didn't find any examples
> like this in the test suite.  It seems like a helper function to call
> `hg` using subprocess.Popen() would be useful to have in the tests
> folder.  However, I didn't come across any examples of helper test
> functions being imported in any of the Python unit tests.

Hm. I guess where I'd go for now would be to capture stdout/stderr in a file and then use inline Python in a .t file to make the assertions you need. Would that work as a stopgap?

> 
> For DRY purposes, etc, it seems like it would be useful to be able to
> share code across Python unit tests.  Starting to do this might be
> another way to chip away at the following problem mentioned in the
> wiki: "The test suite is slow. And the test suite is slow because it
> is highly redundant.." [1]
> 
> I'm asking now because I wanted to hear people's thoughts before I
> prepare my next patch.  Thanks.
> 
> --Chris
> 
> [1] http://mercurial.selenic.com/wiki/WritingTests#No_more_new_test_scripts.21
> [2] http://mercurial.selenic.com/wiki/WritingTests#Writing_a_Python_unit_test
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-devel/attachments/20131226/f16b0102/attachment.asc>


More information about the Mercurial-devel mailing list