Skip to content

Commit b0cd607

Browse files
committed
Merge pull request #5073 from cpcloud/travis-locale
TST/CI: make sure that locales are tested
2 parents 6ee748e + 4d4b3a0 commit b0cd607

File tree

12 files changed

+458
-184
lines changed

12 files changed

+458
-184
lines changed

.travis.yml

+7-10
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ python:
66
matrix:
77
include:
88
- python: 2.6
9-
env: NOSE_ARGS="not slow" CLIPBOARD=xclip
9+
env: NOSE_ARGS="not slow" CLIPBOARD=xclip LOCALE_OVERRIDE="it_IT.UTF-8"
1010
- python: 2.7
1111
env: NOSE_ARGS="slow and not network" LOCALE_OVERRIDE="zh_CN.GB18030" FULL_DEPS=true JOB_TAG=_LOCALE
1212
- python: 2.7
13-
env: NOSE_ARGS="not slow" FULL_DEPS=true GUI=gtk2
13+
env: NOSE_ARGS="not slow" FULL_DEPS=true CLIPBOARD_GUI=gtk2
1414
- python: 3.2
15-
env: NOSE_ARGS="not slow" FULL_DEPS=true GUI=qt4
15+
env: NOSE_ARGS="not slow" FULL_DEPS=true CLIPBOARD_GUI=qt4
1616
- python: 3.3
1717
env: NOSE_ARGS="not slow" FULL_DEPS=true CLIPBOARD=xsel
1818
exclude:
@@ -25,28 +25,25 @@ virtualenv:
2525
system_site_packages: true
2626

2727
before_install:
28-
- echo "Waldo1"
28+
- echo "before_install"
2929
- echo $VIRTUAL_ENV
3030
- df -h
3131
- date
32-
# - export PIP_ARGS=-q # comment this this to debug travis install issues
33-
# - export APT_ARGS=-qq # comment this to debug travis install issues
34-
# - set -x # enable this to see bash commands
35-
- export ZIP_FLAGS=-q # comment this to debug travis install issues
3632
- ci/before_install.sh
3733
- python -V
34+
# Xvfb stuff for clipboard functionality; see the travis-ci documentation
3835
- export DISPLAY=:99.0
3936
- sh -e /etc/init.d/xvfb start
4037

4138
install:
42-
- echo "Waldo2"
39+
- echo "install"
4340
- ci/install.sh
4441

4542
before_script:
4643
- mysql -e 'create database pandas_nosetest;'
4744

4845
script:
49-
- echo "Waldo3"
46+
- echo "script"
5047
- ci/script.sh
5148

5249
after_script:

ci/install.sh

+51-20
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,37 @@
1313
# (no compiling needed), then directly goto script and collect 200$.
1414
#
1515

16-
echo "inside $0"
16+
function edit_init()
17+
{
18+
if [ -n "$LOCALE_OVERRIDE" ]; then
19+
echo "Adding locale to the first line of pandas/__init__.py"
20+
rm -f pandas/__init__.pyc
21+
sedc="3iimport locale\nlocale.setlocale(locale.LC_ALL, '$LOCALE_OVERRIDE')\n"
22+
sed -i "$sedc" pandas/__init__.py
23+
echo "head -4 pandas/__init__.py"
24+
head -4 pandas/__init__.py
25+
echo
26+
fi
27+
}
28+
29+
edit_init
1730

1831
# Install Dependencies
19-
# as of pip 1.4rc2, wheel files are still being broken regularly, this is a known good
20-
# commit. should revert to pypi when a final release is out
21-
pip install -I git+https://github.com/pypa/pip@42102e9deaea99db08b681d06906c2945f6f95e2#egg=pip
22-
pv="${TRAVIS_PYTHON_VERSION:0:1}"
23-
[ "$pv" == "2" ] && pv=""
32+
# as of pip 1.4rc2, wheel files are still being broken regularly, this is a
33+
# known good commit. should revert to pypi when a final release is out
34+
pip_commit=42102e9deaea99db08b681d06906c2945f6f95e2
35+
pip install -I git+https://github.com/pypa/pip@$pip_commit#egg=pip
36+
37+
python_major_version="${TRAVIS_PYTHON_VERSION:0:1}"
38+
[ "$python_major_version" == "2" ] && python_major_version=""
2439

2540
pip install -I -U setuptools
2641
pip install wheel
2742

2843
# comment this line to disable the fetching of wheel files
29-
PIP_ARGS+=" -I --use-wheel --find-links=http://cache27diy-cpycloud.rhcloud.com/${TRAVIS_PYTHON_VERSION}${JOB_TAG}/"
44+
base_url=http://cache27diy-cpycloud.rhcloud.com
45+
wheel_box=${TRAVIS_PYTHON_VERSION}${JOB_TAG}
46+
PIP_ARGS+=" -I --use-wheel --find-links=$base_url/$wheel_box/"
3047

