Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
move one unit test from the standard series of unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed May 14, 2017
1 parent 01bb379 commit 8852d1b
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 47 deletions.
1 change: 1 addition & 0 deletions .local.jenkins.win.yml
Expand Up @@ -14,6 +14,7 @@ install:
- pip freeze > pip_freeze.txt
script:
- { CMD: "python -X faulthandler -X showrefcount -u setup.py unittests", NAME: "UT" }
- { CMD: "python -X faulthandler -X showrefcount -u setup.py unittests_LONG", NAME: "UT_LONG"}
after_script:
- python setup.py bdist_wheel
- if [ ${DIST} != "conda" and ${VERSION} == "3.5" and ${NAME} == "UT" ] then copy dist\*.whl ..\..\local_pypi\local_pypi_server fi
Expand Down
93 changes: 93 additions & 0 deletions _unittests/ut_finance/test_LONG_stock_file.py
@@ -0,0 +1,93 @@
"""
@brief test log(time=3s)
"""


import sys
import os
import unittest
import datetime
import warnings


try:
import src
import pyquickhelper as skip_
except ImportError:
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..")))
if path not in sys.path:
sys.path.append(path)
path = os.path.normpath(
os.path.abspath(
os.path.join(
os.path.split(__file__)[0],
"..",
"..",
"..",
"pyquickhelper",
"src")))
if path not in sys.path:
sys.path.append(path)
import src
import pyquickhelper as skip_

from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import is_travis_or_appveyor
from src.pyensae.finance.astock import StockPrices


class TestLONGStockFile (unittest.TestCase):

def test_save_stock_google(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
cache = os.path.abspath(os.path.split(__file__)[0])
cache = os.path.join(cache, "temp_cache_file_google")
name = os.path.join(cache, "NASDAQ_GOOG.2000-01-03.2014-01-15.txt")
if os.path.exists(name):
os.remove(name)

try:
stock = StockPrices(
"NASDAQ:GOOG",
url="google",
folder=cache,
end=datetime.datetime(
2014,
1,
15))
except ImportError as e:
# There is an issue with pandas_datareader on travis.
# Not up to date with the latest pandas.
if is_travis_or_appveyor():
warnings.warn(
"Probably an issue with pandas_datareader.\n" + str(e))
return
else:
raise e

file = os.path.join(cache, "save.txt")
if os.path.exists(file):
os.remove(file)
stock.to_csv(file)
assert os.path.exists(file)

stock2 = StockPrices(file, sep="\t")
assert stock.dataframe.shape == stock2.dataframe.shape
df = stock2.dataframe
file = os.path.join(cache, "out_excel.xlsx")
if os.path.exists(file):
os.remove(file)
df.to_excel(file)
assert os.path.exists(file)


if __name__ == "__main__":
unittest.main()
47 changes: 0 additions & 47 deletions _unittests/ut_finance/test_stock_file.py
Expand Up @@ -7,7 +7,6 @@
import os
import unittest
import datetime
import warnings


try:
Expand Down Expand Up @@ -37,7 +36,6 @@
import pyquickhelper as skip_

from pyquickhelper.loghelper import fLOG
from pyquickhelper.pycode import is_travis_or_appveyor
from src.pyensae.finance.astock import StockPrices


Expand Down Expand Up @@ -77,51 +75,6 @@ def test_save_stock(self):
df.to_excel(file)
assert os.path.exists(file)

def test_save_stock_google(self):
fLOG(
__file__,
self._testMethodName,
OutputPrint=__name__ == "__main__")
cache = os.path.abspath(os.path.split(__file__)[0])
cache = os.path.join(cache, "temp_cache_file_google")
name = os.path.join(cache, "NASDAQ_GOOG.2000-01-03.2014-01-15.txt")
if os.path.exists(name):
os.remove(name)

try:
stock = StockPrices(
"NASDAQ:GOOG",
url="google",
folder=cache,
end=datetime.datetime(
2014,
1,
15))
except ImportError as e:
# There is an issue with pandas_datareader on travis.
# Not up to date with the latest pandas.
if is_travis_or_appveyor():
warnings.warn(
"Probably an issue with pandas_datareader.\n" + str(e))
return
else:
raise e

file = os.path.join(cache, "save.txt")
if os.path.exists(file):
os.remove(file)
stock.to_csv(file)
assert os.path.exists(file)

stock2 = StockPrices(file, sep="\t")
assert stock.dataframe.shape == stock2.dataframe.shape
df = stock2.dataframe
file = os.path.join(cache, "out_excel.xlsx")
if os.path.exists(file):
os.remove(file)
df.to_excel(file)
assert os.path.exists(file)


if __name__ == "__main__":
unittest.main()

0 comments on commit 8852d1b

Please sign in to comment.