Skip to content

Commit d2ef4e6

Browse files
authored
Merge pull request #809 from bashtage/add-test
MAINT: Add tester
2 parents af99219 + b011884 commit d2ef4e6

33 files changed

+141
-77
lines changed

.travis.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ language: python
44
env:
55
global:
66
- TEST_TYPE="stable and not requires_api_key"
7+
- TEST_INSTALL=false
78
# Doctr deploy key for pydata/pandas-datareader
89
- secure: "iGbOAbBSV5y0TKDh2CifRSk6OpLA9GbEEL/hscHFLSDDUCWcdfvYXda3SWJFWyoQ5QUxSigXWd+ukr4u92d7lmB7m3TWj6BAMNuRpatTgnejLNwLvNeYdvLAxPvx39Cq85frd1Rx1beBLn3h/4wm4Ah+dR5W9NH8+x3OuZMH3Eo="
910

@@ -19,7 +20,7 @@ matrix:
1920
- python: 3.8
2021
env: PANDAS=1 NUMPY=1.18
2122
- python: 3.8
22-
env: PANDAS=1 NUMPY=1.19
23+
env: PANDAS=1 NUMPY=1.19 TEST_INSTALL=true
2324
- python: 3.7
2425
env: TEST_TYPE="quandl" PANDAS=1 NUMPY=1.19
2526
# In allow failures
@@ -44,7 +45,15 @@ install:
4445

4546
script:
4647
- if [[ -n "${TEST_TYPE+x}" ]]; then export MARKERS="-m ${TEST_TYPE}"; fi
47-
- pytest -v -s -r xX "${MARKERS}" --cov-config .coveragerc --cov=pandas_datareader --cov-report xml:/tmp/cov-datareader.xml --junitxml=/tmp/datareader.xml
48+
- |
49+
if [[ ${TEST_INSTALL} = false ]]; then
50+
pytest -v -s -r xX "${MARKERS}" --cov-config .coveragerc --cov=pandas_datareader --cov-report xml:/tmp/cov-datareader.xml --junitxml=/tmp/datareader.xml
51+
else
52+
mkdir pdr_test
53+
cd pdr_test
54+
python -c "import pandas_datareader; pandas_datareader.test()"
55+
cd ..
56+
fi
4857
- black --version
4958
- black --check pandas_datareader
5059
- flake8 --version

docs/source/whatsnew/v0.9.0.txt

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,41 @@
1+
.. _whatsnew_091:
2+
3+
v0.9.1 (TBD)
4+
------------
5+
6+
.. contents:: What's new in v0.9.1
7+
:local:
8+
:backlinks: none
9+
10+
11+
.. _whatsnew_091.enhancements:
12+
13+
Enhancements
14+
~~~~~~~~~~~~
15+
- Added the method ``test`` to the package to simplify running tests from an
16+
installation using
17+
18+
.. code-block:: shell
19+
20+
python -c "import pandas_datareader; pandas_datareader.test()"
21+
22+
.. _whatsnew_091.api_breaking:
23+
24+
Backwards incompatible API changes
25+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26+
27+
- Immediately deprecated old symbol names for TSP to reflect the new website API
28+
29+
.. _whatsnew_091.bug_fixes:
30+
31+
Bug Fixes
32+
~~~~~~~~~
33+
- Update TSP web scraper to new site (:issue:`740`)
34+
135
.. _whatsnew_090:
236

337
v0.9.0 (July 10, 2020)
4-
---------------------------
38+
----------------------
539

640
Highlights include:
741

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

4881
Contributors
4982
~~~~~~~~~~~~

pandas_datareader/__init__.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
import sys
3+
14
from ._version import get_versions
25
from .data import (
36
DataReader,
@@ -27,6 +30,8 @@
2730
get_tops_iex,
2831
)
2932

33+
PKG = os.path.dirname(__file__)
34+
3035
__version__ = get_versions()["version"]
3136
del get_versions
3237

@@ -57,4 +62,30 @@
5762
"get_data_tiingo",
5863
"get_iex_data_tiingo",
5964
"get_data_alphavantage",
65+
"test",
6066
]
67+
68+
69+
def test(extra_args=None):
70+
"""
71+
Run the test suite
72+
73+
Parameters
74+
----------
75+
extra_args : {str, List[str]}
76+
A string or list of strings to pass to pytest. Default is
77+
["--only-stable", "--skip-requires-api-key"]
78+
"""
79+
try:
80+
import pytest
81+
except ImportError as err:
82+
raise ImportError("Need pytest>=5.0.1 to run tests") from err
83+
cmd = ["--only-stable", "--skip-requires-api-key"]
84+
if extra_args:
85+
if not isinstance(extra_args, list):
86+
extra_args = [extra_args]
87+
cmd = extra_args
88+
cmd += [PKG]
89+
joined = " ".join(cmd)
90+
print(f"running: pytest {joined}")
91+
sys.exit(pytest.main(cmd))

pandas_datareader/av/quotes.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
import pandas as pd
33

44
from pandas_datareader.av import AlphaVantage
5-
from pandas_datareader.exceptions import (
6-
DEP_ERROR_MSG,
7-
ImmediateDeprecationError,
8-
)
5+
from pandas_datareader.exceptions import DEP_ERROR_MSG, ImmediateDeprecationError
96

107

118
class AVQuotesReader(AlphaVantage):

pandas_datareader/compat/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import pandas as pd
77
from pandas.api.types import is_list_like, is_number
8-
import pandas.io.common as com
8+
from pandas.io import common as com
99
from pandas.testing import assert_frame_equal
1010

1111
PANDAS_VERSION = LooseVersion(pd.__version__)

pandas_datareader/conftest.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,30 @@
33
import pytest
44

55

6+
def pytest_addoption(parser):
7+
parser.addoption("--only-stable", action="store_true", help="run only stable tests")
8+
parser.addoption(
9+
"--skip-requires-api-key",
10+
action="store_true",
11+
help="skip tests that require an API key",
12+
)
13+
parser.addoption(
14+
"--strict-data-files",
15+
action="store_true",
16+
help="Fail if a test is skipped for missing data file.",
17+
)
18+
19+
20+
def pytest_runtest_setup(item):
21+
if "stable" not in item.keywords and item.config.getoption("--only-stable"):
22+
pytest.skip("skipping due to --only-stable")
23+
24+
if "requires_api_key" in item.keywords and item.config.getoption(
25+
"--skip-requires-api-key"
26+
):
27+
pytest.skip("skipping due to --skip-requires-api-key")
28+
29+
630
@pytest.fixture
731
def datapath(request):
832
"""Get the path to a data file.

pandas_datareader/data.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@
1616
from pandas_datareader.econdb import EcondbReader
1717
from pandas_datareader.enigma import EnigmaReader
1818
from pandas_datareader.eurostat import EurostatReader
19-
from pandas_datareader.exceptions import (
20-
DEP_ERROR_MSG,
21-
ImmediateDeprecationError,
22-
)
19+
from pandas_datareader.exceptions import DEP_ERROR_MSG, ImmediateDeprecationError
2320
from pandas_datareader.famafrench import FamaFrenchReader
2421
from pandas_datareader.fred import FredReader
2522
from pandas_datareader.iex.daily import IEXDailyReader
2623
from pandas_datareader.iex.deep import Deep as IEXDeep
27-
from pandas_datareader.iex.tops import (
28-
LastReader as IEXLasts,
29-
TopsReader as IEXTops,
30-
)
24+
from pandas_datareader.iex.tops import LastReader as IEXLasts, TopsReader as IEXTops
3125
from pandas_datareader.moex import MoexReader
3226
from pandas_datareader.nasdaq_trader import get_nasdaq_symbols
3327
from pandas_datareader.naver import NaverDailyReader

pandas_datareader/enigma.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@
55

66
from pandas_datareader.base import _BaseReader, string_types
77
from pandas_datareader.compat import StringIO
8-
from pandas_datareader.exceptions import (
9-
DEP_ERROR_MSG,
10-
ImmediateDeprecationError,
11-
)
8+
from pandas_datareader.exceptions import DEP_ERROR_MSG, ImmediateDeprecationError
129

1310

1411
class EnigmaReader(_BaseReader):

pandas_datareader/io/sdmx.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def read_sdmx(path_or_buf, dtype="float64", dsd=None):
4747

4848
xdata = _read_content(path_or_buf)
4949

50-
import xml.etree.ElementTree as ET
50+
from xml.etree import ElementTree as ET
5151

5252
root = ET.fromstring(xdata)
5353

@@ -204,7 +204,7 @@ def _read_sdmx_dsd(path_or_buf):
204204

205205
xdata = _read_content(path_or_buf)
206206

207-
import xml.etree.cElementTree as ET
207+
from xml.etree import cElementTree as ET
208208

209209
root = ET.fromstring(xdata)
210210

pandas_datareader/moex.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
import pandas as pd
44

55
from pandas_datareader.base import _DailyBaseReader
6-
from pandas_datareader.compat import (
7-
StringIO,
8-
binary_type,
9-
concat,
10-
is_list_like,
11-
)
6+
from pandas_datareader.compat import StringIO, binary_type, concat, is_list_like
127

138

149
class MoexReader(_DailyBaseReader):

0 commit comments

Comments
 (0)