import os
from zmq.eventloop import ioloop
from distutils.util import strtobool as _bool
from test_util import remove_peers_from_db

BEHAVE_DEBUG_ON_ERROR = _bool(os.environ.get("BEHAVE_DEBUG_ON_ERROR", "no"))


def after_step(context, step):
    if BEHAVE_DEBUG_ON_ERROR and step.status == "failed":
        # -- ENTER DEBUGGER: Zoom in on failure location.
        # NOTE: Use IPython debugger, same for pdb (basic python debugger).
        import pdb
        pdb.post_mortem(step.exc_traceback)


def before_all(context):
    # -- SET LOG LEVEL: behave --logging-level=ERROR ...
    # on behave command-line or in "behave.ini".
    context.config.setup_logging()


def before_scenario(context, scenario):
    cur = ioloop.IOLoop.current()
    ioloop.IOLoop.clear_current()
    cur.close(all_fds=True)
    newloop = ioloop.IOLoop()
    newloop.make_current()


def after_scenario(context, scenario):
Beispiel #2
0
# USE: BEHAVE_DEBUG_ON_ERROR=yes     (to enable debug-on-error)
import os
from distutils.util import strtobool as _bool

import erppeek
from support import tools, behave_better

__all__ = []
OPENERP_ARGS = [
    '-c',
    os.environ.get('OERPSCENARIO_ODOO_CONFIG') or 'etc/openerp.cfg',
    '--logfile=var/log/behave-stdout.log',
]

# stolen from https://pythonhosted.org/behave/tutorial.html
BEHAVE_DEBUG_ON_ERROR = _bool(os.environ.get("BEHAVE_DEBUG_ON_ERROR", "no"))

# Print readable 'Fault' errors
tools.patch_traceback()
# Some monkey patches to enhance Behave
behave_better.patch_all()


def before_all(ctx):
    if erppeek.__version__ < '1.6':
        server = erppeek.start_openerp_services(' '.join(OPENERP_ARGS))
    else:
        server = erppeek.start_odoo_services(OPENERP_ARGS)
    database = server.tools.config['db_name']

    def _output_write(text):
Beispiel #3
0
from distutils.util import strtobool as _bool
import os
import pdb
import shutil
import tempfile


def before_scenario(context, scenario):
    context.cli_args = []
    context.cli_filenames = set()
    context.process_output = None
    context.process_exit_code = None
    context.test_data_folder = tempfile.mkdtemp()


def after_scenario(context, scenario):
    shutil.rmtree(context.test_data_folder)


debug_flag = _bool(os.environ.get("DEBUG", "no"))


def after_step(context, step):
    if debug_flag and step.status == "failed":
        pdb.post_mortem(step.exc_traceback)