support py3 and minimally test

This commit is contained in:
Andy Hayden 2015-04-16 13:59:26 -07:00
parent 997f1eadf0
commit 960658e9c5
5 changed files with 60 additions and 7 deletions

14
.travis.yml Normal file
View File

@ -0,0 +1,14 @@
language: python
python:
- "2.6"
- "2.7"
- "pypy"
- "3.3"
- "3.4"
install:
- python setup.py install
script:
- nosetests

View File

@ -1,7 +1,11 @@
from urllib2 import Request, urlopen
import json
import sys
try:
from urllib.request import Request, urlopen
except ImportError: # python 2
from urllib2 import Request, urlopen
__author__ = 'Hongtao Cai'
googleFinanceKeyToFullName = {
@ -75,6 +79,6 @@ if __name__ == '__main__':
symbols = symbols.split(',')
try:
print json.dumps(getQuotes(symbols), indent=2)
print(json.dumps(getQuotes(symbols), indent=2))
except:
print "Fail"
print("Fail")

View File

@ -9,5 +9,15 @@ setup(
url = 'https://github.com/hongtaocai/googlefinance', # use the URL to the github repo
download_url = 'https://github.com/hongtaocai/googlefinance/tarball/0.4', # I'll explain this in a second
keywords = ['googlefinance', 'stock', 'price' , 'finance', 'google', 'real-time'], # arbitrary keywords
classifiers = [],
classifiers = [
'License :: OSI Approved :: MIT License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
],
)

View File

@ -0,0 +1,17 @@
import googlefinance
import unittest
class TestQuotes(unittest.TestCase):
def test_one_symbol(self):
appl = googlefinance.getQuotes('GOOG')[0]
self.assertEqual(appl["Index"], "NASDAQ")
self.assertEqual(appl["StockSymbol"], "GOOG")
def test_symbols(self):
quotes = googlefinance.getQuotes(['GOOG', 'VIE:BKS'])
self.assertEqual(quotes[0]["Index"], "NASDAQ")
self.assertEqual(quotes[0]["StockSymbol"], "GOOG")
self.assertEqual(quotes[1]["Index"], "VIE")
self.assertEqual(quotes[1]["StockSymbol"], "BKS")

8
tox.ini Normal file
View File

@ -0,0 +1,8 @@
[tox]
envlist=py{26,27,33,34}
[testenv]
commands=
nosetests
deps=
nose