-
-
Notifications
You must be signed in to change notification settings - Fork 18k
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
pytest 'slow' not a registered marker with --strict
flag on other projects
#16680
Comments
you would have to show more information. |
@kmodry can you provide more information? What version of pandas is installed? Is your project publicly available? |
Hi, I just ran into the exact same problem while making a pull request on github for pyjson_tricks . This pullrequest caused travis to run the continues integration test, whose results you can see at: https://travis-ci.org/mverleg/pyjson_tricks/jobs/246885590 . According to that webpage the error occured with pandas version 0.20.2. An older test of the same project with pandas 0.19.2 at https://travis-ci.org/mverleg/pyjson_tricks/jobs/222351028 did not produce these problems. |
To recreate the problem: clone https://github.com/koffie/pyjson_tricks (commit 4f5e734b70ffcb...) and run the tests as described in: https://github.com/koffie/pyjson_tricks/blob/master/docs/index.rst . I.e. just run either tox or detox from the root directory. Changing tox.ini to require pandas==0.19.2 doesn't produce the error, while requiring pandas==0.20.0rc1 or any higher version triggers the error. |
@koffie still not entirely sure what this has to do with pandas. pls show a reproducible example with pandas code itself. I would guess you are picking up the pandas conftest |
Hmm, looking through @koffie's example, pandas fails to import with (Pdb) import pandas.testing
*** AttributeError: module 'pandas' has no attribute 'plotting' I'm not sure how that would cause the test error. Even install matplotlib in that env causes the same error. |
Yes we are indeed picking up parts of pandas conftest and this is happening because there is the statement: Now the error occurs because we like to test our code with the --strict option of pytest. And according to the documentation
Now we don't want to be forced to register all markers that are used in pandas.testing . So would it be possible to remove the importing of the |
Another solution if you really want to keep exposing all your testing functions is to write a pandas plugin for pytest as explained on https://docs.pytest.org/en/latest/writing_plugins.html#writing-plugins and register all your custom markers as explained on https://docs.pytest.org/en/latest/example/markers.html#adding-a-custom-marker-from-a-plugin . |
By the way, a minimal way to reproduce the problem is the following: |
--strict
flag on other projects
@koffie thanks for the minimal example. Added to the original post.
Don't think so. That's part of the public API, and we provide I think you're suggesting to write a plugin is the way to go. |
@TomAugspurger One could move the |
By the way just running
|
Ha, I think that does it, at least for the simple example. Here's the diff if anyone wants to submit a PR before I have a chance tomorrow diff --git a/pandas/util/testing.py b/pandas/util/testing.py
index 17e09b38b..d6ba95613 100644
--- a/pandas/util/testing.py
+++ b/pandas/util/testing.py
@@ -50,13 +50,6 @@ from pandas import (bdate_range, CategoricalIndex, Categorical, IntervalIndex,
from pandas._libs import testing as _testing
from pandas.io.common import urlopen
-try:
- import pytest
- slow = pytest.mark.slow
-except ImportError:
- # Should be ok to just ignore. If you actually need
- # slow then you'll hit an import error long before getting here.
- pass
N = 30
diff --git a/setup.cfg b/setup.cfg
index 8b32f0f62..e0d5f274a 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -27,3 +27,4 @@ split_penalty_logical_operator = 30
testpaths = pandas
markers =
single: mark a test as single cpu only
+ slow: mark a test as slow Thanks for the help @koffie |
Hi, Thanks for the pull request. I just tested this with 16797 applied. And it did fix the problem with |
Create a file
test_pandas.py
withimport pandas
run
pytest
with--strict
flag(original post below)
Importing panda make my pytest tests fail because of one marker "slow" is required in
/usr/local/lib/python2.7/dist-packages/pandas/util/testing.py:55: in
slow = pytest.mark.slow
I don't use slow marker and have to add it to run my test even though it's just for panda
complete stack trace :
tests/_lib/createfullteststoresem.py:54: in createFullTestStoreSem
from oxlib.sem.history import get_ad_product_history
oxlib/sem/history.py:5: in
import pandas as pd
/usr/local/lib/python2.7/dist-packages/pandas/init.py:60: in
import pandas.testing
/usr/local/lib/python2.7/dist-packages/pandas/testing.py:7: in
from pandas.util.testing import (
/usr/local/lib/python2.7/dist-packages/pandas/util/testing.py:55: in
slow = pytest.mark.slow
/usr/local/lib/python2.7/dist-packages/_pytest/mark.py:184: in getattr
self._check(name)
The text was updated successfully, but these errors were encountered: