Skip to content
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

Fixed test_search failing with Python 3.4 on Ubuntu. #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 16 additions & 12 deletions fredapi/tests/test_fred.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,26 +79,32 @@ def __init__(self, rel_url, response=None, side_effect=None):
<seriess realtime_start="2015-07-19" realtime_end="2015-07-19"
order_by="series_id" sort_order="asc" count="6164"
offset="0" limit="1000">
<series id="PCPI01001" realtime_start="2015-07-19" realtime_end="2015-07-19"
<series id="PCPI01001" realtime_start="2015-07-19"
realtime_end="2015-07-19"
title="Per Capita Personal Income in Autauga County, AL"
observation_start="1969-01-01" observation_end="2013-01-01"
frequency="Annual" frequency_short="A" units="Dollars"
units_short="$" seasonal_adjustment="Not Seasonally Adjusted"
seasonal_adjustment_short="NSA" last_updated="2015-01-29 12:10:21-06"
seasonal_adjustment_short="NSA"
last_updated="2015-01-29 12:10:21-06"
popularity="0" notes="..." />
<series id="PCPI01003" realtime_start="2015-07-19" realtime_end="2015-07-19"
<series id="PCPI01003" realtime_start="2015-07-19"
realtime_end="2015-07-19"
title="Per Capita Personal Income in Baldwin County, AL"
observation_start="1969-01-01" observation_end="2013-01-01"
frequency="Annual" frequency_short="A" units="Dollars"
units_short="$" seasonal_adjustment="Not Seasonally Adjusted"
seasonal_adjustment_short="NSA" last_updated="2015-01-29 12:10:21-06"
seasonal_adjustment_short="NSA"
last_updated="2015-01-29 12:10:21-06"
popularity="0" notes="..." />
<series id="PCPI01005" realtime_start="2015-07-19" realtime_end="2015-07-19"
<series id="PCPI01005" realtime_start="2015-07-19"
realtime_end="2015-07-19"
title="Per Capita Personal Income in Barbour County, AL"
observation_start="1969-01-01" observation_end="2013-01-01"
frequency="Annual" frequency_short="A" units="Dollars"
units_short="$" seasonal_adjustment="Not Seasonally Adjusted"
seasonal_adjustment_short="NSA" last_updated="2015-01-29 12:10:21-06"
seasonal_adjustment_short="NSA"
last_updated="2015-01-29 12:10:21-06"
popularity="0" notes="..." />
<!-- more series come here, but not useful for the test... -->
</seriess>
Expand Down Expand Up @@ -150,7 +156,6 @@ def setUp(self):
self.fake_fred_call = fake_fred_call
self.__original_urlopen = fredapi.fred.urlopen


def tearDown(self):
"""Cleanup."""
pass
Expand Down Expand Up @@ -230,9 +235,9 @@ def test_invalid_kwarg_in_get_series(self, urlopen):
"""Test invalid keyword argument in call to get_series."""
url = '{}/series?series_id=invalid&api_key={}'.format(self.root_url,
fred_api_key)
side_effect = fredapi.fred.HTTPError(url, 400, '', '', sys.stderr)
side_effect = fredapi.fred.HTTPError(url, 400, '', '', io.StringIO())
self.prepare_urlopen(urlopen, side_effect=side_effect)
with self.assertRaises(ValueError) as context:
with self.assertRaises(ValueError):
self.fred.get_series('SP500',
observation_start='invalid-datetime-str')
self.assertFalse(urlopen.called)
Expand All @@ -249,12 +254,11 @@ def test_search(self, urlopen):
'seasonal_adjustment_short']])
expected = textwrap.dedent('''\
popularity observation_start seasonal_adjustment_short
series id
series id
PCPI01001 0 1969-01-01 NSA
PCPI01003 0 1969-01-01 NSA
PCPI01005 0 1969-01-01 NSA''')
for aline, eline in zip(actual.split('\n'), expected.split('\n')):
self.assertEqual(aline.strip(), eline.strip())
self.assertEqual(actual.split('\n'), expected.split('\n'))


if __name__ == '__main__':
Expand Down