Pytest -m connection error

All, I have updated the .ini file as per the instructions, I have used ‘’‘pip install -r requirements.txt’’’ to install all the necessary libraries, I have also made sure the data has been loaded correctly to Atlas. When I run the ‘’‘pytest -m connection error’’’ i get a slew of errors:

‘’'tests/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 0x7f66a3487ac8>

@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 = request.getfuncargvalue('app')

E _pytest.warning_types.RemovedInPytest4Warning: getfuncargvalue is deprecated, use getfixturevalue

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: RemovedInPytest4Warning
_____________________ ERROR at setup of test_basic_movies ______________________

request = <SubRequest ‘_configure_application’ for <Function ‘test_basic_movies’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f66a3459518>

@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 = request.getfuncargvalue('app')

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109:


request = <SubRequest ‘_configure_application’ for <Function ‘test_atlas_setup’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f66a3487ac8>

@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 = request.getfuncargvalue('app')

E _pytest.warning_types.RemovedInPytest4Warning: getfuncargvalue is deprecated, use getfixturevalue

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: RemovedInPytest4Warning
__________________ 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 0x7f66a348bc18>

@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 = request.getfuncargvalue('app')

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109:


…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: in _configure_application
app = request.getfuncargvalue(‘app’)


request = <SubRequest ‘_configure_application’ for <Function ‘test_atlas_setup’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f66a3487ac8>

@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 = request.getfuncargvalue('app')

E _pytest.warning_types.RemovedInPytest4Warning: getfuncargvalue is deprecated, use getfixturevalue

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: RemovedInPytest4Warning
__________________ ERROR at setup of test_simple_text_search ___________________

request = <SubRequest ‘_configure_application’ for <Function ‘test_simple_text_search’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f66a3459c50>

@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 = request.getfuncargvalue('app')

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109:


…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: in _configure_application
app = request.getfuncargvalue(‘app’)
…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: in _configure_application
app = request.getfuncargvalue(‘app’)


request = <SubRequest ‘_configure_application’ for <Function ‘test_atlas_setup’>>
monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f66a3487ac8>

@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 = request.getfuncargvalue('app')

E _pytest.warning_types.RemovedInPytest4Warning: getfuncargvalue is deprecated, use getfixturevalue

…/…/anaconda3/lib/python3.7/site-packages/pytest_flask/plugin.py:109: RemovedInPytest4Warning
==================== 39 deselected, 4 error in 0.10 seconds ==================’’’

These errors don’t really tell me all that much. Anyone else getting such errors? Anyone know what is going wrong?

1 Like

Hi, I am also getting the same errors. I do not know why.

I am getting the same errors. The "request.fixturenames keep popping up.
Not sure where to look.

Javier, I couldn’t find rhyme or reason for the errors. In the end I just started the app and the confirmation code worked.

I am unable to start the app.

mflix) C:\Users\Bob\M220\mflix-python>python run.py
Traceback (most recent call last):
File “run.py”, line 13, in
app.config[‘MFLIX_DB_URI’] = config[‘PROD’][‘MFLIX_DB_URI’]
File “C:\Users\Bob\Anaconda3\lib\configparser.py”, line 958, in getitem
raise KeyError(key)
KeyError: ‘PROD’

Yes, I could not fix the issue, but I run “run.py” and worked it out.

What is the content of your .ini file?

Ticket: Connection

Rename this file to .ini after filling in your MFLIX_DB_URI and your SECRET_KEY

Do not surround the URI with quotes

[PROD]
SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-9qpj8.mongodb.net/

[TEST]
SECRET_KEY = super_secret_testing_key
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-9qpj8.mongodb.net/

In the .ini file I copied the uri and code across both test and prod instances.

I don’t know what you mean

i am also getting also same no clue about it.
but python run.py is working well

Hi, This problem is presented because of the version of the testing libraries, i fixed this issue by downgrading the pytest version to the 3.3.2. This can be done by running the following cmd in the terminal:

pip install pytest==3.3.2

I dont know if this is relevant but in my case im using ubuntu 18.04.

Greetings.
Mario Armenta.

8 Likes

That didn’t work for me.

I uninstalled pytest and pytest_flask libraries and installed the latest ones. Using Python 3.7
It worked

2 Likes

It may happen if the file is not renamed properly. The file should be renamed to ‘’.ini" meaning no filename but only “.ini”

1 Like

Bob, what did you rename your ini file to?

This worked for me in Windows

Thank you, It worked for me on Ubuntu 18.04.1 LTS

I have updated pytest_flask and pytest and now I am getting a totally new set of errors. Is this supposed to be a course on mongo or debugging???

ok so I have finally worked this one out. The issue was again in the .ini file where I had a SECRET_KEY = ‘Random String’, whereas it should have been
SECRET_KEY = Random String,

Once I fixed that the test started working