コード例 #1
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_can_extract_a_step_sentence_from_function_doc():
    "lettuce.STEP_REGISTRY._extract_sentence(func) parse func doc and return a sentence"
    steps = StepDict()
    def a_step_func():
        """A step sentence"""
        pass
    assert_equal("A step sentence", steps._extract_sentence(a_step_func))
コード例 #2
0
ファイル: test_registry.py プロジェクト: zerolugithub/lettuce
def test_StepDict_can_extract_a_step_sentence_from_function_doc():
    u"lettuce.STEP_REGISTRY._extract_sentence(func) parse func doc and return a sentence"
    steps = StepDict()
    def a_step_func():
        """A step sentence"""
        pass
    assert_equal("A step sentence", steps._extract_sentence(a_step_func))
コード例 #3
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_can_load_a_step_composed_of_a_regex_and_a_function():
    "lettuce.STEP_REGISTRY.load(step, func) append item(step, func) to STEP_REGISTRY"
    steps = StepDict()
    func = lambda: ""
    step = "a step to test"
    steps.load(step, func)
    assert (step in steps)
    assert_equal(steps[step], func)
コード例 #4
0
ファイル: test_registry.py プロジェクト: Acetonen/lettuce-py3
def test_StepDict_can_load_a_step_composed_of_a_regex_and_a_function():
    "lettuce.STEP_REGISTRY.load(step, func) append item(step, func) to STEP_REGISTRY"
    steps = StepDict()
    func = lambda: ""
    step = "a step to test"
    steps.load(step, func)
    assert (step in steps)
    assert_equal(steps[step], func)
コード例 #5
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_can_load_a_step_from_a_function():
    "lettuce.STEP_REGISTRY.load_func(func) append item(step, func) to STEP_REGISTRY"
    steps = StepDict()
    def a_step_to_test():
        pass

    steps.load_func(a_step_to_test)

    expected_sentence = "A step to test"
    assert (expected_sentence in steps)
    assert_equal(steps[expected_sentence], a_step_to_test)
コード例 #6
0
ファイル: test_registry.py プロジェクト: zerolugithub/lettuce
def test_StepDict_can_load_a_step_from_a_function():
    u"lettuce.STEP_REGISTRY.load_func(func) append item(step, func) to STEP_REGISTRY"
    steps = StepDict()
    def a_step_to_test():
        pass

    steps.load_func(a_step_to_test)

    expected_sentence = "A step to test"
    assert (expected_sentence in steps)
    assert_equal(steps[expected_sentence], a_step_to_test)
コード例 #7
0
ファイル: test_registry.py プロジェクト: zerolugithub/lettuce
def test_StepDict_can_exclude_callable_object_when_load_steps():
    u"lettuce.STEP_REGISTRY.load_steps(obj) don't load callable objets in STEP_REGISTRY"
    steps = StepDict()
    class NoStep:
        class NotAStep(object):
            def __call__(self):
                pass

    no_step = NoStep()
    steps.load_steps(no_step)

    assert len(steps) == 0
コード例 #8
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_can_exclude_callable_object_when_load_steps():
    "lettuce.STEP_REGISTRY.load_steps(obj) don't load callable objets in STEP_REGISTRY"
    steps = StepDict()
    class NoStep:
        class NotAStep(object):
            def __call__(self):
                pass

    no_step = NoStep()
    steps.load_steps(no_step)

    assert len(steps) == 0
コード例 #9
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_can_exclude_methods_when_load_steps():
    "lettuce.STEP_REGISTRY.load_steps(obj) don't load exluded attr in STEP_REGISTRY"
    steps = StepDict()
    class LotsOfSteps:
        exclude = ["step_1"]
        def step_1(self):
            pass
        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = "Step 1"
    expected_sentence2 = "Doing something"
    assert (expected_sentence1 not in steps)
    assert (expected_sentence2 in steps)
コード例 #10
0
ファイル: test_registry.py プロジェクト: zerolugithub/lettuce
def test_StepDict_can_exclude_methods_when_load_steps():
    u"lettuce.STEP_REGISTRY.load_steps(obj) don't load exluded attr in STEP_REGISTRY"
    steps = StepDict()
    class LotsOfSteps:
        exclude = ["step_1"]
        def step_1(self):
            pass
        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = "Step 1"
    expected_sentence2 = "Doing something"
    assert (expected_sentence1 not in steps)
    assert (expected_sentence2 in steps)
コード例 #11
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_can_load_steps_from_an_object():
    "lettuce.STEP_REGISTRY.load_steps(obj) append all obj methods to STEP_REGISTRY"
    steps = StepDict()
    class LotsOfSteps:
        def step_1(self):
            pass
        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = "Step 1"
    expected_sentence2 = "Doing something"
    assert (expected_sentence1 in steps)
    assert (expected_sentence2 in steps)
    assert_equal(steps[expected_sentence1], step_list.step_1)
    assert_equal(steps[expected_sentence2], step_list.step_2)
コード例 #12
0
ファイル: test_registry.py プロジェクト: zerolugithub/lettuce
def test_StepDict_can_load_steps_from_an_object():
    u"lettuce.STEP_REGISTRY.load_steps(obj) append all obj methods to STEP_REGISTRY"
    steps = StepDict()
    class LotsOfSteps:
        def step_1(self):
            pass
        def step_2(self):
            """Doing something"""
            pass

    step_list = LotsOfSteps()
    steps.load_steps(step_list)

    expected_sentence1 = "Step 1"
    expected_sentence2 = "Doing something"
    assert (expected_sentence1 in steps)
    assert (expected_sentence2 in steps)
    assert_equal(steps[expected_sentence1], step_list.step_1)
    assert_equal(steps[expected_sentence2], step_list.step_2)
コード例 #13
0
ファイル: test_registry.py プロジェクト: Acetonen/lettuce-py3
def test_StepDict_raise_StepLoadingError_if_load_first_argument_is_not_a_regex(
):
    "lettuce.STEP_REGISTRY.load(step, func) should raise an error if step is not a regex"
    steps = StepDict()
    test_load = lambda: steps.load("an invalid regex;)", lambda: "")
    assert_raises(StepLoadingError, test_load)
コード例 #14
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_load_a_step_return_the_given_function():
    "lettuce.STEP_REGISTRY.load(step, func) returns func"
    steps = StepDict()
    func = lambda: ""
    assert_equal(steps.load("another step", func), func)
コード例 #15
0
def test_StepDict_can_extract_a_step_sentence_from_function_name():
    u"lettuce.STEP_REGISTRY._extract_sentence(func) parse func name and return a sentence"
    steps = StepDict()
    def a_step_sentence():
        pass
    assert_equal("A step sentence", steps._extract_sentence(a_step_sentence))
コード例 #16
0
ファイル: test_registry.py プロジェクト: Acetonen/lettuce-py3
def test_StepDict_load_a_step_return_the_given_function():
    "lettuce.STEP_REGISTRY.load(step, func) returns func"
    steps = StepDict()
    func = lambda: ""
    assert_equal(steps.load("another step", func), func)
コード例 #17
0
ファイル: test_registry.py プロジェクト: rpaloschi/lettuce
def test_StepDict_raise_StepLoadingError_if_load_first_argument_is_not_a_regex():
    "lettuce.STEP_REGISTRY.load(step, func) should raise an error if step is not a regex"
    steps = StepDict()
    test_load = lambda: steps.load("an invalid regex;)", lambda: "")
    assert_raises(StepLoadingError, test_load)