Skip to content

Commit

Permalink
Add timezone test for various symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiche committed Aug 4, 2024
1 parent bf4f9e4 commit 6680081
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tests/test_ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
python -m unittest tests.ticker.TestTicker
"""
import datetime

import pandas as pd
import parameterized
import pytz

from .context import yfinance as yf
from .context import session_gbl
from yfinance.exceptions import YFChartError, YFInvalidPeriodError, YFNotImplementedError, YFTickerMissingError, YFTzMissingError

from datetime import datetime

import unittest
import requests_cache
Expand Down Expand Up @@ -289,6 +293,7 @@ def test_earnings_dates(self):
data = self.ticker.earnings_dates
self.assertIsInstance(data, pd.DataFrame, "data has wrong type")
self.assertFalse(data.empty, "data is empty")
self.assertEqual(data.index.tz.zone, "America/New_York")

def test_earnings_dates_with_limit(self):
# use ticker with lots of historic earnings
Expand Down Expand Up @@ -330,6 +335,15 @@ def test_earning_dates_have_tz(self):
# data_cached = self.ticker.earnings_trend
# self.assertIs(data, data_cached, "data not cached")

def test_ticker_has_tz(self):
test_data = {"O2D.DE": "UTC", "LHA.DE": "Europe/Berlin"}
for symbol, tz in test_data.items():
with self.subTest(f"{symbol}-{tz}"):
ticker = yf.Ticker(symbol)
data = ticker.get_earnings_dates(limit=1)
self.assertIsNotNone(data.index.tz)
self.assertEqual(data.index.tz.zone, tz)


class TestTickerHolders(unittest.TestCase):
session = None
Expand Down

0 comments on commit 6680081

Please sign in to comment.