Pytest -m connection errors

Hi, I’m from Linux mint, and when I run the command pytest -m connection I get errors:

Hi @damasofc,

Did you run pip install -r requirements.txt before running the pytest ? If yes, then please share/check the contents of .ini file.

Kanika

This is what I have in the .ini

# 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-bcj0u.mongodb.net/test?retryWrites=true&w=majority
MFLIX_NS = sample_mflix

[TEST]
SECRET_KEY = super_secret_testing_key
MFLIX_DB_URI = your_testing_db_uri (can be the same as Atlas, or a local MongoDB database)
MFLIX_NS = sample_mflix

Please update the uri in this variable as well.

Kanika

I made the correction in the .ini, but it stills giving me the same result

I am also getting the same error as @damasofc after making sure both uri vars are set:

[PROD]
SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-ivhgv.mongodb.net/test?ssl=true&ssl_cert_reqs=CERT_NONE&retryWrites=true&w=majority
MFLIX_NS = sample_mflix

[TEST]
SECRET_KEY = super_secret_key_you_should_change
MFLIX_DB_URI = mongodb+srv://m220student:m220password@mflix-ivhgv.mongodb.net/test?ssl=true&ssl_cert_reqs=CERT_NONE&retryWrites=true&w=majority
MFLIX_NS = sample_mflix

@kanikasingla - Also, for reference, my original error after (pip installing the requirements.txt )when running the command yielded this error:
File “/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/_pytest/fixtures.py”, line 841, in FixtureFunctionMarker
params = attr.ib(convert=attr.converters.optional(tuple))
TypeError: attrib() got an unexpected keyword argument ‘convert’

I did a ‘pip install pytest --upgrade’ to get as far as the error @damasofc has. I tried to upgrade flask as well but that didn’t resolve anything. I am able to get the app to connect and run however, as well as have a connection status value returned on the site. So, seems like maybe a versioning issue btwn pytest and flask?

@damasofc
After rabbit-holing a little bit on the google… this seemed to work:

$ pip install attrs==19.1.0

I originally had 19.3.0 installed but there appears to be an incompatibility with attrs versions after 19.1. Anyway, give that a shot if you are still having problems.

(mflix) richards-mbp:mflix-python rrb$ pytest -m connection
=============================================================================== test session starts ================================================================================
platform darwin – Python 3.7.0, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: /Users/rrb/MongoDBUniv/M220P/mflix-python, inifile:
plugins: flask-0.10.0
collected 43 items

tests/test_db_connection.py … [100%]

=============================================================================== 39 tests deselected ================================================================================
===================================================================== 4 passed, 39 deselected in 1.53 seconds ======================================================================
(mflix) richards-mbp:mflix-python rrb$

1 Like

Thank you for giving your solution, and I tried it too, but still the same, nothing change, the same error in my case.

Sorry to hear that didn’t work!
I saw another thread related to the same issue, and another way to resolve it was to remove the specific versions defined in the requirements.txt, giving pip a little more freedom to resolve the dependencies with latest versions of each.
So, instead of the following in requirements.txt:
Flask==0.12.4
Flask-Bcrypt==0.7.1
Flask-Login==0.4.0

Try listing them w/o the versions:

Flask
Flask-Bcrypt
Flask-Login

etc.

And then run the pip install -r requirements.txt command.
You may want to spin up a new virtual env (or conda) just in case. Hope that helps!

Hi @damasofc,

Try to follow what @Rich_92982 has suggested and let me know if it doesn’t work. Just to confirm, you are getting the same error related to “SubRequest” module ?

Kanika



As I show you here, I Continue getting the same errors after doing what @Rich_92982 has suggested.

Hi @damasofc,

Let me know if the below post is helpful:

Kanika

Finally, yes that solves my problem, thank you :slight_smile:

1 Like