10000 TST: Test cleanup, parametrization for datetime64 arithmetic tests by jbrockmendel · Pull Request #23681 · pandas-dev/pandas · GitHub
[go: up one dir, main page]

Skip to content

TST: Test cleanup, parametrization for datetime64 arithmetic tests #23681

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 13 commits into from
Nov 16, 2018
Merged
Prev Previous commit
Next Next commit
make utc_objs into a fixture
  • Loading branch information
jbrockmendel committed Nov 14, 2018
commit 497d33acfd9645f35a27cc33195a5879a954bfe1
16 changes: 16 additions & 0 deletions pandas/conftest.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import importlib
import os

from dateutil.tz import tzutc
import hypothesis
from hypothesis import strategies as st
import numpy as np
import pytest
from pytz import utc

from pandas.compat import PY3
import pandas.util._test_decorators as td
Expand Down Expand Up @@ -243,6 +245,20 @@ def datetime_tz_utc():
return timezone.utc


utc_objs = ['utc', utc, tzutc()]
if PY3:
from datetime import timezone
utc_objs.append(timezone.utc)


@pytest.fixture(params=utc_objs)
def utc_fixture(request):
"""
Fixture to provide variants of UTC timezone strings and tzinfo objects
"""
return request.param


@pytest.fixture(params=['inner', 'outer', 'left', 'right'])
def join_type(request):
"""
Expand Down
14 changes: 2 additions & 12 deletions pandas/tests/scalar/timestamp/test_comparisons.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,10 @@
import pytest
import numpy as np

from dateutil.tz import tzutc
from pytz import utc

from pandas.compat import long, PY2
from pandas import Timestamp


utc_objs = ['utc', utc, tzutc()]
if not PY2:
from datetime import timezone
utc_objs.append(timezone.utc)


class TestTimestampComparison(object):
def test_comparison_object_array(self):
# GH#15183
Expand Down Expand Up @@ -95,11 +86,10 @@ def test_compare_invalid(self):
assert val != np.float64(1)
assert val != np.int64(1)

@pytest.mark.parametrize('utc_obj', utc_objs)
def test_cant_compare_tz_naive_w_aware(self, utc_obj):
def test_cant_compare_tz_naive_w_aware(self, utc_objs):
# see GH#1404
a = Timestamp('3/12/2012')
b = Timestamp('3/12/2012', tz=utc_obj)
b = Timestamp('3/12/2012', tz=utc_objs)

with pytest.raises(TypeError):
a == b
Expand Down
0