Exemplo n.º 1
0
def test_feature_loaded_from_file_sets_scenario_line_and_scenario_filename():
    "Feature.from_file sets ScenarioDescription into Scenario objects, " "giving line number and filename as well"

    feature_file = cjoin("1st_feature_dir", "more_features_here", "another.feature")

    feature = Feature.from_file(feature_file)
    scenario1, scenario2 = feature.scenarios

    assert_equals(scenario1.described_at.file, fs.relpath(feature_file))
    assert_equals(scenario1.described_at.line, 6)

    assert_equals(scenario2.described_at.file, fs.relpath(feature_file))
    assert_equals(scenario2.described_at.line, 12)
Exemplo n.º 2
0
def test_feature_loaded_from_file_sets_scenario_line_and_scenario_filename():
    "Feature.from_file sets ScenarioDescription into Scenario objects, " \
    "giving line number and filename as well"

    feature_file = cjoin('1st_feature_dir', 'more_features_here', 'another.feature')

    feature = Feature.from_file(feature_file)
    scenario1, scenario2 = feature.scenarios

    assert_equals(scenario1.described_at.file, fs.relpath(feature_file))
    assert_equals(scenario1.described_at.line, 6)

    assert_equals(scenario2.described_at.file, fs.relpath(feature_file))
    assert_equals(scenario2.described_at.line, 12)
Exemplo n.º 3
0
def test_feature_loaded_from_file_sets_step_line_and_step_filenames():
    "Feature.from_file sets StepDescription into Scenario objects, " \
    "giving line number and filename as well"

    feature_file = cjoin('1st_feature_dir', 'one_more.feature')

    feature = Feature.from_file(feature_file)
    (scenario, ) = feature.scenarios

    step1, step2, step3, step4 = scenario.steps

    for step in scenario.steps:
        assert_equals(step.described_at.file, fs.relpath(feature_file))

    assert_equals(step1.sentence, "* I have entered 10 into the calculator")
    assert_equals(step1.described_at.line, 7)

    assert_equals(step2.sentence, "* I have entered 4 into the calculator")
    assert_equals(step2.described_at.line, 8)

    assert_equals(step3.sentence, "* I press multiply")
    assert_equals(step3.described_at.line, 9)

    assert_equals(step4.sentence, "* the result should be 40 on the screen")
    assert_equals(step4.described_at.line, 10)
Exemplo n.º 4
0
def test_feature_loaded_from_file_sets_step_line_and_step_filenames():
    "Feature.from_file sets StepDescription into Scenario objects, " \
    "giving line number and filename as well"

    feature_file = cjoin('1st_feature_dir', 'one_more.feature')

    feature = Feature.from_file(feature_file)
    (scenario, ) = feature.scenarios

    step1, step2, step3, step4 = scenario.steps

    for step in scenario.steps:
        assert_equals(step.described_at.file, fs.relpath(feature_file))

    assert_equals(step1.sentence, "* I have entered 10 into the calculator")
    assert_equals(step1.described_at.line, 7)

    assert_equals(step2.sentence, "* I have entered 4 into the calculator")
    assert_equals(step2.described_at.line, 8)

    assert_equals(step3.sentence, "* I press multiply")
    assert_equals(step3.described_at.line, 9)

    assert_equals(step4.sentence, "* the result should be 40 on the screen")
    assert_equals(step4.described_at.line, 10)
Exemplo n.º 5
0
def test_feature_loaded_from_file_has_feature_line_and_feature_filename():
    "Feature.from_file sets FeatureDescription into Feature objects, " "giving line number and filename as well"

    feature_file = cjoin("1st_feature_dir", "more_features_here", "another.feature")

    feature = Feature.from_file(feature_file)
    assert_equals(feature.described_at.file, fs.relpath(feature_file))
    assert_equals(feature.described_at.line, 2)
    assert_equals(feature.name, "Division")
    assert_equals(feature.described_at.description_at, (3, 4))
Exemplo n.º 6
0
def test_feature_loaded_from_file_has_feature_line_and_feature_filename():
    "Feature.from_file sets FeatureDescription into Feature objects, " \
    "giving line number and filename as well"

    feature_file = cjoin('1st_feature_dir', 'more_features_here', 'another.feature')

    feature = Feature.from_file(feature_file)
    assert_equals(feature.described_at.file, fs.relpath(feature_file))
    assert_equals(feature.described_at.line, 2)
    assert_equals(feature.name, 'Division')
    assert_equals(feature.described_at.description_at, (3, 4))
