How to Solve Attributeerror: 'Config' Object Has No Attribute '_Variables' for Pytest on Jenkins Execution

Trying to execute PyTest automation scripts using Jenkins Jobs. Initially I had configured 2 Jenkins Jobs with the exact same configuration. Scripts are running successfully with both jobs. Later I had created a 3rd job with the exact same configuration; but for same scripts/configuration it is throwing attribute error. Please find error details below,

"Executing tests"
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\_pytest\main.py", line 265, in wrap_session
INTERNALERROR>     config._do_configure()
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\_pytest\config\__init__.py", line 1056, in _do_configure
INTERNALERROR>     self.hook.pytest_configure.call_historic(kwargs=dict(config=self))
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\pluggy\_hooks.py", line 277, in call_historic
INTERNALERROR>     res = self._hookexec(self.name, self.get_hookimpls(), kwargs, False)
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\pluggy\_manager.py", line 80, in _hookexec
INTERNALERROR>     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\pluggy\_callers.py", line 60, in _multicall
INTERNALERROR>     return outcome.get_result()
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\pluggy\_result.py", line 60, in get_result
INTERNALERROR>     raise ex[1].with_traceback(ex[2])
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\pluggy\_callers.py", line 39, in _multicall
INTERNALERROR>     res = hook_impl.function(*args)
INTERNALERROR>   File "C:\ProgramData\Jenkins\.jenkins\workspace\Integration-Automation\sf_venv\lib\site-packages\pytest_selenium\pytest_selenium.py", line 249, in pytest_configure
INTERNALERROR>     capabilities = config._variables.get("capabilities", {})
INTERNALERROR> AttributeError: 'Config' object has no attribute '_variables'
"Test complete."

Batch batch command I am using -

pip install virtualenv
python -m virtualenv test
call .\test\Scripts\activate.bat
pip install -r requirements.txt
echo "Executing tests"
python -m pytest ./src/scripts/activities -v -m mytags --environment="TestEnvironment" --stream="TestStream" --junitxml="test_results/results.xml"
call deactivate
echo "Test complete."

Tried to execute scripts with differenet configuration like changing batch commands or not running both jobs in series.

5

1 Answer

I ran into the same problem, and while I haven't figured out what exactly is causing it, I'm pretty confident it is a result of upgrading to pytest 7. The same test works fine with pytest 6.2.5 and fails in 7.2.2.
Update: It's actually pytest-variables 3.0.0:

  • `Use pytest.stash internally instead of _variables`

  • 1

    Your Answer

    By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

    Elena Rostova

    Elena Rostova

    Lead Health, Wellness & Medical Journalist

    Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

    Share this article
    Twitter Facebook Pinterest