Skip to content

CLN: cleanup up platform / python version checks. fix GB10151 #10542

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 1 commit into from
Jul 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 1 addition & 2 deletions bench/bench_sparse.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import numpy as np

from pandas import *
Expand Down Expand Up @@ -30,7 +29,7 @@
s1_dense = s1.to_dense()
s2_dense = s2.to_dense()

if 'linux' in sys.platform:
if compat.is_platform_linux():
pth = '/home/wesm/code/pandas/example'
else:
pth = '/Users/wesm/code/pandas/example'
Expand Down
4 changes: 1 addition & 3 deletions pandas/computation/tests/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,7 @@ def test_floor_division(self):
self.check_floor_division(lhs, '//', rhs)

def test_pow(self):
import platform
if platform.system() == 'Windows':
raise nose.SkipTest('not testing pow on Windows')
tm._skip_if_windows()

# odd failure on win32 platform, so skip
for lhs, rhs in product(self.lhses, self.rhses):
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/tests/test_json/test_ujson.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def _skip_if_python_ver(skip_major, skip_minor=None):
raise nose.SkipTest("skipping Python version %d.%d" % (major, minor))


json_unicode = (json.dumps if sys.version_info[0] >= 3
json_unicode = (json.dumps if compat.PY3
else partial(json.dumps, encoding="utf-8"))

class UltraJSONTests(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_empty_string(self):

def test_read_csv(self):
if not compat.PY3:
if 'win' in sys.platform:
if compat.is_platform_windows():
prefix = u("file:///")
else:
prefix = u("file://")
Expand Down
5 changes: 2 additions & 3 deletions pandas/io/tests/test_pytables.py
Original file line number Diff line number Diff line change
Expand Up @@ -2067,9 +2067,8 @@ def test_store_timezone(self):
# GH2852
# issue storing datetime.date with a timezone as it resets when read back in a new timezone

import platform
if platform.system() == "Windows":
raise nose.SkipTest("timezone setting not supported on windows")
# timezone setting not supported on windows
tm._skip_if_windows()

import datetime
import time
Expand Down
3 changes: 1 addition & 2 deletions pandas/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import collections
from datetime import datetime
import re
import sys

import nose
from nose.tools import assert_equal
Expand Down Expand Up @@ -447,7 +446,7 @@ def __hash__(self):

# old-style classes in Python 2 don't appear hashable to
# collections.Hashable but also seem to support hash() by default
if sys.version_info[0] == 2:
if compat.PY2:
class OldStyleClass():
pass
c = OldStyleClass()
Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ def test_to_html_truncate(self):
</table>
<p>20 rows × 20 columns</p>
</div>'''.format(div_style)
if sys.version_info[0] < 3:
if compat.PY2:
expected = expected.decode('utf-8')
self.assertEqual(result, expected)

Expand Down Expand Up @@ -1106,7 +1106,7 @@ def test_to_html_truncate_multi_index(self):
</table>
<p>8 rows × 8 columns</p>
</div>'''.format(div_style)
if sys.version_info[0] < 3:
if compat.PY2:
expected = expected.decode('utf-8')
self.assertEqual(result, expected)

Expand Down Expand Up @@ -1216,7 +1216,7 @@ def test_to_html_truncate_multi_index_sparse_off(self):
</table>
<p>8 rows × 8 columns</p>
</div>'''.format(div_style)
if sys.version_info[0] < 3:
if compat.PY2:
expected = expected.decode('utf-8')
self.assertEqual(result, expected)

Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ def test_format(self):
# windows has different precision on datetime.datetime.now (it doesn't include us
# since the default for Timestamp shows these but Index formating does not
# we are skipping
if not is_platform_windows:
if not is_platform_windows():
formatted = index.format()
expected = [str(index[0])]
self.assertEqual(formatted, expected)
Expand Down
3 changes: 1 addition & 2 deletions pandas/tools/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def setUpClass(cls):
if not cls.locales:
raise nose.SkipTest("No locales found")

if os.name == 'nt': # we're on windows
raise nose.SkipTest("Running on Windows")
tm._skip_if_windows()

@classmethod
def tearDownClass(cls):
Expand Down
8 changes: 1 addition & 7 deletions pandas/tseries/tests/test_daterange.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime
from pandas.compat import range
import nose
import sys
import numpy as np

from pandas.core.index import Index
Expand All @@ -16,11 +15,6 @@
import pandas.util.testing as tm


def _skip_if_windows_python_3():
if sys.version_info > (3,) and sys.platform == 'win32':
raise nose.SkipTest("not used on python 3/win32")


def eq_gen_range(kwargs, expected):
rng = generate_range(**kwargs)
assert(np.array_equal(list(rng), expected))
Expand Down Expand Up @@ -459,7 +453,7 @@ def test_month_range_union_tz_pytz(self):
early_dr.union(late_dr)

def test_month_range_union_tz_dateutil(self):
_skip_if_windows_python_3()
tm._skip_if_windows_python_3()
tm._skip_if_no_dateutil()
from pandas.tslib import _dateutil_gettz as timezone
tz = timezone('US/Eastern')
Expand Down
10 changes: 1 addition & 9 deletions pandas/tseries/tests/test_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ def _skip_if_has_locale():
if lang is not None:
raise nose.SkipTest("Specific locale is set {0}".format(lang))

def _skip_if_windows_python_3():
if sys.version_info > (3,) and sys.platform == 'win32':
raise nose.SkipTest("not used on python 3/win32")

def _skip_if_not_windows_python_3():
if sys.version_info < (3,) or sys.platform != 'win32':
raise nose.SkipTest("only run on python 3/win32")


class TestTimeSeriesDuplicates(tm.TestCase):
_multiprocess_can_split_ = True
Expand Down Expand Up @@ -417,7 +409,7 @@ def test_timestamp_to_datetime_explicit_pytz(self):
self.assertEqual(stamp.tzinfo, dtval.tzinfo)

def test_timestamp_to_datetime_explicit_dateutil(self):
_skip_if_windows_python_3()
tm._skip_if_windows_python_3()
tm._skip_if_no_dateutil()
from pandas.tslib import _dateutil_gettz as gettz
rng = date_range('20090415', '20090519',
Expand Down
6 changes: 2 additions & 4 deletions pandas/tseries/tests/test_timezones.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# pylint: disable-msg=E1101,W0612
from datetime import datetime, timedelta, tzinfo, date
import sys
import os
import nose

import numpy as np
Expand Down Expand Up @@ -837,8 +835,8 @@ def localize(self, tz, x):
return x.replace(tzinfo=tz)

def test_utc_with_system_utc(self):
if sys.platform == 'win32':
raise nose.SkipTest('Skipped on win32 due to dateutil bug.')
# Skipped on win32 due to dateutil bug
tm._skip_if_windows()

from pandas.tslib import maybe_get_tz

Expand Down
13 changes: 12 additions & 1 deletion pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import pandas.compat as compat
from pandas.compat import(
filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
raise_with_traceback, httplib
raise_with_traceback, httplib, is_platform_windows
)

from pandas.computation import expressions as expr
Expand Down Expand Up @@ -223,6 +223,17 @@ def _skip_if_no_dateutil():
raise nose.SkipTest("dateutil not installed")


def _skip_if_windows_python_3():
if compat.PY3 and is_platform_windows():
import nose
raise nose.SkipTest("not used on python 3/win32")

def _skip_if_windows():
if is_platform_windows():
import nose
raise nose.SkipTest("Running on Windows")


def _skip_if_no_cday():
from pandas.core.datetools import cday
if cday is None:
Expand Down