Description
I came across a rather strange and annoying behavior when running the plotting tests that leaves me completely clueless.
TestTSPlot.test_ts_plot_with_tz['UTC']
fails when running the whole test suite but passes when run in isolation. In particular it fails when run after all TestRegistration
tests and passes when run on its own or after any of the six test functions in TestRegistration
:
FAILURE:
(pandas-dev) C:\Daten\Python\pandas>pytest pandas\tests\plotting\ -k "TestRegistration | test_ts_plot_with_tz"
====================================================================== test session starts ======================================================================
platform win32 -- Python 3.8.2, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Daten\Python\pandas, inifile: setup.cfg
plugins: hypothesis-5.19.0, asyncio-0.14.0, cov-2.10.0, forked-1.2.0, xdist-1.32.0
collected 479 items / 460 deselected / 19 selected
pandas\tests\plotting\test_converter.py ...... [ 31%]
pandas\tests\plotting\test_datetimelike.py F............ [100%]
=========================================================================== FAILURES ============================================================================
____________________________________________________________ TestTSPlot.test_ts_plot_with_tz['UTC'] _____________________________________________________________
self = <pandas.tests.plotting.test_datetimelike.TestTSPlot object at 0x000002965C714E20>, tz_aware_fixture = 'UTC'
@pytest.mark.slow
def test_ts_plot_with_tz(self, tz_aware_fixture):
# GH2877, GH17173, GH31205, GH31580
tz = tz_aware_fixture
index = date_range("1/1/2011", periods=2, freq="H", tz=tz)
ts = Series([188.5, 328.25], index=index)
with tm.assert_produces_warning(None):
_check_plot_works(ts.plot)
ax = ts.plot()
xdata = list(ax.get_lines())[0].get_xdata()
# Check first and last points' labels are correct
> assert (xdata[0].hour, xdata[0].minute) == (0, 0)
E AttributeError: 'numpy.datetime64' object has no attribute 'hour'
pandas\tests\plotting\test_datetimelike.py:57: AttributeError
==================================================================== short test summary info ====================================================================
FAILED pandas/tests/plotting/test_datetimelike.py::TestTSPlot::test_ts_plot_with_tz['UTC'] - AttributeError: 'numpy.datetime64' object has no attribute 'hour'
========================================================= 1 failed, 18 passed, 460 deselected in 2.98s ==========================================================
SUCCESS:
(pandas-dev) C:\Daten\Python\pandas>pytest pandas\tests\plotting\ -k test_ts_plot_with_tz
====================================================================== test session starts ======================================================================
platform win32 -- Python 3.8.2, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Daten\Python\pandas, inifile: setup.cfg
plugins: hypothesis-5.19.0, asyncio-0.14.0, cov-2.10.0, forked-1.2.0, xdist-1.32.0
collected 479 items / 466 deselected / 13 selected
pandas\tests\plotting\test_datetimelike.py ............. [100%]
============================================================== 13 passed, 466 deselected in 2.43s ===============================================================
As I said it passes when run after any of the individual functions in TestRegistration
, i.e. with -k "test_register_by_default | test_ts_plot_with_tz"
, "test_registering_no_warning | test_ts_plot_with_tz"
etc.
Tests are run in an environment set up as described here. Pytest and plugin versions see above. Pandas fresh snapshot as of yesterday 1.1.0.dev0+1977.g1706d830d
.
I'm pretty sure it's a question of my setup, so sorry for bothering you with it, but maybe someone has any idea or pointers of where to look for the reason of this behavior.