Pytest -m paging fails, yet get correct validation code

RE: Chapter 2 Ticket: Paging

So this kept me up late … after many edits and many attempts at editing db.py I finally got a green light for paging with the correct validation code. pytest -m paging fails every single time, however.

Here is the output. Can someone make sense of these error messages? I’m thinking an update is coming. Does flask need updating? Thanks.

 (mflix)
peter@haha~/Desktop/MongoUniv/M220P/mflix-python/tests       
$ pytest -m paging
    ============================= test session starts =============================
    platform win32 -- Python 3.8.8, pytest-5.2.0, py-1.8.0, pluggy-0.13.1
    rootdir: C:\Users\peter\Desktop\MongoUniv\M220P\mflix-python, inifile: pytest.ini
    plugins: anyio-2.2.0, flask-0.11.0
    collected 43 items / 40 deselected / 3 selected

    test_paging.py EEE                                                       [100%]

    =================================== ERRORS ====================================
    _______________ ERROR at setup of test_supports_paging_by_cast ________________

    request = <SubRequest '_configure_application' for <Function test_supports_paging_by_cast>>
    monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00000265F80D0970>

        @pytest.fixture(autouse=True)
        def _configure_application(request, monkeypatch):
            """Use `pytest.mark.options` decorator to pass options to your application
            factory::

                @pytest.mark.options(debug=False)
                def test_something(app):
                    assert not app.debug, 'the application works not in debug mode!'

            """
            if 'app' not in request.fixturenames:
                return

    >       app = getfixturevalue(request, 'app')

    c:\users\peter\anaconda3\lib\site-packages\pytest_flask\plugin.py:110:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    c:\users\peter\anaconda3\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
        return request.getfixturevalue(value)
    conftest.py:14: in app
        app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <configparser.ConfigParser object at 0x00000265F75AF9D0>, key = 'TEST'

        def __getitem__(self, key):
            if key != self.default_section and not self.has_section(key):
    >           raise KeyError(key)
    E           KeyError: 'TEST'

    c:\users\peter\anaconda3\lib\configparser.py:960: KeyError
    _______________ ERROR at setup of test_supports_paging_by_genre _______________

    request = <SubRequest '_configure_application' for <Function test_supports_paging_by_genre>>
    monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00000265F816A0A0>

        @pytest.fixture(autouse=True)
        def _configure_application(request, monkeypatch):
            """Use `pytest.mark.options` decorator to pass options to your application
            factory::

                @pytest.mark.options(debug=False)
                def test_something(app):
                    assert not app.debug, 'the application works not in debug mode!'

            """
            if 'app' not in request.fixturenames:
                return

    >       app = getfixturevalue(request, 'app')

    c:\users\peter\anaconda3\lib\site-packages\pytest_flask\plugin.py:110:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    c:\users\peter\anaconda3\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
        return request.getfixturevalue(value)
    conftest.py:14: in app
        app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <configparser.ConfigParser object at 0x00000265F75AF9D0>, key = 'TEST'

        def __getitem__(self, key):
            if key != self.default_section and not self.has_section(key):
    >           raise KeyError(key)
    E           KeyError: 'TEST'

    c:\users\peter\anaconda3\lib\configparser.py:960: KeyError
    _______________ ERROR at setup of test_supports_paging_by_text ________________

    request = <SubRequest '_configure_application' for <Function test_supports_paging_by_text>>
    monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x00000265F81ACE80>

        @pytest.fixture(autouse=True)
        def _configure_application(request, monkeypatch):
            """Use `pytest.mark.options` decorator to pass options to your application
            factory::

                @pytest.mark.options(debug=False)
                def test_something(app):
                    assert not app.debug, 'the application works not in debug mode!'

            """
            if 'app' not in request.fixturenames:
                return

    >       app = getfixturevalue(request, 'app')

    c:\users\peter\anaconda3\lib\site-packages\pytest_flask\plugin.py:110:
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
    c:\users\peter\anaconda3\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
        return request.getfixturevalue(value)
    conftest.py:14: in app
        app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
    _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    self = <configparser.ConfigParser object at 0x00000265F75AF9D0>, key = 'TEST'

        def __getitem__(self, key):
            if key != self.default_section and not self.has_section(key):
    >           raise KeyError(key)
    E           KeyError: 'TEST'

    c:\users\peter\anaconda3\lib\configparser.py:960: KeyError
    ======================= 40 deselected, 3 error in 0.94s =======================

