-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TST: GH18498 - Split test_pytables into sub-modules #19735
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
Conversation
This commit moves the existing test classes out of the pytables test module into sub-modules.
These tests now live in the pytables sub-module.
Hello @mikebarkas! Thanks for updating the PR.
Comment last updated on April 29, 2018 at 17:58 Hours UTC |
PEP8 issue for |
Codecov Report
@@ Coverage Diff @@
## master #19735 +/- ##
==========================================
- Coverage 91.82% 91.58% -0.25%
==========================================
Files 152 150 -2
Lines 49248 48908 -340
==========================================
- Hits 45222 44790 -432
- Misses 4026 4118 +92
Continue to review full report at Codecov.
|
pandas/tests/io/pytables/common.py
Outdated
import pandas.util.testing as tm | ||
|
||
|
||
tables = pytest.importorskip('tables') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if things are not used here, remove them
pandas/tests/io/pytables/common.py
Outdated
# contextmanager to ensure the file cleanup | ||
|
||
|
||
def safe_remove(path): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would like to tun these into fixtures, also this removes the need for the Base class entirely. ok with doing this in another pass though
@@ -0,0 +1,163 @@ | |||
import pytest | |||
from warnings import catch_warnings | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just name this test_complex.py
def setup_method(self, method): | ||
self.path = 'tmp.__%s__.h5' % tm.rands(10) | ||
|
||
def teardown_method(self, method): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the idea is to split this out into many submodules, e.g.
test_store (construct & instrospect a store)
test_append
test_multiindex
test_remove
test_where
test_select
basically just select similar tests (by name to start is ok) and group them into sub-modules
|
||
def test_append_with_timezones_dateutil(self): | ||
|
||
from datetime import timedelta |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move any imports to the top
Removed test classes, created test functions Grouped tests into sub-modules Cleaned up imports, comments, and spaces
@mikebarkas looks great! oddly there is 1 less tests here (174 and 1 xfail) vs 175 and 1 xfail on master. happy to have parameterization of any tests as well. |
My test build on my fork is failing because I will look for the missing test. |
This is my missing test
I will add it back into |
oh no need to add that back then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit too much splitting. idea is to put common files together. tests might be named inconsitenly, but still to group them together, we should end up with only about 5 ish modules here overall.
from pandas import (Series, DataFrame, date_range, Index, Timestamp, | ||
DatetimeIndex, compat, concat, isna) | ||
tables = pytest.importorskip('tables') | ||
from pandas.tests.io.pytables.common import (ensure_clean_store, safe_close, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can just do a
from .common import .....
(and do this generally)
|
||
import pandas.util.testing as tm | ||
import pandas.util._test_decorators as td | ||
from pandas.util.testing import (assert_panel_equal, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer not to import these and just reference with tm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also do this generally across all files
|
||
import numpy as np | ||
import pandas as pd | ||
from pandas import Series, DataFrame, date_range, timedelta_range, bdate_range |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you rename to test_datetime
with catch_warnings(record=True): | ||
wp = tm.makePanel() | ||
_check_roundtrip(wp, assert_panel_equal) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are may more panel tests, can you move here
|
||
store.close() | ||
assert 'CLOSED' in store.info() | ||
assert not store.is_open |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these need to go with any other open/close tests, which I think you have in test_common.py now. call this file test_open_close (move this one and other tests)
import pytest | ||
from warnings import catch_warnings | ||
|
||
import numpy as np |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are many more selection / query type tests that are in test_common. move here
@@ -0,0 +1,270 @@ | |||
import pytest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename this to test_query
import numpy as np | ||
from pandas import (Series, DataFrame, date_range, Index, Timestamp, | ||
concat, MultiIndex, bdate_range, Panel) | ||
from pandas.tests.io.pytables.common import (ensure_clean_store, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consolidate with test_read (and call test_query)
from pandas.tests.io.pytables.common import ensure_clean_store | ||
import pandas.util.testing as tm | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move these to test_select, we don't need a separate file for this
index = MultiIndex(levels=[['foo', 'bar', 'baz', 'qux'], | ||
['one', 'two', 'three']], | ||
labels=[[0, 0, 0, 1, 1, 2, 2, 3, 3, 3], | ||
[0, 1, 2, 0, 1, 1, 2, 0, 1, 2]], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these need to be put in the right place, not a separate file
Hi Mike, are you still working on this? Would be glad to help out or pick it up if you're too busy. |
Consolidate functions to reduce amount of module files.
@alsobay I broke the build with latest changes, in a different part of the test suite. I have not had time to determine where and to fix it. I am currently moving and have little free time. I would appreciate the help to get this PR finished. |
closing as stale, happy to take an updated PR of this |
git diff upstream/master -u -- "*.py" | flake8 --diff
Moved test classes for pytables into sub-modules.
Moved hdf test data files needed into sub-module.
I did not change any tests, just broke up the classes into separate modules.