Skip to content

MAINT: Add tester #809

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

Merged
merged 1 commit into from
Aug 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 11 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ language: python
env:
global:
- TEST_TYPE="stable and not requires_api_key"
- TEST_INSTALL=false
# Doctr deploy key for pydata/pandas-datareader
- secure: "iGbOAbBSV5y0TKDh2CifRSk6OpLA9GbEEL/hscHFLSDDUCWcdfvYXda3SWJFWyoQ5QUxSigXWd+ukr4u92d7lmB7m3TWj6BAMNuRpatTgnejLNwLvNeYdvLAxPvx39Cq85frd1Rx1beBLn3h/4wm4Ah+dR5W9NH8+x3OuZMH3Eo="

Expand All @@ -19,7 +20,7 @@ matrix:
- python: 3.8
env: PANDAS=1 NUMPY=1.18
- python: 3.8
env: PANDAS=1 NUMPY=1.19
env: PANDAS=1 NUMPY=1.19 TEST_INSTALL=true
- python: 3.7
env: TEST_TYPE="quandl" PANDAS=1 NUMPY=1.19
# In allow failures
Expand All @@ -44,7 +45,15 @@ install:

script:
- if [[ -n "${TEST_TYPE+x}" ]]; then export MARKERS="-m ${TEST_TYPE}"; fi
- pytest -v -s -r xX "${MARKERS}" --cov-config .coveragerc --cov=pandas_datareader --cov-report xml:/tmp/cov-datareader.xml --junitxml=/tmp/datareader.xml
- |
if [[ ${TEST_INSTALL} = false ]]; then
pytest -v -s -r xX "${MARKERS}" --cov-config .coveragerc --cov=pandas_datareader --cov-report xml:/tmp/cov-datareader.xml --junitxml=/tmp/datareader.xml
else
mkdir pdr_test
cd pdr_test
python -c "import pandas_datareader; pandas_datareader.test()"
cd ..
fi
- black --version
- black --check pandas_datareader
- flake8 --version
Expand Down
37 changes: 35 additions & 2 deletions docs/source/whatsnew/v0.9.0.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
.. _whatsnew_091:

v0.9.1 (TBD)
------------

.. contents:: What's new in v0.9.1
:local:
:backlinks: none


.. _whatsnew_091.enhancements:

Enhancements
~~~~~~~~~~~~
- Added the method ``test`` to the package to simplify running tests from an
installation using

.. code-block:: shell

python -c "import pandas_datareader; pandas_datareader.test()"

.. _whatsnew_091.api_breaking:

Backwards incompatible API changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Immediately deprecated old symbol names for TSP to reflect the new website API

.. _whatsnew_091.bug_fixes:

Bug Fixes
~~~~~~~~~
- Update TSP web scraper to new site (:issue:`740`)

.. _whatsnew_090:

v0.9.0 (July 10, 2020)
---------------------------
----------------------

Highlights include:

Expand Down Expand Up @@ -43,7 +77,6 @@ Bug Fixes
- Correct NASDAQ symbols fields link (:issue:`715`)
- Fix Yahoo! actions bug due to change in split format (:issue:`755`)
- Fix FutureWarning from pandas import (:issue:`762`)
- Update TSP web scraper to new site (:issue:`740`)

Contributors
~~~~~~~~~~~~
Expand Down
31 changes: 31 additions & 0 deletions pandas_datareader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import os
import sys

from ._version import get_versions
from .data import (
DataReader,
Expand Down Expand Up @@ -27,6 +30,8 @@
get_tops_iex,
)

PKG = os.path.dirname(__file__)

__version__ = get_versions()["version"]
del get_versions

Expand Down Expand Up @@ -57,4 +62,30 @@
"get_data_tiingo",
"get_iex_data_tiingo",
"get_data_alphavantage",
"test",
]


