Exemple #1
0
    def test_by_interaction(self):
        """Interaction self-test.

        For comparison, try this:

            PYTHONPATH=. python graphwalker/cli.py --reporter=Print \\
              graphwalker/test/examples/selftest.graphml \\
              graphwalker.test.interactor.Interactor
        """
        outer = self

        class HijackReporter(reporting.ReportingPlugin):
            def finalize(self, failure=False):
                outer.assertFalse(failure)

        reporter = HijackReporter()
        plan = planning.build(['Random'])
        stop = stopcond.build('Coverage')
        model = graph.Graph.read('graphwalker/test/examples/selftest.graphml')
        actor = 'graphwalker.test.interactor.Interactor'
        exe = executor.Executor(actor, reporter)

        context = {
            'plan': plan,
            'stop': stop,
            'actor': actor,
            'reporter': reporter,
            'executor': exe,
            'model': model
        }

        stop.start(model, context)
        path = plan(model, stop, 'Start', context)

        exe.run('inner', path, context)
    def test_by_interaction(self):
        """Interaction self-test.

        For comparison, try this:

            PYTHONPATH=. python graphwalker/cli.py --reporter=Print \\
              graphwalker/test/examples/selftest.graphml \\
              graphwalker.test.interactor.Interactor
        """
        outer = self

        class HijackReporter(reporting.ReportingPlugin):
            def finalize(self, failure=False):
                outer.assertFalse(failure)

        reporter = HijackReporter()
        plan = planning.build(["Random"])
        stop = stopcond.build("Coverage")
        model = graph.Graph.read("graphwalker/test/examples/selftest.graphml")
        actor = "graphwalker.test.interactor.Interactor"
        exe = executor.Executor(actor, reporter)

        context = {"plan": plan, "stop": stop, "actor": actor, "reporter": reporter, "executor": exe, "model": model}

        stop.start(model, context)
        path = plan(model, stop, "Start", context)

        exe.run("inner", path, context)
    def test_by_interaction(self):
        """Interaction self-test.

        For comparison, try this:

            PYTHONPATH=. python graphwalker/cli.py --reporter=Print \\
              graphwalker/test/examples/selftest.graphml \\
              graphwalker.test.interactor.Interactor
        """
        outer = self

        class HijackReporter(reporting.ReportingPlugin):
            def finalize(self, failure=False):
                outer.assertFalse(failure)

        reporter = HijackReporter()
        plan = planning.build(['Random'])
        stop = stopcond.build('Coverage')
        model = graph.Graph.read('graphwalker/test/examples/selftest.graphml')
        actor = 'graphwalker.test.interactor.Interactor'
        exe = executor.Executor(actor, reporter)

        context = {
            'plan': plan, 'stop': stop, 'actor': actor,
            'reporter': reporter, 'executor': exe, 'model': model}

        stop.start(model, context)
        path = plan(model, stop, 'Start', context)

        exe.run('inner', path, context)
Exemple #4
0
def run(args):
    sys.path.append('')
    
    reporter = reporting.build(args.get('--reporter') or [])
    suite_name = args.get('--suite-name') or 'graphwalker'

    test_name = args.get('--test-name') or (
        args['<model>'].rsplit('/', 1)[-1].split('.')[0] + '-' +
        time.strftime('%Y%m%d%H%M%S'))

    reporter.start_suite(suite_name)

    plan = planning.build(args.get('--planner') or ['Random'])
    stop = stopcond.build(args.get('--stopcond') or 'Coverage')

    model = graph.Graph.read(args['<model>'])

    actor = args.get('<actor>') or 'graphwalker.dummy.Mute'

    debugger = args.get('--debug') and args.get('--debugger')

    exe = executor.Executor(actor, reporter, debugger)

    context = {'args': args, 'plan': plan, 'stop': stop, 'actor': actor,
               'reporter': reporter, 'executor': exe, 'model': model,
               'debugger': debugger}

    stop.start(model, context)
    path = plan(model, stop, 'Start', context)

    exe.run(test_name, path, context)

    reporter.end_suite()
Exemple #5
0
def run(args):
    sys.path.append('')
    modact = args['<model/actor>']
    assert len(modact) > 1

    reporter = reporting.build(args.get('--reporter') or [])
    suite_name = args.get('--suite-name') or 'graphwalker'

    test_name = args.get('--test-name') or (modact[0].rsplit(
        '/', 1)[-1].split('.')[0] + '-' + time.strftime('%Y%m%d%H%M%S'))

    reporter.start_suite(suite_name)

    plan = planning.build(args.get('--planner') or ['Random'])
    stop = stopcond.build(args.get('--stopcond') or 'Coverage')

    model = graph.Graph.read(modact[0])
    for n in modact[1:-1]:
        model = model.combine(graph.Graph.read(n))

    try:
        model = model.combine(graph.Graph.read(modact[-1]))
        actor = 'graphwalker.dummy.Mute'
    except:
        actor = modact[-1]

    debugger = args.get('--debug') and args.get('--debugger')

    exe = executor.Executor(actor, reporter, debugger)

    context = {
        'args': args,
        'plan': plan,
        'stop': stop,
        'actor': actor,
        'reporter': reporter,
        'executor': exe,
        'model': model,
        'debugger': debugger
    }

    stop.start(model, context)
    path = plan(model, stop, 'Start', context)

    exe.run(test_name, path, context)

    reporter.end_suite()