mirror of
https://github.com/hongtaocai/googlefinance.git
synced 2024-06-25 14:29:40 -05:00
support py3 and minimally test
This commit is contained in:
parent
997f1eadf0
commit
960658e9c5
14
.travis.yml
Normal file
14
.travis.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
language: python
|
||||
|
||||
python:
|
||||
- "2.6"
|
||||
- "2.7"
|
||||
- "pypy"
|
||||
- "3.3"
|
||||
- "3.4"
|
||||
|
||||
install:
|
||||
- python setup.py install
|
||||
|
||||
script:
|
||||
- nosetests
|
|
@ -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")
|
||||
|
|
12
setup.py
12
setup.py
|
@ -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',
|
||||
],
|
||||
)
|
||||
|
|
17
tests/test_googlefinance.py
Normal file
17
tests/test_googlefinance.py
Normal 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")
|
||||
|
Loading…
Reference in New Issue
Block a user