this issue seems to be happening with all the pytests…
pytest -m connection, for example, gives me nearly same error messages as above.
Here is the output of pip list…

$ pip list
Package                            Version
---------------------------------- -------------------
-ffi                               1.14.5
alabaster                          0.7.12
anaconda-client                    1.7.2
anaconda-navigator                 2.0.3
anaconda-project                   0.9.1
anyio                              2.2.0
appdirs                            1.4.4
appnope                            0.1.0
argh                               0.26.2
argon2-cffi                        20.1.0
asn1crypto                         1.4.0
astroid                            2.5
astropy                            4.2.1
async-generator                    1.10
atomicwrites                       1.4.0
attrs                              19.1.0
autopep8                           1.5.6
Babel                              2.9.0
backcall                           0.1.0
backports.functools-lru-cache      1.6.4
backports.shutil-get-terminal-size 1.0.0
backports.tempfile                 1.0
backports.weakref                  1.0.post1
bcrypt                             3.1.7
beautifulsoup4                     4.9.3
bitarray                           1.9.2
bkcharts                           0.2
black                              19.10b0
bleach                             3.1.0
bokeh                              2.3.2
boto                               2.49.0
Bottleneck                         1.3.2
brotlipy                           0.7.0
certifi                            2020.12.5
cffi                               1.13.1
chardet                            4.0.0
Click                              7.0
cloudpickle                        1.6.0
clyent                             1.2.2
colorama                           0.4.4
comtypes                           1.1.9
conda                              4.10.1
conda-build                        3.21.4
conda-content-trust                0+unknown
conda-package-handling             1.7.3
conda-repo-cli                     1.0.4
conda-token                        0.3.0
conda-verify                       3.4.2
contextlib2                        0.6.0.post1
cryptography                       3.4.7
cycler                             0.10.0
Cython                             0.29.23
cytoolz                            0.11.0
dask                               2021.4.0
decorator                          4.4.0
defusedxml                         0.6.0
diff-match-patch                   20200713
distributed                        2021.4.0
dnspython                          1.15.0
docutils                           0.17
entrypoints                        0.3
et-xmlfile                         1.0.1
Faker                              0.8.13
fastcache                          1.1.0
filelock                           3.0.12
flake8                             3.7.8
Flask                              0.12.4
Flask-Bcrypt                       0.7.1
Flask-Cors                         3.0.3
Flask-JWT-Extended                 3.7.0
Flask-Login                        0.4.0
fsspec                             0.9.0
future                             0.18.2
gevent                             21.1.2
glob2                              0.7
greenlet                           1.0.0
h5py                               2.10.0
HeapDict                           1.0.1
html5lib                           1.1
idna                               2.10
imagecodecs                        2021.3.31
imageio                            2.9.0
imagesize                          1.2.0
importlib-metadata                 0.23
iniconfig                          1.1.1
intervaltree                       3.1.0
ipykernel                          5.1.3
ipython                            7.8.0
ipython-genutils                   0.2.0
ipywidgets                         7.5.1
isort                              5.8.0
itsdangerous                       1.1.0
jdcal                              1.4.1
jedi                               0.15.1
Jinja2                             2.10.3
joblib                             1.0.1
json5                              0.9.5
jsonschema                         3.1.1
jupyter                            1.0.0
jupyter-client                     5.3.1
jupyter-console                    6.0.0
jupyter-core                       4.4.0
jupyter-packaging                  0.7.12
jupyter-server                     1.4.1
jupyterlab                         3.0.14
jupyterlab-pygments                0.1.2
jupyterlab-server                  2.4.0
jupyterlab-widgets                 1.0.0
keyring                            22.3.0
kiwisolver                         1.3.1
lazy-object-proxy                  1.6.0
libarchive-c                       2.9
llvmlite                           0.36.0
locket                             0.2.1
lxml                               4.6.3
MarkupSafe                         1.1.1
matplotlib                         3.3.4
mccabe                             0.6.1
menuinst                           1.4.16
mistune                            0.8.4
mkl-fft                            1.3.0
mkl-random                         1.2.1
mkl-service                        2.3.0
mock                               4.0.3
more-itertools                     7.2.0
mpmath                             1.2.1
msgpack                            1.0.2
multipledispatch                   0.6.0
mypy-extensions                    0.4.3
navigator-updater                  0.2.1
nbclassic                          0.2.6
nbclient                           0.5.3
nbconvert                          5.6.0
nbformat                           4.4.0
nest-asyncio                       1.5.1
networkx                           2.5
nltk                               3.6.1
nose                               1.3.7
notebook                           6.0.1
numba                              0.53.1
numexpr                            2.7.3
numpy                              1.20.1
numpydoc                           1.1.0
olefile                            0.46
openpyxl                           3.0.7
packaging                          20.9
pandas                             1.2.4
pandocfilters                      1.4.2
paramiko                           2.7.2
parso                              0.5.1
partd                              1.2.0
path                               15.1.2
pathlib2                           2.3.5
pathspec                           0.7.0
patsy                              0.5.1
pep8                               1.7.1
pexpect                            4.7.0
pickleshare                        0.7.5
Pillow                             8.2.0
pip                                21.0.1
pkginfo                            1.7.0
pluggy                             0.6.0
ply                                3.11
prometheus-client                  0.7.1
prompt-toolkit                     2.0.10
psutil                             5.8.0
ptyprocess                         0.6.0
py                                 1.8.0
pycodestyle                        2.5.0
pycosat                            0.6.3
pycparser                          2.19
pycurl                             7.43.0.6
pydocstyle                         6.0.0
pyerfa                             1.7.3
pyflakes                           2.1.1
Pygments                           2.4.2
PyJWT                              1.7.1
pylint                             2.7.4
pyls-black                         0.4.6
pyls-spyder                        0.3.2
pymongo                            3.7.2
PyNaCl                             1.4.0
pyodbc                             4.0.0-unsupported
pyOpenSSL                          20.0.1
pyparsing                          2.4.7
pyreadline                         2.1
pyrsistent                         0.15.4
PySocks                            1.7.1
pytest                             3.3.0
pytest-flask                       0.11.0
python-dateutil                    2.8.0
python-jsonrpc-server              0.4.0
python-language-server             0.36.2
pytz                               2021.1
PyWavelets                         1.1.1
pywin32                            227
pywin32-ctypes                     0.2.0
pywinpty                           1.1.4
PyYAML                             5.4.1
pyzmq                              18.1.1
QDarkStyle                         2.8.1
QtAwesome                          1.0.2
qtconsole                          4.5.5
QtPy                               1.9.0
regex                              2021.4.4
requests                           2.25.1
rope                               0.18.0
Rtree                              0.9.7
ruamel-yaml-conda                  0.15.100
scikit-image                       0.18.1
scikit-learn                       0.24.1
scipy                              1.6.2
seaborn                            0.11.1
Send2Trash                         1.5.0
setuptools                         52.0.0.post20210125
simplegeneric                      0.8.1
singledispatch                     0.0.0
sip                                4.19.13
six                                1.12.0
sniffio                            1.2.0
snowballstemmer                    2.1.0
sortedcollections                  2.1.0
sortedcontainers                   2.3.0
soupsieve                          2.2.1
Sphinx                             4.0.1
sphinxcontrib-applehelp            1.0.2
sphinxcontrib-devhelp              1.0.2
sphinxcontrib-htmlhelp             1.0.3
sphinxcontrib-jsmath               1.0.1
sphinxcontrib-qthelp               1.0.3
sphinxcontrib-serializinghtml      1.1.4
sphinxcontrib-websupport           1.2.4
spyder-kernels                     1.10.2
SQLAlchemy                         1.4.7
statsmodels                        0.12.2
sympy                              1.8
tables                             3.6.1
tblib                              1.7.0
terminado                          0.8.2
testpath                           0.4.2
text-unidecode                     1.2
textdistance                       4.2.1
threadpoolctl                      2.1.0
three-merge                        0.1.1
tifffile                           2021.4.8
toml                               0.10.2
toolz                              0.11.1
tornado                            6.0.3
tqdm                               4.59.0
traitlets                          4.3.3
typed-ast                          1.4.2
typing-extensions                  3.7.4.3
ujson                              4.0.2
unicodecsv                         0.14.1
urllib3                            1.26.4
watchdog                           1.0.2
wcwidth                            0.1.7
webencodings                       0.5.1
Werkzeug                           0.16.0
wheel                              0.36.2
widgetsnbextension                 3.5.1
win-inet-pton                      1.1.0
win-unicode-console                0.5
wincertstore                       0.2
wrapt                              1.12.1
xlrd                               2.0.1
XlsxWriter                         1.3.8
xlwings                            0.23.0
xlwt                               1.3.0
xmltodict                          0.12.0
yapf                               0.31.0
zict                               2.0.0
zipp                               0.6.0
zope.event                         4.5.0
zope.interface                     5.3.0

