Структуру понял, спасибо.
Добавил файл в conftest.py.
Вот такого он формата:
#!/usr/bin/env python
# -- coding: utf-8 --
# coding: utf8
import allure
def pytest_exception_interact(node, call, report):
** driver = node.instance.driver**
** allure.attach(**
** name=‘Скриншот’,**
** contents=driver.get_screenshot_as_png(),**
** type=allure.constants.AttachmentType.PNG,**
** )**
Но при запуске такое выводит:
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/main.py”, line 110, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/main.py”, line 146, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 745, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 334, in
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/main.py”, line 169, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 745, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 334, in
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 613, in execute
INTERNALERROR> return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 254, in _wrapped_call
INTERNALERROR> return call_outcome.get_result()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 280, in get_result
INTERNALERROR> _reraise(*ex) # noqa
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 265, in init
INTERNALERROR> self.result = func()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 613, in execute
INTERNALERROR> return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 254, in _wrapped_call
INTERNALERROR> return call_outcome.get_result()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 280, in get_result
INTERNALERROR> _reraise(*ex) # noqa
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 265, in init
INTERNALERROR> self.result = func()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 613, in execute
INTERNALERROR> return _wrapped_call(hook_impl.function(*args), self.execute)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 254, in _wrapped_call
INTERNALERROR> return call_outcome.get_result()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 280, in get_result
INTERNALERROR> _reraise(*ex) # noqa
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 265, in init
INTERNALERROR> self.result = func()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/runner.py”, line 68, in pytest_runtest_protocol
INTERNALERROR> runtestprotocol(item, nextitem=nextitem)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/runner.py”, line 82, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, “call”, log))
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/runner.py”, line 168, in call_and_report
INTERNALERROR> hook.pytest_exception_interact(node=item, call=call, report=report)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 745, in call
INTERNALERROR> return self._hookexec(self, self._nonwrappers + self._wrappers, kwargs)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 339, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook, methods, kwargs)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 334, in
INTERNALERROR> _MultiCall(methods, kwargs, hook.spec_opts).execute()
INTERNALERROR> File “/Users/user/Desktop/autotesting2/config/lib/python2.7/site-packages/_pytest/vendored_packages/pluggy.py”, line 614, in execute
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File “/Users/user/Desktop/autotesting2/conftest.py”, line 9, in pytest_exception_interact
INTERNALERROR> driver = node.instance.driver
INTERNALERROR> AttributeError: TestSomeCase instance has no attribute ‘driver’
Или файл надо положить в virtualenv ?