Exemplo n.º 7
0
def test_output_when_could_not_find_features_colorless():
    "Testing the colorful output of many successful features colorless"

    path = fs.relpath(join(abspath(dirname(__file__)), 'unexistent-folder'))
    runner = Runner(path, verbosity=3)
    runner.run()

    assert_stdout_lines(
        'Oops!\n'
        'could not find features at ./%s\n' % path
    )
Exemplo n.º 8
0
def test_feature_loaded_from_file_has_description_at():
    "Feature.from_file sets FeatureDescription with line numbers of its description"

    feature_file = cjoin("1st_feature_dir", "some.feature")

    feature = Feature.from_file(feature_file)
    assert_equals(feature.described_at.file, fs.relpath(feature_file))
    assert_equals(feature.described_at.line, 5)
    assert_equals(feature.name, "Addition")
    assert_equals(feature.described_at.description_at, (6, 7, 8))
    assert_equals(
        feature.description,
        "In order to avoid silly mistakes\n" "As a math idiot\n" "I want to be told the sum of two numbers",
    )
Exemplo n.º 9
0
def test_feature_loaded_from_file_has_description_at():
    "Feature.from_file sets FeatureDescription with line numbers of its description"

    feature_file = cjoin('1st_feature_dir', 'some.feature')

    feature = Feature.from_file(feature_file)
    assert_equals(feature.described_at.file, fs.relpath(feature_file))
    assert_equals(feature.described_at.line, 5)
    assert_equals(feature.name, 'Addition')
    assert_equals(feature.described_at.description_at, (6, 7, 8))
    assert_equals(
        feature.description, "In order to avoid silly mistakes\n"
        "As a math idiot\n"
        "I want to be told the sum of two numbers")
Exemplo n.º 10
0
def test_feature_loaded_from_file_has_feature_line_and_feature_filename():
    """
    Feature.from_file sets FeatureDescription into Feature objects,
    giving line number and filename as well
    """

    feature_file = cjoin('1st_feature_dir',
                         'more_features_here',
                         'another.feature')

    feature = Feature.from_file(feature_file)
    assert_equals(feature.described_at.file, fs.relpath(feature_file))
    assert_equals(feature.described_at.line, 2)
    assert_equals(feature.name, 'Division')
    assert_equals(feature.described_at.description_at, (3, 4))
Exemplo n.º 11
0
    def file(self):
        """
        Return the relative path to the file
        """

        # need to import this here to prevent a circular import
        from lettuce.core import fs

        if self._file:
            return fs.relpath(self._file)
        elif self.parent:
            if self.parent.feature.described_at is self:
                return None
            return self.parent.feature.described_at.file
        else:
            return None
from os.path import dirname, join, abspath

from lettuce import Runner
import lettuce
from lettuce.core import fs, StepDefinition

from tests.asserts import (
    assert_equals,
    assert_lines_with_traceback,
    capture_output,
)


current_dir = abspath(dirname(__file__))
lettuce_dir = abspath(dirname(lettuce.__file__))
lettuce_path = lambda *x: fs.relpath(join(lettuce_dir, *x))

call_line = StepDefinition.__call__.im_func.func_code.co_firstlineno + 5


def path_to_feature(name):
    return join(abspath(dirname(__file__)), 'behave_as_features', name, "%s.feature" % name)


def test_simple_behave_as_feature():
    """
    Basic step.behave_as behaviour is working
    """

    with capture_output() as (out, _):
        Runner(path_to_feature('1st_normal_steps'), verbosity=3).run()
Exemplo n.º 13
0
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
from nose.tools import with_setup
from os.path import dirname, join, abspath

from lettuce import Runner
import lettuce
from lettuce.core import fs, StepDefinition

from tests.asserts import prepare_stdout
from tests.asserts import assert_stdout_lines
from tests.asserts import assert_stdout_lines_with_traceback

current_dir = abspath(dirname(__file__))
lettuce_dir = abspath(dirname(lettuce.__file__))
lettuce_path = lambda *x: fs.relpath(join(lettuce_dir, *x))

call_line = StepDefinition.__call__.__func__.__code__.co_firstlineno + 5


def path_to_feature(name):
    return join(abspath(dirname(__file__)), 'behave_as_features', name,
                "%s.feature" % name)


@with_setup(prepare_stdout)
def test_simple_behave_as_feature():
    "Basic step.behave_as behaviour is working"
    Runner(path_to_feature('1st_normal_steps'), verbosity=3).run()
    assert_stdout_lines(
        "\n"