Skip to content
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
Closed

Feature request: doctest report format as an option #1749

troianow opened this issue Jul 21, 2016 · 10 comments
Labels
good first issue easy issue that is friendly to new contributor plugin: doctests related to the doctests builtin plugin status: help wanted developers would like help from experts on this topic

Comments

@troianow
Copy link

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 nicoddemus added good first issue easy issue that is friendly to new contributor plugin: doctests related to the doctests builtin plugin labels Jul 22, 2016
@nicoddemus
Copy link
Member

Thanks for the suggestion! 😁

@RonnyPfannschmidt RonnyPfannschmidt added the status: help wanted developers would like help from experts on this topic label Jul 22, 2016
hartym added a commit to hartym/pytest that referenced this issue Jul 23, 2016
@hartym
Copy link
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
Copy link
Member

@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
Copy link
Member

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
Copy link
Member

no idea actually i think that came in before my time

@hartym
Copy link
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
Copy link
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
…tested things like "logging") for argument parsing (fixes pytest-dev#1749)
@hartym
Copy link
Contributor

hartym commented Jul 23, 2016

PR at #1754

@The-Compiler
Copy link
Member

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
Copy link
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
Labels
good first issue easy issue that is friendly to new contributor plugin: doctests related to the doctests builtin plugin status: help wanted developers would like help from experts on this topic
Projects
None yet
Development

No branches or pull requests

5 participants