def test(extra_args=None):
"""
Run the test suite

Parameters
----------
extra_args : {str, List[str]}
A string or list of strings to pass to pytest. Default is
["--only-stable", "--skip-requires-api-key"]
"""
try:
import pytest
except ImportError as err:
raise ImportError("Need pytest>=5.0.1 to run tests") from err
cmd = ["--only-stable", "--skip-requires-api-key"]
if extra_args:
if not isinstance(extra_args, list):
extra_args = [extra_args]
cmd = extra_args
cmd += [PKG]
joined = " ".join(cmd)
print(f"running: pytest {joined}")
sys.exit(pytest.main(cmd))
5 changes: 1 addition & 4 deletions pandas_datareader/av/quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
import pandas as pd

from pandas_datareader.av import AlphaVantage
from pandas_datareader.exceptions import (
DEP_ERROR_MSG,
ImmediateDeprecationError,
)
from pandas_datareader.exceptions import DEP_ERROR_MSG, ImmediateDeprecationError


class AVQuotesReader(AlphaVantage):
Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pandas as pd
from pandas.api.types import is_list_like, is_number
import pandas.io.common as com
from pandas.io import common as com
from pandas.testing import assert_frame_equal

PANDAS_VERSION = LooseVersion(pd.__version__)
Expand Down
24 changes: 24 additions & 0 deletions pandas_datareader/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
import pytest


def pytest_addoption(parser):
parser.addoption("--only-stable", action="store_true", help="run only stable tests")
parser.addoption(
"--skip-requires-api-key",
action="store_true",
help="skip tests that require an API key",
)
parser.addoption(
"--strict-data-files",
action="store_true",
help="Fail if a test is skipped for missing data file.",
)


def pytest_runtest_setup(item):
if "stable" not in item.keywords and item.config.getoption("--only-stable"):
pytest.skip("skipping due to --only-stable")

if "requires_api_key" in item.keywords and item.config.getoption(
"--skip-requires-api-key"
):
pytest.skip("skipping due to --skip-requires-api-key")


