-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fix doctests in dependencygraph.py #3048
Conversation
@Madnex @tomaarsen, rather than having several fixtures to check the availability of binaries, it seems more rational to have just one generic function that takes the binary name as parameter. Then, the new test/binary_fixt can be imported in any test that requires the availability of a particular binary. For ex. in the updated nltk/tag/hunpos.py:
Then:
|
Seems like a good idea for sure |
Thanks for the review and suggestions @tomaarsen: I guess that LookupError is what you refer to when you call for something more specific.
At this time, there don't seem to be other cases of unavailable binaries in #2989. There are a number unavailable "jar" packs related to the Stanford parser, but these will probably require a different solution. However, the new check_binary() function can also replace the discourse, inference, and nonmonotonic fixtures in test/. I think it is preferable to do that within the present PR, in order to check that it works as intended. |
For ex. replace the redundant nltk/test/inference_fixt.py:
|
Indeed, a |
Looks like we're nearly ready to merge this... @ekaf are you intending to use |
@stevenbird yes, this PR seems complete. I don't intend to use check_binary elsewhere. |
Thoughts on moving |
Since it is just a test fixture among many others in the test directory, the current place seems adequate. However, maybe the filename could be changed to something broader (like for ex. setup_fixt.py), in order to open the possibility to include other generic fixtures later.
|
Renamed fixture file with a broader filename, in order to accommodate the eventual addition of other generic fixtures. The scope of this PR has already expanded beyond just handling dependencygraph.py, so I think it would be best to wait for a future PR to also replace pytest.importorskip(), because those cases are outside issue #2989. |
This is looking good. Thanks for this @ekaf! |
* Fix doctests in nltk/parse/dependencygraph.py * Move pytest import inside setup_dot() function * Generic fixture to skip doctest when a required binary is not available * Import generic fixture in dependencygraph.py and hunpos.py * Return False when binary is unavailable * Implement suggestions by @tomaahsen * Replace redundant text fixtures by check_binary * Broaden fixture filename * Delete old fixture file
Reduce the list of failing doctests (Issue #2989), by fixing the tests in nltk/parse/dependencygraph.py.
pytest --doctest-modules --doctest-continue-on-failure ./nltk/parse/dependencygraph.py
With this PR, if the "dot" binary is present, all tests pass. Otherwise, one test is skipped: