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

Tests : mocking yfinance tzcache #4187

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
# IMPORTATION STANDARD
# IMPORTS STANDARD
import json
import os
import pathlib
from typing import Any, Dict, List, Optional, Type

import importlib_metadata

# IMPORTATION THIRDPARTY
# IMPORTS THIRD-PARTY
import matplotlib
import pandas as pd
import pytest
import yfinance.utils
from _pytest.capture import MultiCapture, SysCapture
from _pytest.config import Config
from _pytest.config.argparsing import Parser
from _pytest.fixtures import SubRequest
from _pytest.mark.structures import Mark

# IMPORTATION INTERNAL
# IMPORTS INTERNAL
from openbb_terminal import (
decorators,
feature_flags as obbff,
Expand All @@ -26,6 +27,7 @@

# pylint: disable=redefined-outer-name


DISPLAY_LIMIT: int = 500
EXTENSIONS_ALLOWED: List[str] = ["csv", "json", "txt"]
EXTENSIONS_MATCHING: Dict[str, List[Type]] = {
Expand Down Expand Up @@ -381,6 +383,16 @@ def mock_matplotlib(mocker):
mocker.patch("matplotlib.pyplot.show")


# pylint: disable=protected-access
@pytest.fixture(autouse=True)
def mock_yfinance_tzcache(mocker):
mocker.patch.object(
target=yfinance.utils,
attribute="_TzCache",
new=yfinance.utils._TzCacheDummy,
)


@pytest.fixture
def default_csv_path(request: SubRequest) -> str:
return build_path_by_extension(request=request, extension="csv", create_folder=True)
Expand Down