Skip to content

Commit e660c05

Browse files
committed
Merge pull request #10542 from schettino72/10151-cleanup-up-platform-python-version-checks
CLN: cleanup up platform / python version checks. fix GB10151
2 parents b9e5f1e + d82721c commit e660c05

File tree

13 files changed

+28
-39
lines changed

13 files changed

+28
-39
lines changed

bench/bench_sparse.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
import numpy as np
32

43
from pandas import *
@@ -30,7 +29,7 @@
3029
s1_dense = s1.to_dense()
3130
s2_dense = s2.to_dense()
3231

33-
if 'linux' in sys.platform:
32+
if compat.is_platform_linux():
3433
pth = '/home/wesm/code/pandas/example'
3534
else:
3635
pth = '/Users/wesm/code/pandas/example'

pandas/computation/tests/test_eval.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ def test_floor_division(self):
163163
self.check_floor_division(lhs, '//', rhs)
164164

165165
def test_pow(self):
166-
import platform
167-
if platform.system() == 'Windows':
168-
raise nose.SkipTest('not testing pow on Windows')
166+
tm._skip_if_windows()
169167

170168
# odd failure on win32 platform, so skip
171169
for lhs, rhs in product(self.lhses, self.rhses):

pandas/io/tests/test_json/test_ujson.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def _skip_if_python_ver(skip_major, skip_minor=None):
3636
raise nose.SkipTest("skipping Python version %d.%d" % (major, minor))
3737

3838

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

4242
class UltraJSONTests(TestCase):

pandas/io/tests/test_parsers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def test_empty_string(self):
163163

164164
def test_read_csv(self):
165165
if not compat.PY3:
166-
if 'win' in sys.platform:
166+
if compat.is_platform_windows():
167167
prefix = u("file:///")
168168
else:
169169
prefix = u("file://")

pandas/io/tests/test_pytables.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2067,9 +2067,8 @@ def test_store_timezone(self):
20672067
# GH2852
20682068
# issue storing datetime.date with a timezone as it resets when read back in a new timezone
20692069

2070-
import platform
2071-
if platform.system() == "Windows":
2072-
raise nose.SkipTest("timezone setting not supported on windows")
2070+
# timezone setting not supported on windows
2071+
tm._skip_if_windows()
20732072

20742073
import datetime
20752074
import time

pandas/tests/test_common.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import collections
33
from datetime import datetime
44
import re
5-
import sys
65

76
import nose
87
from nose.tools import assert_equal
@@ -447,7 +446,7 @@ def __hash__(self):
447446

448447
# old-style classes in Python 2 don't appear hashable to
449448
# collections.Hashable but also seem to support hash() by default
450-
if sys.version_info[0] == 2:
449+
if compat.PY2:
451450
class OldStyleClass():
452451
pass
453452
c = OldStyleClass()

pandas/tests/test_format.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ def test_to_html_truncate(self):
990990
</table>
991991
<p>20 rows × 20 columns</p>
992992
</div>'''.format(div_style)
993-
if sys.version_info[0] < 3:
993+
if compat.PY2:
994994
expected = expected.decode('utf-8')
995995
self.assertEqual(result, expected)
996996

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

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

pandas/tests/test_index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ def test_format(self):
10221022
# windows has different precision on datetime.datetime.now (it doesn't include us
10231023
# since the default for Timestamp shows these but Index formating does not
10241024
# we are skipping
1025-
if not is_platform_windows:
1025+
if not is_platform_windows():
10261026
formatted = index.format()
10271027
expected = [str(index[0])]
10281028
self.assertEqual(formatted, expected)

pandas/tools/tests/test_util.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ def setUpClass(cls):
4343
if not cls.locales:
4444
raise nose.SkipTest("No locales found")
4545

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

4948
@classmethod
5049
def tearDownClass(cls):

pandas/tseries/tests/test_daterange.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime
22
from pandas.compat import range
33
import nose
4-
import sys
54
import numpy as np
65

76
from pandas.core.index import Index
@@ -16,11 +15,6 @@
1615
import pandas.util.testing as tm
1716

1817

19-
def _skip_if_windows_python_3():
20-
if sys.version_info > (3,) and sys.platform == 'win32':
21-
raise nose.SkipTest("not used on python 3/win32")
22-
23-
2418
def eq_gen_range(kwargs, expected):
2519
rng = generate_range(**kwargs)
2620
assert(np.array_equal(list(rng), expected))
@@ -459,7 +453,7 @@ def test_month_range_union_tz_pytz(self):
459453
early_dr.union(late_dr)
460454

461455
def test_month_range_union_tz_dateutil(self):
462-
_skip_if_windows_python_3()
456+
tm._skip_if_windows_python_3()
463457
tm._skip_if_no_dateutil()
464458
from pandas.tslib import _dateutil_gettz as timezone
465459
tz = timezone('US/Eastern')

pandas/tseries/tests/test_timeseries.py

+1-9
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,6 @@ def _skip_if_has_locale():
4646
if lang is not None:
4747
raise nose.SkipTest("Specific locale is set {0}".format(lang))
4848

49-
def _skip_if_windows_python_3():
50-
if sys.version_info > (3,) and sys.platform == 'win32':
51-
raise nose.SkipTest("not used on python 3/win32")
52-
53-
def _skip_if_not_windows_python_3():
54-
if sys.version_info < (3,) or sys.platform != 'win32':
55-
raise nose.SkipTest("only run on python 3/win32")
56-
5749

5850
class TestTimeSeriesDuplicates(tm.TestCase):
5951
_multiprocess_can_split_ = True
@@ -417,7 +409,7 @@ def test_timestamp_to_datetime_explicit_pytz(self):
417409
self.assertEqual(stamp.tzinfo, dtval.tzinfo)
418410

419411
def test_timestamp_to_datetime_explicit_dateutil(self):
420-
_skip_if_windows_python_3()
412+
tm._skip_if_windows_python_3()
421413
tm._skip_if_no_dateutil()
422414
from pandas.tslib import _dateutil_gettz as gettz
423415
rng = date_range('20090415', '20090519',

pandas/tseries/tests/test_timezones.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# pylint: disable-msg=E1101,W0612
22
from datetime import datetime, timedelta, tzinfo, date
3-
import sys
4-
import os
53
import nose
64

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

839837
def test_utc_with_system_utc(self):
840-
if sys.platform == 'win32':
841-
raise nose.SkipTest('Skipped on win32 due to dateutil bug.')
838+
# Skipped on win32 due to dateutil bug
839+
tm._skip_if_windows()
842840

843841
from pandas.tslib import maybe_get_tz
844842

pandas/util/testing.py

+12-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import pandas.compat as compat
2929
from pandas.compat import(
3030
filter, map, zip, range, unichr, lrange, lmap, lzip, u, callable, Counter,
31-
raise_with_traceback, httplib
31+
raise_with_traceback, httplib, is_platform_windows
3232
)
3333

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

225225

226+
def _skip_if_windows_python_3():
227+
if compat.PY3 and is_platform_windows():
228+
import nose
229+
raise nose.SkipTest("not used on python 3/win32")
230+
231+
def _skip_if_windows():
232+
if is_platform_windows():
233+
import nose
234+
raise nose.SkipTest("Running on Windows")
235+
236+
226237
def _skip_if_no_cday():
227238
from pandas.core.datetools import cday
228239
if cday is None:

0 commit comments

Comments
 (0)