New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: doctest report format as an option #1749

Closed
troianow opened this Issue Jul 21, 2016 · 10 comments

Comments

Projects
None yet
5 participants
@troianow

troianow commented Jul 21, 2016

Adding an option to the plugin to choose the type of report (e.g. None, REPORT_UDIFF, REPORT_NDIFF, REPORT_CDIFF) rather than the hard-coded REPORT_UDIFF

For example

py.test foo.py --doctest-module --doctest-report NONE

Would set REPORT_UDIFF = 0 in _pytest/doctest.py:68 and return:

================================== FAILURES ===================================
______________________________ [doctest] foo.bar ______________________________
013     '''
014     >>> bar()
Expected:
       a  b
    0  1  4
    1  2  4
    2  3  6
Got:
       a  b
    0  1  4
    1  2  5
    2  3  6

while
py.test foo.py --doctest-module --doctest-report UDIFF

would set `REPORT_UDIFF = doctest.REPORT_UDIFF

` in _pytest/doctest.py:68 and return

================================== FAILURES ===================================
______________________________ [doctest] foo.bar ______________________________
013     '''
014     >>> bar()
Differences (unified diff with -expected +actual):
    @@ -1,4 +1,4 @@
        a  b
     0  1  4
    -1  2  4
    +1  2  5
     2  3  6
@nicoddemus

This comment has been minimized.

Member

nicoddemus commented Jul 22, 2016

Thanks for the suggestion! 😁

@hartym

This comment has been minimized.

Contributor

hartym commented Jul 23, 2016

@nicoddemus I made a basic implementation (see commit 625b603 in my fork, above), still need to do doc and tests but wanted your input on wether or not it's the right way to do it. Basically, I've seen that all doctest module imports are local and tried to implement it in a way that respects this, can you confirm (or infirm) it's the right way to to it ? Thanks (cc @hackebrot)

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Jul 23, 2016

@hartym if i recall correctly the code was made that way so we do not need to import doctest in case of no doctest test

so your function pretty much removes that, since it does import dpoctest to get the options

@The-Compiler

This comment has been minimized.

Member

The-Compiler commented Jul 23, 2016

if i recall correctly the code was made that way so we do not need to import doctest in case of no doctest test

What's the point of that?

@RonnyPfannschmidt

This comment has been minimized.

Member

RonnyPfannschmidt commented Jul 23, 2016

no idea actually i think that came in before my time

@hartym

This comment has been minimized.

Contributor

hartym commented Jul 23, 2016

I understand that, I'd like to avoid this but can't think of a "clever" way to do it without having to duplicate informations found in the doctest module. Any idea? Or is it fine to duplicate this to obtain this more efficient argparse builder thing?

The only implementation I can think off (and did this before refactoring to this dict getter) is to getattr(...) the thing at the last minute, but looks nasty ...

@hartym

This comment has been minimized.

Contributor

hartym commented Jul 23, 2016

@The-Compiler apparently, some test check for example that the logging module is not in sys.modules at some point, probably between argument parsing and actual run, and my patch breaks that.

hartym added a commit to hartym/pytest that referenced this issue Jul 23, 2016

hartym added a commit to hartym/pytest that referenced this issue Jul 23, 2016

Separate the option keys and value to avoid importing "doctest" (and …
…tested things like "logging") for argument parsing (fixes pytest-dev#1749)
@hartym

This comment has been minimized.

Contributor

hartym commented Jul 23, 2016

PR at #1754

@nicoddemus nicoddemus referenced this issue Jul 23, 2016

Merged

Doctest report format option (#1749) #1754

4 of 4 tasks complete
@The-Compiler

This comment has been minimized.

Member

The-Compiler commented Jul 23, 2016

Seems like that change was originally made in 9b4cca2 - maybe @hpk42 knows why he did that back then 😆

hartym added a commit to hartym/pytest that referenced this issue Jul 23, 2016

@hartym

This comment has been minimized.

Contributor

hartym commented Jul 23, 2016

f8f690d @ PR #1754

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment