spec icon indicating copy to clipboard operation
spec copied to clipboard

Print module docstrings in spec output

Open codeinthehole opened this issue 11 years ago • 4 comments

I would find it useful if the spec output included the module docstring as well. This would let me set some context for the following TestCases.

Example

For example, for functional tests I end up naming my TestCases things like:

class TestAnAdmin(WebTest):
    def test_can_create_a_new_product(self):
        ...

which outputs as:

An admin
- can create a new product

But the trouble is I end up with lots of TestCases with the same name and the spec output is a little confusing.

Proposal

It would be good if I could use a module docstring to distinguish between test modules. Eg:

"""
Product dashboard
"""

class TestAnAdmin(WebTest):
    def test_can_create_a_new_product(self):
        ...

would lead to something like:

Product dashboard
-----------------
An admin
- can create a new product

Category dashboard
------------------
An admin
- can create a new category

The underlining is optional. It might be better to use a bold font or simply leave it to the docstring to distinguish the module docstrings.

Sensible?

codeinthehole avatar Mar 12 '13 11:03 codeinthehole

:+1:

narfdotpl avatar Mar 13 '13 12:03 narfdotpl

+1

LuRsT avatar Mar 14 '13 09:03 LuRsT

Neat idea; I haven't run into this need myself because the projects I've been testing end up organized into one test module per class under test, so the "top level" of the test output is naturally pretty distinct/unique. But I can see why testing similar collections of functionality would make the output harder to parse.

Would need to make sure this is actually feasible re: how Nose organizes discovered tests (I haven't poked at that part of Spec in a year or so, so memory hazy) but given I was able to get the rest of things indented it's probably doable somehow. I'd definitely consider merging a PR implementing this, otherwise I may pok when I have time.

bitprophet avatar Mar 18 '13 06:03 bitprophet

Excellent. I'll have a go at implementing.

codeinthehole avatar Mar 18 '13 11:03 codeinthehole