It looks like your configuration file is not setup correctly. The clues being

and

the configuration file … agreed. but which one? You think .ini ?? The URI looks fine and the secret code I assume could be any jumbled mess of letters and numbers? I’ve even ripped out anaconda and reinstalled python 3.8.10 and setup a venv and then re-did pip install requirements. Like I said I’m getting green lights yet pytest won’t give me love. bizarre.

You need 2 sections. One for TEST and the other for PROD. Share the content.

my .ini on Windows 10: using git-bash and or powershell:

[PROD]
SECRET_KEY = 9uu33Ert&Polk
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-zzzzz.mongodb.net/sample_mflix
MFLIX_NS = sample_mflix

[TEST]
SECRET_KEY = 9uu33Ert&Polk
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-zzzzz.mongodb.net/
MFLIX_NS = sample_mflix

…and the error messages with pytest -m connection:

(mflix) PS C:\Users\peter\Desktop\MongoUniv\M220P\mflix-python\tests> pytest -m connection
================================================================== test session starts ==================================================================
platform win32 – Python 3.8.10, pytest-5.2.0, py-1.8.0, pluggy-0.13.1
rootdir: C:\Users\peter\Desktop\MongoUniv\M220P\mflix-python, inifile: pytest.ini
plugins: flask-0.11.0
collected 43 items / 39 deselected / 4 selected

test_db_connection.py EEEE                                                                                                                         [100%]

======================================================================== ERRORS =========================================================================
__________________________________________________________ ERROR at setup of test_atlas_setup ___________________________________________________________

request = <SubRequest '_configure_application' for <Function test_atlas_setup>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x000001EA860E2A90>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x000001EA85C0BE20>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
__________________________________________________________ ERROR at setup of test_basic_movies __________________________________________________________

request = <SubRequest '_configure_application' for <Function test_basic_movies>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x000001EA861B3A30>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x000001EA85C0BE20>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
_______________________________________________________ ERROR at setup of test_search_by_movie_id _______________________________________________________

request = <SubRequest '_configure_application' for <Function test_search_by_movie_id>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x000001EA862067C0>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x000001EA85C0BE20>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
_______________________________________________________ ERROR at setup of test_simple_text_search _______________________________________________________

request = <SubRequest '_configure_application' for <Function test_simple_text_search>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x000001EA8629E1F0>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x000001EA85C0BE20>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
============================================================ 39 deselected, 4 error in 2.70s ==========

I am puzzled with

Is it possible that in recent pytest-5.3.0 pytest.ini is used rather than simply .ini?

Do you have a file pytest.ini?

If not, try copy .ini into pytest.ini

BUT … we still get …
(Steeve, thanks for your help… I tried your idea of pasting .ini into pytestini but that was a no-go also.)

