Ejemplo n.º 1
0
def test_unload_reload():
    """
    Test unloading and then reloading the step.
    """

    def step():  # pylint:disable=missing-docstring
        pass

    steps = StepDict()

    # Load
    steps.step(r'My step (\d)')(step)

    assert_matches(steps, "My step 1", (step, ('1',), {}))

    # Members added to step by registering it
    # pylint:disable=no-member

    # Unload
    step.unregister()

    assert_no_match(steps, "My step 1")

    # Should be a no-op
    step.unregister()

    assert_no_match(steps, "My step 1")

    # Reload
    steps.step(step.sentence)(step)

    assert_matches(steps, "My step 1", (step, ('1',), {}))
Ejemplo n.º 2
0
def test_unload_reload():
    """
    Test unloading and then reloading the step.
    """
    def step():  # pylint:disable=missing-docstring
        pass

    steps = StepDict()

    # Load
    steps.step(r"My step (\d)")(step)
    steps.step(r"Another step (\d)")(step)

    assert_matches(steps, "My step 1", (step, ("1", ), {}))
    assert_matches(steps, "Another step 1", (step, ("1", ), {}))

    # Members added to step by registering it
    # pylint:disable=no-member

    # Unload
    step.unregister()

    assert_no_match(steps, "My step 1")
    assert_no_match(steps, "Another step 1")

    # Should be a no-op
    step.unregister()

    assert_no_match(steps, "My step 1")
    assert_no_match(steps, "Another step 1")

    # Reload
    steps.step(r"My step (\d)")(step)

    assert_matches(steps, "My step 1", (step, ("1", ), {}))
Ejemplo n.º 3
0
def test_unload_reload():
    """
    Test unloading and then reloading the step.
    """

    def step():  # pylint:disable=missing-docstring
        pass

    class StepDefinition(object):
        """A step definition object to match."""
        sentence = 'My step 1'

    steps = StepDict()

    # Load
    steps.step(r'My step (\d)')(step)

    assert len(steps) == 1
    assert steps.match_step(StepDefinition) == (step, ('1',), {})

    # Members added to step by registering it
    # pylint:disable=no-member

    # Unload
    step.unregister()

    assert len(steps) == 0

    # Should be a no-op
    step.unregister()

    assert len(steps) == 0

    # Reload
    steps.step(step.sentence)(step)

    assert len(steps) == 1
    assert steps.match_step(StepDefinition) == (step, ('1',), {})
Ejemplo n.º 4
0
def test_unload_reload():
    """
    Test unloading and then reloading the step.
    """
    def step():  # pylint:disable=missing-docstring
        pass

    class StepDefinition(object):
        """A step definition object to match."""
        sentence = 'My step 1'

    steps = StepDict()

    # Load
    steps.step(r'My step (\d)')(step)

    assert len(steps) == 1
    assert steps.match_step(StepDefinition) == (step, ('1', ), {})

    # Members added to step by registering it
    # pylint:disable=no-member

    # Unload
    step.unregister()

    assert len(steps) == 0

    # Should be a no-op
    step.unregister()

    assert len(steps) == 0

    # Reload
    steps.step(step.sentence)(step)

    assert len(steps) == 1
    assert steps.match_step(StepDefinition) == (step, ('1', ), {})