3148
# Force virtualenv to accpet system_site_packages
3249
rm -f $VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/no-global-site-packages.txt
@@ -35,39 +52,53 @@ rm -f $VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/no-global-site-packages.txt
3552
if [ -n "$LOCALE_OVERRIDE" ]; then
3653
# make sure the locale is available
3754
# probably useless, since you would need to relogin
38-
sudo locale-gen "$LOCALE_OVERRIDE"
55+
time sudo locale-gen "$LOCALE_OVERRIDE"
3956
fi
4057

41-
4258
# show-skipped is working at this particular commit
43-
time pip install git+git://github.com/cpcloud/nose-show-skipped.git@fa4ff84e53c09247753a155b428c1bf2c69cb6c3
44-
time pip install $PIP_ARGS -r ci/requirements-${TRAVIS_PYTHON_VERSION}${JOB_TAG}.txt
45-
time sudo apt-get install libatlas-base-dev gfortran
59+
show_skipped_commit=fa4ff84e53c09247753a155b428c1bf2c69cb6c3
60+
time pip install git+git://github.com/cpcloud/nose-show-skipped.git@$show_skipped_commit
61+
time pip install $PIP_ARGS -r ci/requirements-${wheel_box}.txt
62+
63+
# we need these for numpy
64+
time sudo apt-get $APT_ARGS install libatlas-base-dev gfortran
65+
66+
67+
# Need to enable for locale testing. The location of the locale file(s) is
68+
# distro specific. For example, on Arch Linux all of the locales are in a
69+
# commented file--/etc/locale.gen--that must be commented in to be used
70+
# whereas Ubuntu looks in /var/lib/locales/supported.d/* and generates locales
71+
# based on what's in the files in that folder
72+
time echo 'it_CH.UTF-8 UTF-8' | sudo tee -a /var/lib/locales/supported.d/it
73+
time sudo locale-gen
4674

4775

4876
# install gui for clipboard testing
49-
if [ -n "$GUI" ]; then
50-
echo "Using GUI clipboard: $GUI"
51-
[ -n "$pv" ] && py="py"
52-
time sudo apt-get $APT_ARGS install python${pv}-${py}${GUI}
77+
if [ -n "$CLIPBOARD_GUI" ]; then
78+
echo "Using CLIPBOARD_GUI: $CLIPBOARD_GUI"
79+
[ -n "$python_major_version" ] && py="py"
80+
python_cb_gui_pkg=python${python_major_version}-${py}${CLIPBOARD_GUI}
81+
time sudo apt-get $APT_ARGS install $python_cb_gui_pkg
5382
fi
5483

5584

56-
# install a clipboard
85+
# install a clipboard if $CLIPBOARD is not empty
5786
if [ -n "$CLIPBOARD" ]; then
5887
echo "Using clipboard: $CLIPBOARD"
5988
time sudo apt-get $APT_ARGS install $CLIPBOARD
6089
fi
6190

6291

6392
# Optional Deps
64-
if [ x"$FULL_DEPS" == x"true" ]; then
93+
if [ -n "$FULL_DEPS" ]; then
6594
echo "Installing FULL_DEPS"
66-
# for pytables gets the lib as well
95+
96+
# need libhdf5 for PyTables
6797
time sudo apt-get $APT_ARGS install libhdf5-serial-dev
6898
fi
6999

70-
# build pandas
100+
101+
# build and install pandas
71102
time python setup.py build_ext install
72103

73104
true

ci/script.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ echo "inside $0"
55
if [ -n "$LOCALE_OVERRIDE" ]; then
66
export LC_ALL="$LOCALE_OVERRIDE";
77
echo "Setting LC_ALL to $LOCALE_OVERRIDE"
8-
(cd /; python -c 'import pandas; print("pandas detected console encoding: %s" % pandas.get_option("display.encoding"))')
9-
8+
pycmd='import pandas; print("pandas detected console encoding: %s" % pandas.get_option("display.encoding"))'
9+
python -c "$pycmd"
1010
fi
1111

1212
echo nosetests --exe -w /tmp -A "$NOSE_ARGS" pandas --show-skipped

doc/source/release.rst

+3
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,9 @@ Bug Fixes
578578
- Fix a bug with ``NDFrame.replace()`` which made replacement appear as
579579
though it was (incorrectly) using regular expressions (:issue:`5143`).
580580
- Fix better error message for to_datetime (:issue:`4928`)
581+
- Made sure different locales are tested on travis-ci (:issue:`4918`). Also
582+
adds a couple of utilities for getting locales and setting locales with a
583+
context manager.
581584

