Skip to content

Key errors while running pytest #3112

@nbharadwaj11

Description

@nbharadwaj11

Thanks for submitting an issue!

Here's a quick checklist in what to include:

  • Include a detailed description of the bug or suggestion
  • pip list of the virtual environment you are using
  • pytest and operating system versions
  • Minimal example if possible

I have been seeing key errors while running pytest.
I have a test suite written in pytest, and when I try to run it, I see the following errors all the time:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config.py", line 328, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/Users/nbharadwaj/code/thewall/tests/test_sign_out.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config.py", line 328, in _getconftestmodules
    return self._path2confmods[path]
KeyError: local('/Users/nbharadwaj/code/thewall/tests')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config.py", line 359, in _importconftest
    return self._conftestpath2mod[conftestpath]
KeyError: local('/Users/nbharadwaj/code/thewall/conftest.py')

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/_pytest/config.py", line 365, in _importconftest
    mod = conftestpath.pyimport()
  File "/usr/local/lib/python3.6/site-packages/py/_path/local.py", line 668, in pyimport
    __import__(modname)
  File "/usr/local/lib/python3.6/site-packages/_pytest/assertion/rewrite.py", line 213, in load_module
    py.builtin.exec_(co, mod.__dict__)
  File "/Users/nbharadwaj/code/thewall/conftest.py", line 6, in <module>
    import pandas as pd
ModuleNotFoundError: No module named 'pandas'
ERROR: could not load /Users/nbharadwaj/code/thewall/conftest.py

My system was is running 2 versions of python. Python 2.7 and Python 3.6

Python 3.6 is what my test suite is written on. I have tried uninstalling and reinstalling python3.6 multiple times, but have not had any luck with it so far. I am using pycharm as my IDE.

pytest version: 3.3.2
operating system: MacOS Sierra 10.12.6

Can someone please help me on this?


edited by @The-Compiler to add code tags

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: questiongeneral question, might be closed after 2 weeks of inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions