Skip to content

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

Closed
wants to merge 6 commits into from

Conversation

mikebarkas
Copy link

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.

Mike Barkas added 3 commits February 15, 2018 21:23
  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.
@pep8speaks
Copy link

pep8speaks commented Feb 17, 2018

Hello @mikebarkas! Thanks for updating the PR.

Line 67:9: E722 do not use bare except'
Line 75:5: E722 do not use bare except'
Line 84:5: E722 do not use bare except'

Comment last updated on April 29, 2018 at 17:58 Hours UTC

@mikebarkas
Copy link
Author

PEP8 issue for common.py
do not use bare except This is in existing code.
This issue is for moving the tests and not changing test.

@mikebarkas mikebarkas changed the title Gh18498 Gh18498 - Spit test_pytables into sub-modules Feb 17, 2018
@mikebarkas mikebarkas changed the title Gh18498 - Spit test_pytables into sub-modules TST: GH18498 - Spit test_pytables into sub-modules Feb 17, 2018
@mikebarkas mikebarkas changed the title TST: GH18498 - Spit test_pytables into sub-modules TST: GH18498 - Split test_pytables into sub-modules Feb 17, 2018
@codecov
Copy link

codecov bot commented Feb 17, 2018

Codecov Report

Merging #19735 into master will decrease coverage by 0.24%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Flag Coverage Δ
#multiple 91.56% <ø> (+1.35%) ⬆️
#single 32.81% <ø> (-9.09%) ⬇️
Impacted Files Coverage Δ
pandas/tseries/plotting.py 0% <0%> (-100%) ⬇️
pandas/core/dtypes/base.py 47.61% <0%> (-44.28%) ⬇️
pandas/plotting/_compat.py 62% <0%> (-28.91%) ⬇️
pandas/core/arrays/base.py 60% <0%> (-24.15%) ⬇️
pandas/io/s3.py 72.72% <0%> (-13.64%) ⬇️
pandas/core/missing.py 85.9% <0%> (-5.75%) ⬇️
pandas/plotting/_timeseries.py 60.82% <0%> (-4.49%) ⬇️
pandas/io/formats/console.py 66.66% <0%> (-3.04%) ⬇️
pandas/io/html.py 85.98% <0%> (-2.81%) ⬇️
pandas/io/formats/format.py 96.25% <0%> (-2%) ⬇️
... and 58 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdfce2b...5052897. Read the comment docs.

@jreback jreback added Testing pandas testing functions or related to the test suite IO HDF5 read_hdf, HDFStore labels Feb 18, 2018
import pandas.util.testing as tm


tables = pytest.importorskip('tables')
Copy link
Contributor

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

# contextmanager to ensure the file cleanup


def safe_remove(path):
Copy link
Contributor

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

Copy link
Contributor

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):
Copy link
Contributor

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

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
@jreback
Copy link
Contributor

jreback commented Feb 22, 2018

@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.

@mikebarkas
Copy link
Author

My test build on my fork is failing because ImportError: No module named tables
Looking into it.

I will look for the missing test.

@mikebarkas
Copy link
Author

This is my missing test

def test_longpanel(self):
    pass

I will add it back into test_panel

@jreback
Copy link
Contributor

jreback commented Feb 22, 2018

oh no need to add that back then

Copy link
Contributor

@jreback jreback left a 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,
Copy link
Contributor

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,
Copy link
Contributor

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.

Copy link
Contributor

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

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)

Copy link
Contributor

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

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

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

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,
Copy link
Contributor

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


Copy link
Contributor

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]],
Copy link
Contributor

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

@alsobay
Copy link

alsobay commented Apr 29, 2018

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.
@mikebarkas
Copy link
Author

@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.

@jreback
Copy link
Contributor

jreback commented Jul 28, 2018

closing as stale, happy to take an updated PR of this

@jreback jreback closed this Jul 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO HDF5 read_hdf, HDFStore Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TST: split out test_pytables.py to sub-module of tests
4 participants