582585
pandas 0.12.0
583586
-------------

pandas/io/tests/test_data.py

+40-27
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pandas.io.data import DataReader, SymbolWarning
1414
from pandas.util.testing import (assert_series_equal, assert_produces_warning,
1515
network, assert_frame_equal)
16+
import pandas.util.testing as tm
1617
from numpy.testing import assert_array_equal
1718

1819

@@ -35,6 +36,15 @@ def assert_n_failed_equals_n_null_columns(wngs, obj, cls=SymbolWarning):
3536

3637

3738
class TestGoogle(unittest.TestCase):
39+
@classmethod
40+
def setUpClass(cls):
41+
cls.locales = tm.get_locales(prefix='en_US')
42+
if not cls.locales:
43+
raise nose.SkipTest("US English locale not available for testing")
44+
45+
@classmethod
46+
def tearDownClass(cls):
47+
del cls.locales
3848

3949
@network
4050
def test_google(self):
@@ -44,9 +54,10 @@ def test_google(self):
4454
start = datetime(2010, 1, 1)
4555
end = datetime(2013, 1, 27)
4656

47-
self.assertEquals(
48-
web.DataReader("F", 'google', start, end)['Close'][-1],
49-
13.68)
57+
for locale in self.locales:
58+
with tm.set_locale(locale):
59+
panel = web.DataReader("F", 'google', start, end)
60+
self.assertEquals(panel.Close[-1], 13.68)
5061

5162
self.assertRaises(Exception, web.DataReader, "NON EXISTENT TICKER",
5263
'google', start, end)
@@ -58,38 +69,40 @@ def test_get_quote_fails(self):
5869

5970
@network
6071
def test_get_goog_volume(self):
61-
df = web.get_data_google('GOOG')
62-
self.assertEqual(df.Volume.ix['OCT-08-2010'], 2863473)
72+
for locale in self.locales:
73+
with tm.set_locale(locale):
74+
df = web.get_data_google('GOOG').sort_index()
75+
self.assertEqual(df.Volume.ix['OCT-08-2010'], 2863473)
6376

6477
@network
6578
def test_get_multi1(self):
66-
sl = ['AAPL', 'AMZN', 'GOOG']
67-
pan = web.get_data_google(sl, '2012')
68-
69-
def testit():
79+
for locale in self.locales:
80+
sl = ['AAPL', 'AMZN', 'GOOG']
81+
with tm.set_locale(locale):
82+
pan = web.get_data_google(sl, '2012')
7083
ts = pan.Close.GOOG.index[pan.Close.AAPL > pan.Close.GOOG]
71-
self.assertEquals(ts[0].dayofyear, 96)
72-
73-
if (hasattr(pan, 'Close') and hasattr(pan.Close, 'GOOG') and
74-
hasattr(pan.Close, 'AAPL')):
75-
testit()
76-
else:
77-
self.assertRaises(AttributeError, testit)
84+
if (hasattr(pan, 'Close') and hasattr(pan.Close, 'GOOG') and
85+
hasattr(pan.Close, 'AAPL')):
86+
self.assertEquals(ts[0].dayofyear, 96)
87+
else:
88+
self.assertRaises(AttributeError, lambda: pan.Close)
7889

7990
@network
8091
def test_get_multi2(self):
8192
with warnings.catch_warnings(record=True) as w:
82-
pan = web.get_data_google(['GE', 'MSFT', 'INTC'], 'JAN-01-12',
83-
'JAN-31-12')
84-
result = pan.Close.ix['01-18-12']
85-
assert_n_failed_equals_n_null_columns(w, result)
86-
87-
# sanity checking
88-
89-
assert np.issubdtype(result.dtype, np.floating)
90-
result = pan.Open.ix['Jan-15-12':'Jan-20-12']
91-
self.assertEqual((4, 3), result.shape)
92-
assert_n_failed_equals_n_null_columns(w, result)
93+
for locale in self.locales:
94+
with tm.set_locale(locale):
95+
pan = web.get_data_google(['GE', 'MSFT', 'INTC'],
96+
'JAN-01-12', 'JAN-31-12')
97+
result = pan.Close.ix['01-18-12']
98+
assert_n_failed_equals_n_null_columns(w, result)
99+
100+
# sanity checking
101+
102+
assert np.issubdtype(result.dtype, np.floating)
103+
result = pan.Open.ix['Jan-15-12':'Jan-20-12']
104+
self.assertEqual((4, 3), result.shape)
105+
assert_n_failed_equals_n_null_columns(w, result)
93106

94107

95108
class TestYahoo(unittest.TestCase):

0 commit comments

Comments
 (0)