@pytest.fixture
def datapath(request):
"""Get the path to a data file.
Expand Down
10 changes: 2 additions & 8 deletions pandas_datareader/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,12 @@
from pandas_datareader.econdb import EcondbReader
from pandas_datareader.enigma import EnigmaReader
from pandas_datareader.eurostat import EurostatReader
from pandas_datareader.exceptions import (
DEP_ERROR_MSG,
ImmediateDeprecationError,
)
from pandas_datareader.exceptions import DEP_ERROR_MSG, ImmediateDeprecationError
from pandas_datareader.famafrench import FamaFrenchReader
from pandas_datareader.fred import FredReader
from pandas_datareader.iex.daily import IEXDailyReader
from pandas_datareader.iex.deep import Deep as IEXDeep
from pandas_datareader.iex.tops import (
LastReader as IEXLasts,
TopsReader as IEXTops,
)
from pandas_datareader.iex.tops import LastReader as IEXLasts, TopsReader as IEXTops
from pandas_datareader.moex import MoexReader
from pandas_datareader.nasdaq_trader import get_nasdaq_symbols
from pandas_datareader.naver import NaverDailyReader
Expand Down
5 changes: 1 addition & 4 deletions pandas_datareader/enigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

from pandas_datareader.base import _BaseReader, string_types
from pandas_datareader.compat import StringIO
from pandas_datareader.exceptions import (
DEP_ERROR_MSG,
ImmediateDeprecationError,
)
from pandas_datareader.exceptions import DEP_ERROR_MSG, ImmediateDeprecationError


class EnigmaReader(_BaseReader):
Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/io/sdmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def read_sdmx(path_or_buf, dtype="float64", dsd=None):

xdata = _read_content(path_or_buf)

import xml.etree.ElementTree as ET
from xml.etree import ElementTree as ET

root = ET.fromstring(xdata)

Expand Down Expand Up @@ -204,7 +204,7 @@ def _read_sdmx_dsd(path_or_buf):

xdata = _read_content(path_or_buf)

import xml.etree.cElementTree as ET
from xml.etree import cElementTree as ET

root = ET.fromstring(xdata)

Expand Down
7 changes: 1 addition & 6 deletions pandas_datareader/moex.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
import pandas as pd

from pandas_datareader.base import _DailyBaseReader
from pandas_datareader.compat import (
StringIO,
binary_type,
concat,
is_list_like,
)
from pandas_datareader.compat import StringIO, binary_type, concat, is_list_like


class MoexReader(_DailyBaseReader):
Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/av/test_av_quotes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

import pandas_datareader.data as web
from pandas_datareader import data as web
from pandas_datareader.exceptions import ImmediateDeprecationError

pytestmark = [
Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/io/test_jsdmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np
import pandas as pd
import pandas.testing as tm
from pandas import testing as tm
import pytest

from pandas_datareader.compat import PANDAS_0210
Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/io/test_sdmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import numpy as np
import pandas as pd
import pandas.testing as tm
from pandas import testing as tm
import pytest

from pandas_datareader.io.sdmx import _read_sdmx_dsd, read_sdmx
Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/test_bankofcanada.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest

from pandas_datareader import data as web
from pandas_datareader._utils import RemoteDataError
import pandas_datareader.data as web

pytestmark = pytest.mark.stable

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
import requests

import pandas_datareader.base as base
from pandas_datareader import base as base

pytestmark = pytest.mark.stable

Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/tests/test_econdb.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import pandas as pd
import pandas.testing as tm
from pandas import testing as tm
import pytest

import pandas_datareader.data as web
from pandas_datareader import data as web

pytestmark = pytest.mark.stable

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/test_enigma.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from requests.exceptions import HTTPError

import pandas_datareader as pdr
import pandas_datareader.data as web
from pandas_datareader import data as web
from pandas_datareader.exceptions import ImmediateDeprecationError

pytestmark = pytest.mark.requires_api_key
Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/tests/test_eurostat.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import numpy as np
import pandas as pd
import pandas.testing as tm
from pandas import testing as tm
import pytest

import pandas_datareader.data as web
from pandas_datareader import data as web

pytestmark = pytest.mark.stable

Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/tests/test_famafrench.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pandas as pd
import pandas.testing as tm
from pandas import testing as tm
import pytest

import pandas_datareader.data as web
from pandas_datareader import data as web
from pandas_datareader.famafrench import get_available_datasets

pytestmark = pytest.mark.stable
Expand Down
5 changes: 2 additions & 3 deletions pandas_datareader/tests/test_fred.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

import numpy as np
import pandas as pd
from pandas import DataFrame
import pandas.testing as tm
from pandas import DataFrame, testing as tm
import pytest

from pandas_datareader import data as web
from pandas_datareader._utils import RemoteDataError
import pandas_datareader.data as web

pytestmark = pytest.mark.stable

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/test_iex_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pandas import DataFrame, MultiIndex
import pytest

import pandas_datareader.data as web
from pandas_datareader import data as web
from pandas_datareader.iex.daily import IEXDailyReader


Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/test_moex.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from requests.exceptions import HTTPError

import pandas_datareader.data as web
from pandas_datareader import data as web

pytestmark = pytest.mark.stable

Expand Down
2 changes: 1 addition & 1 deletion pandas_datareader/tests/test_nasdaq.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from pandas_datareader import data as web
from pandas_datareader._testing import skip_on_exception
from pandas_datareader._utils import RemoteDataError
import pandas_datareader.data as web


class TestNasdaqSymbols(object):
Expand Down
4 changes: 2 additions & 2 deletions pandas_datareader/tests/test_oecd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import numpy as np
import pandas as pd
import pandas.testing as tm
from pandas import testing as tm
import pytest

from pandas_datareader import data as web
from pandas_datareader._utils import RemoteDataError
import pandas_datareader.data as web


class TestOECD(object):
Expand Down
Loading