Ticket: Connection pytest -m connection

Please check out the below post:

Kanika

Hi,

I’ve been trying to run pytest -m connection in CentOs (python 3.6) / Windows (python 3.7),

with the same results:

*BTW:
I’am using venv for python in both environment.
When I run: python run.py the site loads information (so the connection string is working), but the test always is failing.

============================= test session starts ==============================
platform linux – Python 3.6.8, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: /home/changomayor/mongo_cursos/tests, inifile:
plugins: flask-0.10.0
collected 43 items

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 0x7f7d13ff1d68>

@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')

…/lib64/python3.6/site-packages/pytest_flask/plugin.py:109:


conftest.py:14: in app
app.config[‘SECRET_KEY’] = config[‘TEST’][‘SECRET_KEY’]


self = <configparser.ConfigParser object at 0x7f7d1512d6a0>, key = ‘TEST’

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

E KeyError: ‘TEST’

/usr/lib64/python3.6/configparser.py:959: KeyError
_____________________ ERROR at setup of test_basic_movies ______________________

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

@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')

…/lib64/python3.6/site-packages/pytest_flask/plugin.py:109:


conftest.py:14: in app
app.config[‘SECRET_KEY’] = config[‘TEST’][‘SECRET_KEY’]


self = <configparser.ConfigParser object at 0x7f7d1512d6a0>, key = ‘TEST’

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

E KeyError: ‘TEST’

/usr/lib64/python3.6/configparser.py:959: 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 0x7f7d13f2afd0>

@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')

…/lib64/python3.6/site-packages/pytest_flask/plugin.py:109:


conftest.py:14: in app
app.config[‘SECRET_KEY’] = config[‘TEST’][‘SECRET_KEY’]


self = <configparser.ConfigParser object at 0x7f7d1512d6a0>, key = ‘TEST’

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

E KeyError: ‘TEST’

/usr/lib64/python3.6/configparser.py:959: 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 0x7f7d13f1fcc0>

@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')

…/lib64/python3.6/site-packages/pytest_flask/plugin.py:109:


conftest.py:14: in app
app.config[‘SECRET_KEY’] = config[‘TEST’][‘SECRET_KEY’]


self = <configparser.ConfigParser object at 0x7f7d1512d6a0>, key = ‘TEST’

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

E KeyError: ‘TEST’

/usr/lib64/python3.6/configparser.py:959: KeyError
============================= 39 tests deselected ==============================
==================== 39 deselected, 4 error in 0.67 seconds ====================

--------------------------------
this is current installed modules
--------------------------------
Package Version


attrs 19.1.0
backcall 0.1.0
bcrypt 3.1.7
bleach 3.1.0
cffi 1.12.3
Click 7.0
decorator 4.4.0
defusedxml 0.6.0
dnspython 1.15.0
entrypoints 0.3
Faker 0.8.13
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
ipykernel 5.1.2
ipython 7.7.0
ipython-genutils 0.2.0
ipywidgets 7.5.1
itsdangerous 1.1.0
jedi 0.15.1
Jinja2 2.10.1
jsonschema 3.0.2
jupyter 1.0.0
jupyter-client 5.2.4
jupyter-console 6.0.0
jupyter-core 4.4.0
MarkupSafe 1.1.1
mistune 0.8.4
nbconvert 5.6.0
nbformat 4.4.0
notebook 6.0.0
pandocfilters 1.4.2
parso 0.5.1
pexpect 4.7.0
pickleshare 0.7.5
pip 18.1
pluggy 0.6.0
prometheus-client 0.7.1
prompt-toolkit 2.0.9
ptyprocess 0.6.0
py 1.8.0
pycparser 2.19
Pygments 2.4.2
PyJWT 1.7.1
pymongo 3.7.2
pyrsistent 0.15.4
pytest 3.3.0
pytest-flask 0.10.0
python-dateutil 2.8.0
pyzmq 18.1.0
qtconsole 4.5.3
Send2Trash 1.5.0
setuptools 40.6.2
six 1.12.0
terminado 0.8.2
testpath 0.4.2
text-unidecode 1.2
tornado 6.0.3
traitlets 4.3.2
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.15.5
widgetsnbextension 3.5.1

Can you help me?

Hi @nsandoval11,

Please make sure you have renamed dotini file to .ini file and you are running tests from directory mflix-python.

Kanika

Hi @Kanika,

I recreated all steps but I found this message after run: pip install -r requiriments.txt

When I run pytest -m connection in mflix-python I got other exception.

Thanks for your help.

ERROR: notebook 6.0.0 has requirement jupyter-client>=5.3.1, but you’ll have jupyter-client 5.2.4 which is incompatible.

Package Version


attrs 19.1.0
backcall 0.1.0
bcrypt 3.1.7
bleach 3.1.0
cffi 1.12.3
Click 7.0
decorator 4.4.0
defusedxml 0.6.0
dnspython 1.15.0
entrypoints 0.3
Faker 0.8.13
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
ipykernel 5.1.2
ipython 7.7.0
ipython-genutils 0.2.0
ipywidgets 7.5.1
itsdangerous 1.1.0
jedi 0.15.1
Jinja2 2.10.1
jsonschema 3.0.2
jupyter 1.0.0
jupyter-client 5.2.4
jupyter-console 6.0.0
jupyter-core 4.4.0
MarkupSafe 1.1.1
mistune 0.8.4
nbconvert 5.6.0
nbformat 4.4.0
notebook 6.0.0
pandocfilters 1.4.2
parso 0.5.1
pexpect 4.7.0
pickleshare 0.7.5
pip 19.2.2
pluggy 0.6.0
prometheus-client 0.7.1
prompt-toolkit 2.0.9
ptyprocess 0.6.0
py 1.8.0
pycparser 2.19
Pygments 2.4.2
PyJWT 1.7.1
pymongo 3.7.2
pyrsistent 0.15.4
pytest 3.3.0
pytest-flask 0.10.0
python-dateutil 2.8.0
pyzmq 18.1.0
qtconsole 4.5.3
Send2Trash 1.5.0
setuptools 40.6.2
six 1.12.0
terminado 0.8.2
testpath 0.4.2
text-unidecode 1.2
tornado 6.0.3
traitlets 4.3.2
wcwidth 0.1.7
webencodings 0.5.1
Werkzeug 0.15.5
widgetsnbextension 3.5.1