Skip to content

Commit 4d4b3a0

Browse files
committed
TST: only test Google Finance if there is at least one US English locale
1 parent c4b83b7 commit 4d4b3a0

File tree

6 files changed

+213
-182
lines changed

6 files changed

+213
-182
lines changed

.travis.yml

+6-9
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ matrix:
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

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

16-
function edit_init() {
16+
function edit_init()
17+
{
1718
if [ -n "$LOCALE_OVERRIDE" ]; then
18-
pandas_dir=pandas
19-
echo "Adding locale to the first line of $pandas_dir/__init__.py"
20-
rm -f $pandas_dir/__init__.pyc
21-
sedc="1iimport locale; locale.setlocale(locale.LC_ALL, '$LOCALE_OVERRIDE')"
22-
sed -i "$sedc" $pandas_dir/__init__.py
23-
echo "First line of $pandas_dir/__init__.py"
24-
head $pandas_dir/__init__.py
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
2526
fi
2627
}
2728

28-
echo "inside $0"
29+
edit_init
2930

3031
# Install Dependencies
31-
# as of pip 1.4rc2, wheel files are still being broken regularly, this is a known good
32-
# commit. should revert to pypi when a final release is out
33-
pip install -I git+https://github.com/pypa/pip@42102e9deaea99db08b681d06906c2945f6f95e2#egg=pip
34-
pv="${TRAVIS_PYTHON_VERSION:0:1}"
35-
[ "$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=""
3639

3740
pip install -I -U setuptools
3841
pip install wheel
3942

4043
# comment this line to disable the fetching of wheel files
41-
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/"
4247

4348
# Force virtualenv to accpet system_site_packages
4449
rm -f $VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/no-global-site-packages.txt
@@ -47,47 +52,53 @@ rm -f $VIRTUAL_ENV/lib/python$TRAVIS_PYTHON_VERSION/no-global-site-packages.txt
4752
if [ -n "$LOCALE_OVERRIDE" ]; then
4853
# make sure the locale is available
4954
# probably useless, since you would need to relogin
50-
sudo locale-gen "$LOCALE_OVERRIDE"
55+
time sudo locale-gen "$LOCALE_OVERRIDE"
5156
fi
5257

53-
5458
# show-skipped is working at this particular commit
55-
time pip install git+git://github.com/cpcloud/nose-show-skipped.git@fa4ff84e53c09247753a155b428c1bf2c69cb6c3
56-
time pip install $PIP_ARGS -r ci/requirements-${TRAVIS_PYTHON_VERSION}${JOB_TAG}.txt
57-
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
5865

5966

60-
# need to enable for locale testing
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
6172
time echo 'it_CH.UTF-8 UTF-8' | sudo tee -a /var/lib/locales/supported.d/it
6273
time sudo locale-gen
6374

6475

6576
# install gui for clipboard testing
66-
if [ -n "$GUI" ]; then
67-
echo "Using GUI clipboard: $GUI"
68-
[ -n "$pv" ] && py="py"
69-
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
7082
fi
7183

7284

73-
# install a clipboard
85+
# install a clipboard if $CLIPBOARD is not empty
7486
if [ -n "$CLIPBOARD" ]; then
7587
echo "Using clipboard: $CLIPBOARD"
7688
time sudo apt-get $APT_ARGS install $CLIPBOARD
7789
fi
7890

7991

8092
# Optional Deps
81-
if [ x"$FULL_DEPS" == x"true" ]; then
93+
if [ -n "$FULL_DEPS" ]; then
8294
echo "Installing FULL_DEPS"
83-
# for pytables gets the lib as well
95+
96+
# need libhdf5 for PyTables
8497
time sudo apt-get $APT_ARGS install libhdf5-serial-dev
8598
fi
8699

87100

88-
edit_init
89-
90-
# build pandas
101+
# build and install pandas
91102
time python setup.py build_ext install
92103

93104
true

pandas/io/tests/test_data.py

+38-29
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ def assert_n_failed_equals_n_null_columns(wngs, obj, cls=SymbolWarning):
3636

3737

3838
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
3948

4049
@network
4150
def test_google(self):
@@ -45,8 +54,9 @@ def test_google(self):
4554
start = datetime(2010, 1, 1)
4655
end = datetime(2013, 1, 27)
4756

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

5262
self.assertRaises(Exception, web.DataReader, "NON EXISTENT TICKER",
@@ -59,41 +69,40 @@ def test_get_quote_fails(self):
5969

6070
@network
6171
def test_get_goog_volume(self):
62-
with tm.set_locale('en_US.UTF-8'):
63-
df = web.get_data_google('GOOG').sort_index()
64-
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)
6576

6677
@network
6778
def test_get_multi1(self):
68-
sl = ['AAPL', 'AMZN', 'GOOG']
69-
with tm.set_locale('en_US.UTF-8'):
70-
pan = web.get_data_google(sl, '2012')
71-
72-
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')
7383
ts = pan.Close.GOOG.index[pan.Close.AAPL > pan.Close.GOOG]
74-
self.assertEquals(ts[0].dayofyear, 96)
75-
76-
if (hasattr(pan, 'Close') and hasattr(pan.Close, 'GOOG') and
77-
hasattr(pan.Close, 'AAPL')):
78-
testit()
79-
else:
80-
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)
8189

8290
@network
8391
def test_get_multi2(self):
8492
with warnings.catch_warnings(record=True) as w:
85-
with tm.set_locale('en_US.UTF-8'):
86-
pan = web.get_data_google(['GE', 'MSFT', 'INTC'], 'JAN-01-12',
87-
'JAN-31-12')
88-
result = pan.Close.ix['01-18-12']
89-
assert_n_failed_equals_n_null_columns(w, result)
90-
91-
# sanity checking
92-
93-
assert np.issubdtype(result.dtype, np.floating)
94-
result = pan.Open.ix['Jan-15-12':'Jan-20-12']
95-
self.assertEqual((4, 3), result.shape)
96-
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)
97106

98107

99108
class TestYahoo(unittest.TestCase):

0 commit comments

Comments
 (0)