-
-
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
TST: Converting to Pytest Idiom #15990
Comments
this is already indicated in #15341 and documented. this is orthogonal to #15962 which is fine.
absolutely NOT. not sure where you got this notion. sure Generally replacing test code should be done in independent PRs/commits. |
actually another section after http://pandas-docs.github.io/pandas-docs-travis/contributing.html#how-to-use-parametrize would make sense to explain how to write / when to use which assertions, focused on asserting pandas objects ( |
Since all the
Pytest has special comparison reprs for builtin data structues, and you can define your own so this could be solved. But we don't want to. We need all the arguments to I can writeup a summary of the comparisons and assertions for the documentation. |
@jreback , @TomAugspurger : So if I'm understanding this properly, we are sticking with raw If that is the case, yes, absolutely, then we should replace using |
I think you misunderstood. For builtins, scalars, etc. we'll recommend For DataFrames, Series, etc., we'll recommend I don't think we need to change any of the asserts in |
@TomAugspurger : No, I do understand in fact. I am referring to chunks like this and something like this. |
I think @gfyoung meant the |
In But probably not worth changing now |
@jorisvandenbossche : Yes, that is correct. Okay, that's what I was hoping to get clarification on. |
Also, do we want to use |
Regarding the wrappers in |
yes the only things would change are
and use |
I would also add the following (static
|
One thing I might also add is that in the spirit of functional, test classes should probably be avoided unless there is a good organization reason for doing so. Otherwise, test functions should be used. |
@gfyoung ideally yes, but they are nice for organization, so I wouldn't necessarily change the structure if its meant for organization (and it almost always is). |
To everyone here, what is your opinion about |
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990. [ci skip]
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990. [ci skip]
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990.
* MAINT: Convert test setup/teardown to pytest idiom * tm.TestCase now just inherits from object * setUpClass renamed to setup_class * tearDownClass renamed to teardown_class * setUp renamed to setup_method * tearDown renamed to teardown_method * MAINT: Remove unittest.TestCase from testing * DOC: Update documentation for TestCase usage tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes gh-15990. * TST: Patch Circle matplotlib failure The tm.mplskip decorator was breaking on Circle, so this commit removes the decorator and replaces it with direct function calls to check for matplotlib. * TST: Replace yield-based tests in test_query_eval
* MAINT: Convert test setup/teardown to pytest idiom * tm.TestCase now just inherits from object * setUpClass renamed to setup_class * tearDownClass renamed to teardown_class * setUp renamed to setup_method * tearDown renamed to teardown_method * MAINT: Remove unittest.TestCase from testing * DOC: Update documentation for TestCase usage tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990. * TST: Patch Circle matplotlib failure The tm.mplskip decorator was breaking on Circle, so this commit removes the decorator and replaces it with direct function calls to check for matplotlib. * TST: Replace yield-based tests in test_query_eval
* MAINT: Convert test setup/teardown to pytest idiom * tm.TestCase now just inherits from object * setUpClass renamed to setup_class * tearDownClass renamed to teardown_class * setUp renamed to setup_method * tearDown renamed to teardown_method * MAINT: Remove unittest.TestCase from testing * DOC: Update documentation for TestCase usage tm.TestCase no longer follows the nosetest idiom, so it is here to stay, so update the documentation to say that we are using it still. Closes pandas-devgh-15990. * TST: Patch Circle matplotlib failure The tm.mplskip decorator was breaking on Circle, so this commit removes the decorator and replaces it with direct function calls to check for matplotlib. * TST: Replace yield-based tests in test_query_eval
@gfyoung BTW, I just saw that the latest pytest actually supports a |
The PR you pointed to seems to referring to |
Ah, sorry, yes, that is what I meant :-) But indeed, we also have out own |
Our testing framework is a literal hodgepodge of different 3rd-party framework standards (i.e.
nosetest
,pytest
,unittest
) that needs to be cleaned up.A couple of points are clear:
assert
instead ofself.assert*...
for
loops withpytest.mark.parametrize
object
instead oftm.TestCase
However, we also have this massive testing module helper
testing.py
that is populated with tons of useful comparison methods as well as wrappers around basicassert
methods that are used inconsistently throughout the code-base. Thus, the question is whether or not we want to keep using those OR remove them entirely and replace them with basicassert
statements.The advantage with using
tm.assert
statements is that they come directly with error messages instead of an emptyAssertionError
, which is what I don't like about rawassert
statements that are considered more idiomatic withpytest
.Thus, it's a question of greater clarity (i.e. our error messages will be more useful by default when we get test failures) vs. idiomatic (raw
assert
with no wrapping is the idiomatic way to go but risks presenting less helpful failure messages).Another point I wanted to bring up is with regards to the introduction of decorators in #15952 to capturestdout
andstderr
.pytest
has fixtures to capture those, but incorporating it into the code-base is very difficult due to our heavy reliance still onunittest.TestCase
, which causes incorporation to fail. The question is: do we eventually want to use thepytest
fixture or continue using the decorator?Thoughts?
From the discussion that follows, here are the functions that should be removed and replaced:
self (tm).assertRaises
-->pytest.raises
self (tm).assertRaisesRegexp
-->Per discussion in #16089 (comment), we are leaving as is.
self.assert*
(examples follow)self.assertIs
self.assertEqual
self.assert_*
(examples follow)self.assert_numpy_array_equal
self.assert_series_equal
self.assert_frame_equal
self.assert_index_equal
tm.assert_equal
tm.assertIs(Not)
tm.assert(Not)In
tm.assertIs(Not)None
tm.assert(Not)IsInstance
The text was updated successfully, but these errors were encountered: