Ticket: Projection, Error when trying to run tests

I just edited the db.py file and then tried to run

pytetst -m projection

but I get the following errors and I’m not sure why:

Traceback (most recent call last):
  File "d:\files\documents\coding\mongodb\mongo_python\venv\lib\site-packages\_pytest\config.py", line 327, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('D:\\Files\\Documents\\Coding\\mongodb\\mongo_python\\mflix-python\\tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\files\documents\coding\mongodb\mongo_python\venv\lib\site-packages\_pytest\config.py", line 358, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('D:\\Files\\Documents\\Coding\\mongodb\\mongo_python\\mflix-python\\tests\\conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "d:\files\documents\coding\mongodb\mongo_python\venv\lib\site-packages\_pytest\config.py", line 364, in _importconftest
    mod = conftestpath.pyimport()
  File "d:\files\documents\coding\mongodb\mongo_python\venv\lib\site-packages\py\_path\local.py", line 721, in pyimport
    raise self.ImportMismatchError(modname, modfile, self)
py._path.local.LocalPath.ImportMismatchError: ('tests.conftest', 'D:\\Files\\Documents\\Coding\\mongodb\\mflix-python\\tests\\conftest.py', local('D:\\Files\\Documents\\Coding\\mongodb\\mongo_python\\mflix-python\\tests\\conftest.py
'))
ERROR: could not load D:\Files\Documents\Coding\mongodb\mongo_python\mflix-python\tests\conftest.py

Is your virtual environment activated?

Yeah, I believe it is!

Please post a screenshot of the terminal where you run the command. Make sure we see the whole command.

I ran it in a terminal in PyCharm, and I checked that the interpreter is using the virtual environment.

Any reason why your virtual env is called venv rather than mflix?

Hi @Nicola_Farmer - welcome to the forums,

Can you verify which version of Python is being used and can you provide a full list of the installed libraries (pip list) for that virtual environment?

I’ve not seen this particular error before so we’ll need to gather some additional information before we can begin to make a hypothesis.

Thanks and kindest regards,
Eoin

No reason, I’m just not too familiar with virtual environments and that is what PyCharm named it by default

Hi @Eoin_Brazil,

Thank you!

The version of Python is 3.8 and the installed libraries are as follows:

Package            Version
------------------ -------
appnope            0.1.0
attrs              19.1.0
backcall           0.1.0
bcrypt             3.2.0
bleach             3.1.0
cffi               1.14.5
Click              7.0
colorama           0.4.4
decorator          4.4.0
defusedxml         0.6.0
dnspython          1.15.0
entrypoints        0.3
Faker              0.8.13
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
importlib-metadata 0.23
ipykernel          5.1.3
ipython            7.8.0
ipython-genutils   0.2.0
ipywidgets         7.5.1
itsdangerous       1.1.0
jedi               0.15.1
Jinja2             2.10.3
jsonschema         3.1.1
jupyter            1.0.0
jupyter-client     5.3.1
jupyter-console    6.0.0
jupyter-core       4.4.0
MarkupSafe         1.1.1
mccabe             0.6.1
mistune            0.8.4
more-itertools     7.2.0
nbconvert          5.6.0
nbformat           4.4.0
notebook           6.0.1
pandocfilters      1.4.2
parso              0.5.1
pexpect            4.7.0
pickleshare        0.7.5
pip                21.1.2
pluggy             0.6.0
prometheus-client  0.7.1
prompt-toolkit     2.0.10
ptyprocess         0.6.0
py                 1.8.0
pycodestyle        2.5.0
pycparser          2.19
pyflakes           2.1.1
Pygments           2.4.2
PyJWT              1.7.1
pymongo            3.7.2
pyrsistent         0.15.4
pytest             3.3.0
pytest-flask       0.11.0
python-dateutil    2.8.0
pywinpty           1.1.2
pyzmq              22.1.0
qtconsole          4.5.5
Send2Trash         1.5.0
setuptools         57.0.0
six                1.12.0
terminado          0.8.2
testpath           0.4.2
text-unidecode     1.2
tornado            6.0.3
traitlets          4.3.3
wcwidth            0.1.7
webencodings       0.5.1
Werkzeug           0.16.0
widgetsnbextension 3.5.1
zipp               0.6.0

Hi @Nicola_Farmer

Thanks for sharing those system details, they appear to be valid and sufficient for your environment to run the necessary M220P files.

I’m not sure and we haven’t tested within PyCharm so my first suggestion would be to test running the M220P files in a standard terminal environment to see if this PyCharm specific error.

Otherwise, you might try clearing any existing *.pyc and __pycache__ files that is within your PyCharm folders but essentially we don’t recommend PyCharm and we don’t test for that environment so it might be better if you want to continue to use that IDE to see if this is a similar/common error within their user forums.

I’ll reiterate my suggestion is to try this in your normal terminal environment as this is what we test for our supported operating systems and this is what we can help with, where issues arise.

Kindest regards,
Eoin