skip to Main Content

I’m trying to run pytest which worked in pycharm, but can’t manage to run it on vscode.

First I’m doing:

python -m venv env
envScriptsactivate
python -m pip install --upgrade pip
pip install selenium webdriver-manager pytest pytest-html
Package            Version
------------------ -----------
pip                23.3.2
pytest             7.4.4
pytest-html        4.1.1
pytest-metadata    3.0.0
pytest-xdist       3.5.0
selenium           4.16.0
setuptools         69.0.3
webdriver-manager  4.0.1

The packages appear in the venv yet getting the following error:

(env) PS C:UsersUserDesktopautomation-projectsPythonpaloAlto> pytest
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltoenvLibsite-packages_pytestmain.py", line 267, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltoenvLibsite-packages_pytestconfig__init__.py", line 1053, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltoenvLibsite-packagespluggy_hooks.py", line 514, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self._hookimpls, kwargs, False)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltoenvLibsite-packagespluggy_manager.py", line 115, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltoenvLibsite-packagespluggy_callers.py", line 113, in _multicall
INTERNALERROR>     raise exception.with_traceback(exception.__traceback__)
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltoenvLibsite-packagespluggy_callers.py", line 77, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>           ^^^^^^^^^^^^^^^^^^^^^^^^^
INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltotestCasesconftest.py", line 49, in pytest_configure
INTERNALERROR>     config._metadata['Project Name'] = 'Palo Alto'
INTERNALERROR>     ^^^^^^^^^^^^^^^^
INTERNALERROR> AttributeError: 'Config' object has no attribute '_metadata'

2

Answers


  1. PS suggests you are using a Powershell terminal. Close that terminal and start a command prompt terminal. Powershell terminal can generate many issues with Python.

    Login or Signup to reply.
  2. INTERNALERROR>   File "C:UsersUserDesktopautomation-projectsPythonpaloAltotestCasesconftest.py", line 49, in pytest_configure
    INTERNALERROR>     config._metadata['Project Name'] = 'Palo Alto'
    

    In pytest, the Config object does not have a _metadata attribute by default.

    It should be changed to:

    def pytest_configure(config):
        config.metadata['Project Name'] = 'Palo Alto'
    

    This should resolve the AttributeError you’re seeing.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search