Test case

Mixin for noseapp supporting

class noseapp.case.base.ToNoseAppTestCase(*args, **kwargs)[source]

This is mixin for noseapp supporting. Class must be first in inheritance chain!

Usage:

class MyTestCase(ToNoseAppTestCase, unittest.TestCase):
    pass
ext(name)[source]

Get extension by name. Extension must be required.

Example:

suite = Suite(__name__, require=['extension'])

@suite.register
class Test(TestCase):

    def test(self):
        ext = self.ext('extension')
Parameters:name (str) – extension name
Raises:noseapp.core.extensions.ExtensionNotRequired
classmethod mount_to_suite(suite)[source]

Mount class to suite. If this procedure will be ignored then class can’t be instantiate.

Raises:RuntimeError
Return type:cls
of_suite

This is suite name after mounting.

Step by step case

class noseapp.case.screenplay.ScreenPlayCase(*args, **kwargs)[source]

Test case for implementation by step script

Usage:

class CaseExample(ScreenPlayCase):

    USE_PROMPT = True  # usage interactive debug

    @step(1, 'description')
    def step_1(self):
        self.assertTrue(True)

    @step(2, 'description')
    def step_2(self):
        self.assertTrue(True)


class CaseParametrizeExample(ScreenPlayCase):

    FLOWS = (
      1, 2, 3
    )

    @step(1, u'Step 1')
    def step_1(self, i):
        self.assertGreater(i, 0)

    @step(2, u'Step 2')
    def step_2(self, i):
        self.assertGreater(i, 0)


class SimpleCaseClass(ScreenPlayCase):

    def test(self):
        pass
begin()[source]

Callback. Will be called before run steps.

error_template_params

Params for ERROR_MESSAGE_TEMPLATE render.

Return type:dict
finalize()[source]

Callback. Will be called after run steps. If exception at step method will be raised then method can’t to be called.

render_error_message(**kwargs)[source]

Render error message by template.

Decorators

noseapp.case.decorators.flows(*flows)[source]

Decorator for parametrize test method.

Usage:

from noseapp import Suite
from noseapp import TestCase
from noseapp.datastructures import Context

suite = Suite(__name__)

@suite.register
class MyTestCase(TestCase):
    @flows(
        Context(integer=1, string='hello'),
        Context(integer=2, string='world'),
    )
    def test(self, ctx):
        ctx.integer
        ctx.string