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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 3 deletions
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 2 deletions
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

Lines changed: 1 addition & 7 deletions
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')

0 commit comments

Comments
 (0)