Skip to content

MAINT moved all "d" modules to pytest. #7885

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 2 commits into from
Jan 22, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
MAINT moved test_dates to pytest
  • Loading branch information
NelleV committed Jan 20, 2017
commit 11b8dcdd1d9f38985353d0b42f0d5e8fba6cf969
1 change: 0 additions & 1 deletion lib/matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,6 @@ def _jupyter_nbextension_paths():
'matplotlib.tests.test_compare_images',
'matplotlib.tests.test_container',
'matplotlib.tests.test_contour',
'matplotlib.tests.test_dates',
'matplotlib.tests.test_dviread',
'matplotlib.tests.test_figure',
'matplotlib.tests.test_font_manager',
Expand Down
48 changes: 19 additions & 29 deletions lib/matplotlib/tests/test_dates.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from __future__ import (absolute_import, division, print_function,
unicode_literals)

import six
from six.moves import map
Copy link
Member

Choose a reason for hiding this comment

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

The line below uses six.

Copy link
Member

Choose a reason for hiding this comment

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

As an import?

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 don't see where the import is useful.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I'm not able to find any use of six. in that file.

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, I wasn't thinking properly.


import datetime
import warnings
import tempfile
import pytest

import dateutil
import pytz
Expand All @@ -16,8 +16,8 @@
from unittest import mock
except ImportError:
import mock
from nose.tools import assert_raises, assert_equal
from nose.plugins.skip import SkipTest

from numpy.testing import assert_raises, assert_equal

from matplotlib.testing.decorators import image_comparison, cleanup
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -180,18 +180,16 @@ def test_strftime_fields(dt):
"{hour24:02d} {hour12:02d} {minute:02d} {second:02d} "
"%{microsecond:06d} %x"
.format(
# weeknum=dt.isocalendar()[1], # %U/%W {weeknum:02d}
# %w Sunday=0, weekday() Monday=0
weekday=str((dt.weekday() + 1) % 7),
day=dt.day,
month=dt.month,
year=dt.year % 100,
full_year=dt.year,
hour24=dt.hour,
hour12=((dt.hour-1) % 12) + 1,
minute=dt.minute,
second=dt.second,
microsecond=dt.microsecond))
weekday=str((dt.weekday() + 1) % 7),
day=dt.day,
month=dt.month,
year=dt.year % 100,
full_year=dt.year,
hour24=dt.hour,
hour12=((dt.hour-1) % 12) + 1,
minute=dt.minute,
second=dt.second,
microsecond=dt.microsecond))
assert_equal(formatter.strftime(dt), formatted_date_str)

try:
Expand Down Expand Up @@ -446,10 +444,7 @@ def tz_convert(dt_list, tzinfo):
def test_date2num_dst_pandas():
# Test for github issue #3896, but in date2num around DST transitions
# with a timezone-aware pandas date_range object.
try:
import pandas as pd
except ImportError:
raise SkipTest('pandas not installed')
pd = pytest.importorskip('pandas')

def tz_convert(*args):
return pd.DatetimeIndex.tz_convert(*args).astype(datetime.datetime)
Expand All @@ -458,18 +453,13 @@ def tz_convert(*args):


def test_DayLocator():
assert_raises(ValueError, mdates.DayLocator, interval=-1)
assert_raises(ValueError, mdates.DayLocator, interval=-1.5)
assert_raises(ValueError, mdates.DayLocator, interval=0)
assert_raises(ValueError, mdates.DayLocator, interval=1.3)
mdates.DayLocator(interval=1.0)
assert_raises(ValueError, mdates.DayLocator, interval=-1)
assert_raises(ValueError, mdates.DayLocator, interval=-1.5)
assert_raises(ValueError, mdates.DayLocator, interval=0)
assert_raises(ValueError, mdates.DayLocator, interval=1.3)
mdates.DayLocator(interval=1.0)


def test_tz_utc():
dt = datetime.datetime(1970, 1, 1, tzinfo=mdates.UTC)
dt.tzname()


if __name__ == '__main__':
import nose
nose.runmodule(argv=['-s', '--with-doctest'], exit=False)