Skip to content

REF/TST: Add more pytest idiom to resample/test_base.py #24377

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 9 commits into from
Dec 23, 2018

Conversation

simonjayhawkins
Copy link
Member

@simonjayhawkins simonjayhawkins commented Dec 20, 2018

in this pass:

cc @jreback

@pep8speaks
Copy link

pep8speaks commented Dec 20, 2018

Hello @simonjayhawkins! Thanks for updating the PR.

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on December 23, 2018 at 19:07 Hours UTC

@codecov
Copy link

codecov bot commented Dec 20, 2018

Codecov Report

Merging #24377 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #24377   +/-   ##
=======================================
  Coverage   92.29%   92.29%           
=======================================
  Files         162      162           
  Lines       51841    51841           
=======================================
  Hits        47847    47847           
  Misses       3994     3994
Flag Coverage Δ
#multiple 90.7% <ø> (ø) ⬆️
#single 42.98% <ø> (ø) ⬆️

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 5d134ec...dceb8bc. Read the comment docs.

@codecov
Copy link

codecov bot commented Dec 20, 2018

Codecov Report

Merging #24377 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #24377      +/-   ##
==========================================
- Coverage    92.3%    92.3%   -0.01%     
==========================================
  Files         162      163       +1     
  Lines       51875    51947      +72     
==========================================
+ Hits        47883    47949      +66     
- Misses       3992     3998       +6
Flag Coverage Δ
#multiple 90.71% <ø> (ø) ⬆️
#single 42.98% <ø> (-0.01%) ⬇️
Impacted Files Coverage Δ
pandas/core/arrays/datetimes.py 97.77% <0%> (-0.47%) ⬇️
pandas/core/arrays/timedeltas.py 86.85% <0%> (-0.31%) ⬇️
pandas/core/arrays/datetimelike.py 96.35% <0%> (-0.16%) ⬇️
pandas/core/indexes/timedeltas.py 90.42% <0%> (-0.03%) ⬇️
pandas/core/arrays/period.py 98.49% <0%> (-0.01%) ⬇️
pandas/core/indexes/datetimes.py 96.33% <0%> (-0.01%) ⬇️
pandas/core/indexes/base.py 96.27% <0%> (ø) ⬆️
pandas/core/arrays/_ranges.py 98.66% <0%> (ø)
pandas/core/indexes/datetimelike.py 97.29% <0%> (ø) ⬆️
pandas/core/tools/datetimes.py 85.32% <0%> (+0.04%) ⬆️
... and 1 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 3e0358d...f7092c2. 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.

need to look some more



@pytest.mark.parametrize(
'_index_factory,_series_name,_index_start,_index_end',
Copy link
Contributor

Choose a reason for hiding this comment

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

this is slightly magical

@jreback jreback added Testing pandas testing functions or related to the test suite Resample resample method labels Dec 21, 2018
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.

looks good. on master we have 499 tests and 139 skipped, here 497 ad 9 skipped. so I think a couple got removed?

@@ -19,6 +17,22 @@
assert_almost_equal, assert_frame_equal, assert_index_equal,
assert_series_equal)

# tuples of '_index_factory,_series_name,_index_start,_index_end'
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 give a little more expl here on what this actuall does

@simonjayhawkins
Copy link
Member Author

@jreback

on master we have 499 tests and 139 skipped, here 497 ad 9 skipped. so I think a couple got removed?

for TestDatetimeIndex::test_resample_empty_dtypes

$ pytest pandas/tests/resample/test_base.py::TestDatetimeIndex::test_resample_empty_dtypes
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: C:\Users\simon\OneDrive\code\pandas-simonjayhawkins, inifile: setup.cfg
plugins: xdist-1.23.0, forked-0.2, cov-2.5.1, hypothesis-3.59.1
collected 192 items

pandas\tests\resample\test_base.py ..................................... [ 19%]
........................................................................ [ 56%]
........................................................................ [ 94%]
...........                                                              [100%]

========================= 192 passed in 1.55 seconds ==========================

similarly for TestPeriodIndex

$ pytest pandas/tests/resample/test_base.py::TestPeriodIndex::test_resample_empty_dtypes
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: C:\Users\simon\OneDrive\code\pandas-simonjayhawkins, inifile: setup.cfg
plugins: xdist-1.23.0, forked-0.2, cov-2.5.1, hypothesis-3.59.1
collected 192 items

pandas\tests\resample\test_base.py ..................................... [ 19%]
........................................................................ [ 56%]
........................................................................ [ 94%]
...........                                                              [100%]

========================= 192 passed in 1.10 seconds ==========================

and the same for TestTimedeltaIndex

but because test_resample_empty_dtypes is paramatrized using a generator it was misbehaving..

$ pytest pandas/tests/resample/test_base.py -k test_resample_empty_dtypes
============================= test session starts =============================
platform win32 -- Python 3.6.6, pytest-3.7.3, py-1.5.4, pluggy-0.7.1
rootdir: C:\Users\simon\OneDrive\code\pandas-simonjayhawkins, inifile: setup.cfg
plugins: xdist-1.23.0, forked-0.2, cov-2.5.1, hypothesis-3.59.1
collected 638 items / 318 deselected

pandas\tests\resample\test_base.py ..................................... [ 11%]
........................................................................ [ 34%]
........................................................................ [ 56%]
...........sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 79%]
sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss      [100%]

=========== 192 passed, 128 skipped, 318 deselected in 1.43 seconds ===========

so that account for 128 of the 130 reduction in skipped tests. the other two are from the overridden tests...

@pytest.mark.skip()
def test_asfreq(self):
pass
@pytest.mark.skip()
def test_asfreq_fill_value(self):
pass

the number of passed tests is reduced by two since test_raises_on_non_datetimelike_index is not dependent on index type so is now only run once instead of 3 times.

def test_raises_on_non_datetimelike_index(self):
# this is a non datetimelike index
xp = DataFrame()
pytest.raises(TypeError, lambda: xp.resample('A').mean())

@jreback
Copy link
Contributor

jreback commented Dec 23, 2018

_____________ ERROR collecting pandas/tests/resample/test_base.py _____________
2018-12-23T18:59:10.6286537Z C:\Miniconda\envs\pandas-dev\lib\site-packages\_pytest\python.py:450: in _importtestmodule
2018-12-23T18:59:10.6287402Z     mod = self.fspath.pyimport(ensuresyspath=importmode)
2018-12-23T18:59:10.6287666Z C:\Miniconda\envs\pandas-dev\lib\site-packages\py\_path\local.py:668: in pyimport
2018-12-23T18:59:10.6287846Z     __import__(modname)
2018-12-23T18:59:10.6288006Z E     File "D:\a\1\s\pandas\tests\resample\test_base.py", line 21
2018-12-23T18:59:10.6288224Z E   SyntaxError: Non-ASCII character '\xe2' in file D:\a\1\s\pandas\tests\resample\test_base.py on line 21, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
2018-12-23T18:59:10.629434

@jreback jreback added this to the 0.24.0 milestone Dec 23, 2018
@jreback jreback merged commit 0d2cd53 into pandas-dev:master Dec 23, 2018
@jreback
Copy link
Contributor

jreback commented Dec 23, 2018

thanks @simonjayhawkins

@simonjayhawkins simonjayhawkins deleted the resample-base-alt branch December 24, 2018 08:46
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this pull request Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resample resample method Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants