Skip to content

Commit

Permalink
Upgrade test dependencies (#1171)
Browse files Browse the repository at this point in the history
* Upgrade test dependencies

* Fixing error in tests - TypeError: byte indices must be integers or slices, not str

* Fixing error: fixture 'mock' not found
  • Loading branch information
koropets authored Jun 23, 2021
1 parent 6baf7ee commit 27190e9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 43 deletions.
23 changes: 11 additions & 12 deletions requirements/test_requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,24 @@
# Force latest version for security patch until nbconvert is updated
bleach>=3.3.0
docker~=4.0
pytest~=5.3
pytest~=6.2
pytest-xdist~=1.26 # Parallelises the test-runs
pytest-mock~=1.13
pytest-mypy~=0.4
pytest-timeout~=1.3
pytest-cov~=2.8
responses~=0.10
pytest-mock~=3.6
pytest-mypy~=0.8
pytest-timeout~=1.4
pytest-cov~=2.12
responses~=0.13
black==19.3b0
pytest-flakes~=4.0
pytest-flakes~=4.0.3
adal~=1.2
jupyter~=1.0.0
notebook~=6.1
nbconvert~=5.6
urllib3~=1.25.8
pytest-benchmark~=3.2
mock~=3.0
nbconvert~=6.0
urllib3~=1.26
pytest-benchmark~=3.4
mock~=4.0
influxdb~=5.3.0
packaging~=20.7
py>=1.10.0
urllib3~=1.25
Pygments>=2.7.4
jinja2~=2.11
52 changes: 29 additions & 23 deletions requirements/test_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,50 @@ adal==1.2.2 # via -c full_requirements.txt, -r test_requirements.i
apipkg==1.5 # via execnet
appdirs==1.4.3 # via black
argon2-cffi==20.1.0 # via notebook
attrs==19.3.0 # via -c full_requirements.txt, black, jsonschema, pytest
async-generator==1.10 # via nbclient
attrs==19.3.0 # via -c full_requirements.txt, black, jsonschema, pytest, pytest-mypy
backcall==0.1.0 # via ipython
black==19.3b0 # via -r test_requirements.in
bleach==3.3.0 # via -r test_requirements.in, nbconvert
certifi==2019.11.28 # via -c full_requirements.txt, requests
cffi==1.13.2 # via -c full_requirements.txt, argon2-cffi, cryptography
chardet==3.0.4 # via -c full_requirements.txt, requests
click==7.1.2 # via -c full_requirements.txt, black
coverage==5.0.3 # via pytest-cov
coverage==5.5 # via pytest-cov
cryptography==3.4.6 # via -c full_requirements.txt, adal, pyjwt
decorator==4.4.1 # via ipython, traitlets
decorator==4.4.1 # via ipython
defusedxml==0.6.0 # via nbconvert
docker==4.1.0 # via -c full_requirements.txt, -r test_requirements.in
entrypoints==0.3 # via -c full_requirements.txt, nbconvert
execnet==1.7.1 # via pytest-xdist
filelock==3.0.12 # via pytest-mypy
idna==2.8 # via -c full_requirements.txt, requests
importlib-metadata==1.4.0 # via -c full_requirements.txt, jsonschema, pluggy, pytest
influxdb==5.3.0 # via -c full_requirements.txt, -r test_requirements.in
iniconfig==1.1.1 # via pytest
ipykernel==5.1.3 # via ipywidgets, jupyter, jupyter-console, notebook, qtconsole
ipython-genutils==0.2.0 # via nbformat, notebook, qtconsole, traitlets
ipython==7.11.1 # via ipykernel, ipywidgets, jupyter-console
ipywidgets==7.5.1 # via jupyter
jedi==0.15.2 # via ipython
jinja2==2.11.3 # via -c full_requirements.txt, -r test_requirements.in, nbconvert, notebook
jsonschema==3.2.0 # via -c full_requirements.txt, nbformat
jupyter-client==5.3.4 # via ipykernel, jupyter-console, notebook, qtconsole
jupyter-client==6.1.12 # via ipykernel, jupyter-console, nbclient, notebook, qtconsole
jupyter-console==6.0.0 # via jupyter
jupyter-core==4.6.1 # via jupyter-client, nbconvert, nbformat, notebook, qtconsole
jupyter==1.0.0 # via -r test_requirements.in
jupyterlab-pygments==0.1.2 # via nbconvert
markupsafe==1.1.1 # via -c full_requirements.txt, jinja2
mistune==0.8.4 # via nbconvert
mock==3.0.5 # via -r test_requirements.in
more-itertools==8.1.0 # via -c full_requirements.txt, pytest, zipp
mock==4.0.3 # via -r test_requirements.in
more-itertools==8.1.0 # via -c full_requirements.txt, zipp
msgpack==0.6.1 # via -c full_requirements.txt, influxdb
mypy-extensions==0.4.3 # via -c full_requirements.txt, mypy
mypy==0.761 # via pytest-mypy
nbconvert==5.6.1 # via -r test_requirements.in, jupyter, notebook
nbformat==5.0.3 # via ipywidgets, nbconvert, notebook
nbclient==0.5.3 # via nbconvert
nbconvert==6.1.0 # via -r test_requirements.in, jupyter, notebook
nbformat==5.0.3 # via ipywidgets, nbclient, nbconvert, notebook
nest-asyncio==1.5.1 # via nbclient
notebook==6.4.0 # via -r test_requirements.in, jupyter, widgetsnbextension
packaging==20.7 # via -c full_requirements.txt, -r test_requirements.in, bleach, pytest
pandocfilters==1.4.2 # via nbconvert
Expand All @@ -60,36 +66,36 @@ py-cpuinfo==5.0.0 # via pytest-benchmark
py==1.10.0 # via -r test_requirements.in, pytest
pycparser==2.19 # via -c full_requirements.txt, cffi
pyflakes==2.1.1 # via pytest-flakes
pygments==2.9.0 # via -r test_requirements.in, ipython, jupyter-console, nbconvert, qtconsole
pygments==2.9.0 # via -r test_requirements.in, ipython, jupyter-console, jupyterlab-pygments, nbconvert, qtconsole
pyjwt[crypto]==1.7.1 # via -c full_requirements.txt, adal
pyparsing==2.4.6 # via -c full_requirements.txt, packaging
pyrsistent==0.15.7 # via -c full_requirements.txt, jsonschema
pytest-benchmark==3.2.3 # via -r test_requirements.in
pytest-cov==2.8.1 # via -r test_requirements.in
pytest-flakes==4.0.0 # via -r test_requirements.in
pytest-benchmark==3.4.1 # via -r test_requirements.in
pytest-cov==2.12.1 # via -r test_requirements.in
pytest-flakes==4.0.3 # via -r test_requirements.in
pytest-forked==1.1.3 # via pytest-xdist
pytest-mock==1.13.0 # via -r test_requirements.in
pytest-mypy==0.4.2 # via -r test_requirements.in
pytest-timeout==1.3.4 # via -r test_requirements.in
pytest-mock==3.6.1 # via -r test_requirements.in
pytest-mypy==0.8.1 # via -r test_requirements.in
pytest-timeout==1.4.2 # via -r test_requirements.in
pytest-xdist==1.31.0 # via -r test_requirements.in
pytest==5.3.2 # via -r test_requirements.in, pytest-benchmark, pytest-cov, pytest-flakes, pytest-forked, pytest-mock, pytest-mypy, pytest-timeout, pytest-xdist
pytest==6.2.4 # via -r test_requirements.in, pytest-benchmark, pytest-cov, pytest-flakes, pytest-forked, pytest-mock, pytest-mypy, pytest-timeout, pytest-xdist
python-dateutil==2.8.1 # via -c full_requirements.txt, adal, influxdb, jupyter-client
pytz==2019.3 # via -c full_requirements.txt, influxdb
pyzmq==18.1.1 # via jupyter-client, notebook
qtconsole==4.6.0 # via jupyter
requests==2.22.0 # via -c full_requirements.txt, adal, docker, influxdb, responses
responses==0.10.9 # via -r test_requirements.in
requests==2.25.1 # via -c full_requirements.txt, adal, docker, influxdb, responses
responses==0.13.3 # via -r test_requirements.in
send2trash==1.5.0 # via notebook
six==1.15.0 # via -c full_requirements.txt, argon2-cffi, bleach, docker, influxdb, jsonschema, mock, prompt-toolkit, pyrsistent, pytest-xdist, python-dateutil, responses, traitlets, websocket-client
six==1.15.0 # via -c full_requirements.txt, argon2-cffi, bleach, docker, influxdb, jsonschema, prompt-toolkit, pyrsistent, pytest-xdist, python-dateutil, responses, websocket-client
terminado==0.8.3 # via notebook
testpath==0.4.4 # via nbconvert
toml==0.10.0 # via black
toml==0.10.0 # via black, pytest, pytest-cov
tornado==6.1 # via ipykernel, jupyter-client, notebook, terminado
traitlets==4.3.3 # via ipykernel, ipython, ipywidgets, jupyter-client, jupyter-core, nbconvert, nbformat, notebook, qtconsole
traitlets==5.0.5 # via ipykernel, ipython, ipywidgets, jupyter-client, jupyter-core, nbclient, nbconvert, nbformat, notebook, qtconsole
typed-ast==1.4.0 # via mypy
typing-extensions==3.7.4.3 # via -c full_requirements.txt, mypy
urllib3==1.25.11 # via -c full_requirements.txt, -r test_requirements.in, requests
wcwidth==0.1.8 # via prompt-toolkit, pytest
urllib3==1.26.5 # via -c full_requirements.txt, -r test_requirements.in, requests, responses
wcwidth==0.1.8 # via prompt-toolkit
webencodings==0.5.1 # via bleach
websocket-client==0.57.0 # via -c full_requirements.txt, docker
widgetsnbextension==3.5.1 # via ipywidgets
Expand Down
6 changes: 5 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,13 @@ def gordo_ml_server_callback(request):
resp = getattr(gordo_server_app, request.method.lower())(
request.path_url, headers=dict(request.headers), **kwargs
)
if type(resp.headers) is not dict:
headers = dict(resp.headers.to_list())
else:
headers = resp.headers
return (
resp.status_code,
resp.headers,
headers,
json.dumps(resp.json) if resp.json is not None else resp.data,
)

Expand Down
15 changes: 8 additions & 7 deletions tests/gordo/builder/test_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from sklearn.multioutput import MultiOutputRegressor
from sklearn.linear_model import LinearRegression
from sklearn import metrics
from mock import patch
from mock import patch, MagicMock

import gordo
from gordo.builder import ModelBuilder
Expand Down Expand Up @@ -64,8 +64,7 @@ def machine_check(machine: Machine, check_history):


@pytest.mark.parametrize("scaler", [None, "sklearn.preprocessing.MinMaxScaler"])
def test_get_metrics_dict_scaler(scaler, mock):
mock_model = mock
def test_get_metrics_dict_scaler(scaler):
metrics_list = [sklearn.metrics.mean_squared_error]
# make the features in y be in different scales
y = pd.DataFrame(
Expand All @@ -75,10 +74,12 @@ def test_get_metrics_dict_scaler(scaler, mock):
metrics_dict = ModelBuilder.build_metrics_dict(metrics_list, y, scaler=scaler)
metric_func = metrics_dict["mean-squared-error"]

mock_model.predict = lambda _y: _y * [0.8, 1]
mse_feature_one_wrong = metric_func(mock_model, y, y)
mock_model.predict = lambda _y: _y * [1, 0.8]
mse_feature_two_wrong = metric_func(mock_model, y, y)
mock_model1 = MagicMock()
mock_model1.predict = lambda _y: _y * [0.8, 1]
mse_feature_one_wrong = metric_func(mock_model1, y, y)
mock_model2 = MagicMock()
mock_model2.predict = lambda _y: _y * [1, 0.8]
mse_feature_two_wrong = metric_func(mock_model2, y, y)

if scaler:
assert np.isclose(mse_feature_one_wrong, mse_feature_two_wrong)
Expand Down

0 comments on commit 27190e9

Please sign in to comment.