(mflix)peter@XPS13 MINGW64 ~/Desktop/MongoUniv/M220P/mflix-python/tests
$ pytest -m connection
============================= test session starts =============================
platform win32 -- Python 3.8.10, pytest-5.2.0, py-1.8.0, pluggy-0.13.1
rootdir: C:\Users\peter\Desktop\MongoUniv\M220P\mflix-python, inifile: pytest.ini
plugins: flask-0.11.0
collected 43 items / 39 deselected / 4 selected

test_db_connection.py EEEE                                               [100%]

=================================== ERRORS ====================================
_____________________ ERROR at setup of test_atlas_setup ______________________

request = <SubRequest '_configure_application' for <Function test_atlas_setup>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000025FD441AEB0>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x0000025FD3A16DC0>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
_____________________ ERROR at setup of test_basic_movies _____________________

request = <SubRequest '_configure_application' for <Function test_basic_movies>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000025FD44C9D60>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x0000025FD3A16DC0>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
__________________ ERROR at setup of test_search_by_movie_id __________________

request = <SubRequest '_configure_application' for <Function test_search_by_movie_id>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000025FD4532730>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x0000025FD3A16DC0>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
__________________ ERROR at setup of test_simple_text_search __________________

request = <SubRequest '_configure_application' for <Function test_simple_text_search>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x0000025FD453F1C0>

    @pytest.fixture(autouse=True)
    def _configure_application(request, monkeypatch):
        """Use `pytest.mark.options` decorator to pass options to your application
        factory::

            @pytest.mark.options(debug=False)
            def test_something(app):
                assert not app.debug, 'the application works not in debug mode!'

        """
        if 'app' not in request.fixturenames:
            return

>       app = getfixturevalue(request, 'app')

..\mflix\lib\site-packages\pytest_flask\plugin.py:110:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\mflix\lib\site-packages\pytest_flask\pytest_compat.py:3: in getfixturevalue
    return request.getfixturevalue(value)
conftest.py:14: in app
    app.config['SECRET_KEY'] = config['TEST']['SECRET_KEY']
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <configparser.ConfigParser object at 0x0000025FD3A16DC0>, key = 'TEST'

    def __getitem__(self, key):
        if key != self.default_section and not self.has_section(key):
>           raise KeyError(key)
E           KeyError: 'TEST'

C:\Users\peter\Python38\lib\configparser.py:960: KeyError
======================= 39 deselected, 4 error in 1.02s =======================

Ok success finally. Had to roll back to Python 3.8.8 from 3.8.10. Downloaded and re-extracted mflix-python.zip. Took the working .ini and db.py files and viola, pytest passes no problems. EIther something got corrupted or pytest just doesn’t like Python after 3.8.8.
Thanks steve for your help.

btw I am attempting to complete this course (M220P) in 3 different environments. LOL :smiley:
Windows Anaconda, venv, and Manjaro. Hopefully, I will be expert in troubleshooting.

Hi @Peter_Suchsland,

If you are switching between Python versions I would also pip install -r requirements.txt in case a dependency is installed in a version-specific path or your current environment doesn’t meet the requirements.

That’s certainly one approach for broadening your troubleshooting skills! I recommend using venv to isolate your Python dependencies irrespective of the host O/S environment. Future You will be very appreciative ;-).

Regards,
Stennie

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.