Skip to content

Organize, Split, Parametrize timezones/timestamps tests #19473

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

Merged
merged 5 commits into from
Feb 1, 2018

Conversation

jbrockmendel
Copy link
Member

test_timezones has a small subset of tests that specifically tests tslibs.timezones, but most of it makes much more sense to organize with the appropriate Timestamp and DatetimeIndex tests. Otherwise we get (as in the status quo) a ton of duplicate and near-duplicate tests for e.g. tz_localize in both test_timezones and test_timestamps.

This PR starts that cleanup for timestamps. Will wait on DTI pending feedback.

@codecov
Copy link

codecov bot commented Jan 31, 2018

Codecov Report

Merging #19473 into master will increase coverage by 0.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #19473      +/-   ##
==========================================
+ Coverage    91.6%   91.62%   +0.01%     
==========================================
  Files         150      150              
  Lines       48724    48728       +4     
==========================================
+ Hits        44632    44645      +13     
+ Misses       4092     4083       -9
Flag Coverage Δ
#multiple 89.99% <ø> (+0.01%) ⬆️
#single 41.74% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/frame.py 97.42% <0%> (-0.16%) ⬇️
pandas/core/generic.py 95.91% <0%> (ø) ⬆️
pandas/core/indexes/accessors.py 90.19% <0%> (+0.19%) ⬆️
pandas/plotting/_converter.py 66.95% <0%> (+1.73%) ⬆️

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 d37d867...2a16a97. Read the comment docs.

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.

again instead of moving around inside a single file, just make a sub-directory an move to separate files. it is much easier to discover things.

pandas/tests/scalar/timestamp/test_.....


def test_pprint(self):
# GH#12622
import pprint
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 import at the top

'2014-01-01 00:00:00.000000001'])
def test_repr(self, date, freq):
# dateutil zone change (only matters for repr)
if LooseVersion(dateutil.__version__) >= LooseVersion('2.6.0'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timezones can be parameterized here

@jreback jreback added Testing pandas testing functions or related to the test suite Datetime Datetime data dtype Timezones Timezone data dtype labels Jan 31, 2018
@jbrockmendel
Copy link
Member Author

again instead of moving around inside a single file, just make a sub-directory an move to separate files. it is much easier to discover things.

OK. So pretty much one class per file?

@jbrockmendel
Copy link
Member Author

Just pushed a commit that splits a chunk of scalar.test_timestamps into scalar.timestamps.test_*. This will take a few steps. After looking at the results I agree you're right this is a nice layout.

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.

small change. ping on grenn.

with pytest.raises(AmbiguousTimeError):
ts.tz_localize('US/Pacific', errors='coerce')

@pytest.mark.parametrize('tz', ['UTC', 'Asia/Tokyo',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eventually we want to propagate all of these to higher level fixtures (the tz I am talking about)

@@ -704,6 +471,31 @@ def test_today(self):
assert (abs(ts_from_string_tz.tz_localize(None) -
ts_from_method_tz.tz_localize(None)) < delta)


class TestTimestamp(object):

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should go in scalar/test_timezones , yes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to leave this one out of this round until I make up my mind on exactly where it belongs. test_tz isn't very informative, so it will likely be split into method-specific tests, many of which likely already exist.

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.

small change. ping on green.

@jbrockmendel
Copy link
Member Author

ping

@jreback jreback added this to the 0.23.0 milestone Feb 1, 2018
@jreback jreback merged commit 63d96f5 into pandas-dev:master Feb 1, 2018
@jreback
Copy link
Contributor

jreback commented Feb 1, 2018

thanks, spitting like this is very welcome. you may need to rebase other PRs.

@jreback jreback modified the milestone: 0.23.0 Feb 1, 2018
@jbrockmendel jbrockmendel deleted the ts_tests branch February 11, 2018 21:58
harisbal pushed a commit to harisbal/pandas that referenced this pull request Feb 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Testing pandas testing functions or related to the test suite Timezones Timezone data dtype
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants