view _ui_tests/conftest.py @ 1862:afa63a0cc1e1

partial revert of dab0253193eb
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 18 Nov 2012 16:58:06 +0100
parents f87d2e646c60
children 384555088cab
line wrap: on
line source
# Copyright: 2012 MoinMoin:HughPerkins
# License: GNU GPL v3 (or any later version), see LICENSE.txt for details.

"""
Contains events called by py.test during the life-cycle of the test suite
This module is automatically loaded by py.test, which looks for a file
of this name
"""

import os
import sys
sys.path.append(os.path.dirname(__file__))
import driver_register

def pytest_runtest_makereport(item, call):
    """
    Entry point for event which occurs after each test has run
    The parameters are:
    - item: the method called
    - call: an object of type CallInfo, which has two properties, of which
      excinfo contains info about any exception that got thrown by the method
    This method is called automatically by py.test.  The name of the method
    is used by py.test to locate it, and decide when to call it
    This specific method instance is used to take a screenshot whenever a test
    fails, ie whenever the method throws an exception
    """
    if call.excinfo is not None:
        if driver_register.get_driver() is not None and hasattr(item, 'obj'):
            driver_register.get_driver().get_screenshot_as_file(
                unicode(item.obj).split(u" ")[2] + u'.png')