def test_output_of_table_with_success_colorless(): "Language: pt-br -> sucess table colorless" runner = Runner(join_path('pt-br', 'success', 'table.feature'), verbosity=3) runner.run() assert_stdout_lines( u"\n" u"Funcionalidade: feature burra, com tabela # tests/functional/language_specific_features/pt-br/success/table.feature:3\n" u" Como um programador # tests/functional/language_specific_features/pt-br/success/table.feature:4\n" u" Eu quero testar steps com tabelas # tests/functional/language_specific_features/pt-br/success/table.feature:5\n" u" Para ver o output em pt-br # tests/functional/language_specific_features/pt-br/success/table.feature:6\n" u"\n" u" Cenário: Fazer nada, com tabelas :) # tests/functional/language_specific_features/pt-br/success/table.feature:8\n" u" Dado que eu brinco com os seguintes itens: # tests/functional/language_specific_features/pt-br/success/table_steps.py:6\n" u" | id | description |\n" u" | 12 | some desc |\n" u" | 64 | another desc |\n" u"\033[A\033[A\033[A\033[A Dado que eu brinco com os seguintes itens: # tests/functional/language_specific_features/pt-br/success/table_steps.py:6\n" u" | id | description |\n" u" | 12 | some desc |\n" u" | 64 | another desc |\n" u"\n" u"1 feature (1 passed)\n" u"1 scenario (1 passed)\n" u"1 step (1 passed)\n" )
def test_output_outlines_success_colorful(): "Language: zh-TW -> sucess outlines colorful" runner = Runner(join_path('zh-TW', 'success', 'outlines.feature'), verbosity=4) runner.run() assert_stdout_lines( '\n' "\033[1;37m特性: 中文場景模板 \033[1;30m# tests/functional/language_specific_features/zh-TW/success/outlines.feature:3\033[0m\n" "\033[1;37m 中文場景模板圖表測試 \033[1;30m# tests/functional/language_specific_features/zh-TW/success/outlines.feature:4\033[0m\n" '\n' "\033[1;37m 場景模板: 用表格描述場景 \033[1;30m# tests/functional/language_specific_features/zh-TW/success/outlines.feature:6\033[0m\n" "\033[0;36m 如果 輸入是<輸入> \033[1;30m# tests/functional/language_specific_features/zh-TW/success/outlines_steps.py:13\033[0m\n" "\033[0;36m 當 執行<處理>時 \033[1;30m# tests/functional/language_specific_features/zh-TW/success/outlines_steps.py:22\033[0m\n" "\033[0;36m 那麽 得到<結果> \033[1;30m# tests/functional/language_specific_features/zh-TW/success/outlines_steps.py:31\033[0m\n" '\n' "\033[1;37m 例如:\033[0m\n" "\033[0;36m \033[1;37m |\033[0;36m 輸入\033[1;37m |\033[0;36m 處理\033[1;37m |\033[0;36m 結果 \033[1;37m |\033[0;36m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 什麽\033[1;37m |\033[1;32m 這個\033[1;37m |\033[1;32m 功能 \033[1;37m |\033[1;32m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 其他\033[1;37m |\033[1;32m 這裏\033[1;37m |\033[1;32m 一樣 \033[1;37m |\033[1;32m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 數據\033[1;37m |\033[1;32m 動作\033[1;37m |\033[1;32m unicode輸出!\033[1;37m |\033[1;32m\033[0m\n" '\n' "\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n" "\033[1;37m3 scenarios (\033[1;32m3 passed\033[1;37m)\033[0m\n" "\033[1;37m9 steps (\033[1;32m9 passed\033[1;37m)\033[0m\n" )
def test_subunit_output_with_tags(): """ Test Subunit output with tags """ state.expect = [ Includes({ 'status': 'success', 'tags': set(['slow-ish']), }), Includes({ 'status': 'success', 'tags': set(['fast-ish']), }), Includes({ 'status': 'success', 'tags': set(), }), Includes({ 'status': 'success', 'tags': set(), }), ] runner = Runner(feature_name('tagged_features'), enable_subunit=True) runner.run()
def test_output_outlines_success_colorful(): "Language: pt-br -> sucess outlines colorful" runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=4) runner.run() assert_stdout_lines( u'\n' u'\033[1;37mFuncionalidade: outlines em português \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines.feature:3\033[0m\n' u'\033[1;37m Como um programador \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines.feature:4\033[0m\n' u'\033[1;37m Eu quero testar cenários esquemáticos \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines.feature:5\033[0m\n' u'\033[1;37m Para ver o output em pt-br \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines.feature:6\033[0m\n' u'\n' u'\033[1;37m Esquema do Cenário: Fazer nada, repetidas vezes, através de esquemas \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines.feature:8\033[0m\n' u'\033[0;36m Dado que tenho o <dado1> \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines_steps.py:13\033[0m\n' u'\033[0;36m Quando eu faço algo com <isso> \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines_steps.py:22\033[0m\n' u'\033[0;36m Então eu fico feliz em ver <aquilo> \033[1;30m# tests/functional/language_specific_features/pt-br/success/outlines_steps.py:31\033[0m\n' u'\n' u'\033[1;37m Exemplos:\033[0m\n' u'\033[0;36m \033[1;37m |\033[0;36m dado1\033[1;37m |\033[0;36m isso \033[1;37m |\033[0;36m aquilo \033[1;37m |\033[0;36m\033[0m\n' u'\033[1;32m \033[1;37m |\033[1;32m algo \033[1;37m |\033[1;32m assim \033[1;37m |\033[1;32m funcional \033[1;37m |\033[1;32m\033[0m\n' u'\033[1;32m \033[1;37m |\033[1;32m outro\033[1;37m |\033[1;32m aqui \033[1;37m |\033[1;32m também \033[1;37m |\033[1;32m\033[0m\n' u'\033[1;32m \033[1;37m |\033[1;32m dados\033[1;37m |\033[1;32m funcionarão\033[1;37m |\033[1;32m com unicode !\033[1;37m |\033[1;32m\033[0m\n' u'\n' u"\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n" \ u"\033[1;37m3 scenarios (\033[1;32m3 passed\033[1;37m)\033[0m\n" \ u"\033[1;37m9 steps (\033[1;32m9 passed\033[1;37m)\033[0m\n" )
def test_output_outlines_success_colorless(): "Language: zh-CN -> sucess outlines colorless" runner = Runner(join_path('zh-CN', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_stdout_lines( "\n" "特性: 中文场景模板 # tests/functional/language_specific_features/zh-CN/success/outlines.feature:3\n" " 中文场景模板图表测试 # tests/functional/language_specific_features/zh-CN/success/outlines.feature:4\n" "\n" " 场景模板: 用表格描述场景 # tests/functional/language_specific_features/zh-CN/success/outlines.feature:6\n" " 如果 输入是<输入> # tests/functional/language_specific_features/zh-CN/success/outlines_steps.py:13\n" " 当 执行<处理>时 # tests/functional/language_specific_features/zh-CN/success/outlines_steps.py:22\n" " 那么 得到<结果> # tests/functional/language_specific_features/zh-CN/success/outlines_steps.py:31\n" "\n" " 例如:\n" " | 输入 | 处理 | 结果 |\n" " | 什么 | 这个 | 功能 |\n" " | 其他 | 这里 | 一样 |\n" " | 数据 | 动作 | unicode输出! |\n" "\n" "1 feature (1 passed)\n" "3 scenarios (3 passed)\n" "9 steps (9 passed)\n" )
def test_output_outlines_success_colorless(): "Language: zh-TW -> sucess outlines colorless" runner = Runner(join_path('zh-TW', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_stdout_lines( "\n" "特性: 中文場景模板 # tests/functional/language_specific_features/zh-TW/success/outlines.feature:3\n" " 中文場景模板圖表測試 # tests/functional/language_specific_features/zh-TW/success/outlines.feature:4\n" "\n" " 場景模板: 用表格描述場景 # tests/functional/language_specific_features/zh-TW/success/outlines.feature:6\n" " 如果 輸入是<輸入> # tests/functional/language_specific_features/zh-TW/success/outlines_steps.py:13\n" " 當 執行<處理>時 # tests/functional/language_specific_features/zh-TW/success/outlines_steps.py:22\n" " 那麽 得到<結果> # tests/functional/language_specific_features/zh-TW/success/outlines_steps.py:31\n" "\n" " 例如:\n" " | 輸入 | 處理 | 結果 |\n" " | 什麽 | 這個 | 功能 |\n" " | 其他 | 這裏 | 一樣 |\n" " | 數據 | 動作 | unicode輸出! |\n" "\n" "1 feature (1 passed)\n" "3 scenarios (3 passed)\n" "9 steps (9 passed)\n" )
def test_xunit_output_with_background_section(): 'Test xunit output with a background section in the feature' called = [] def assert_correct_xml(filename, content): called.append(True) assert_xsd_valid(filename, content) root = etree.fromstring(content) assert_equals(root.get("tests"), "1") assert_equals(root.get("failures"), "0") assert_equals(len(root.getchildren()), 2) passed1, passed2 = root.findall("testcase") assert_equals(passed1.get("name"), 'Given the variable "X" holds 2') assert_true(float(passed1.get("time")) > 0) assert_equals(passed2.get("name"), 'Given the variable "X" is equal to 2') assert_true(float(passed2.get("time")) > 0) from lettuce import step @step(ur'the variable "(\w+)" holds (\d+)') @step(ur'the variable "(\w+)" is equal to (\d+)') def just_pass(step, *args): pass filename = bg_feature_name('simple') old = xunit_output.wrt_output xunit_output.wrt_output = assert_correct_xml runner = Runner(filename, enable_xunit=True) runner.run() assert_equals(1, len(called), "Function not called") xunit_output.wrt_output = old
def test_output_outlines_success_colorful(): "Language: ja -> sucess outlines colorful" runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=4) runner.run() assert_stdout_lines( '\n' "\033[1;37mフィーチャ: アウトラインを日本語で書く \033[1;30m# tests/functional/language_specific_features/ja/success/outlines.feature:3\033[0m\n" "\033[1;37m 図表のテストをパスすること \033[1;30m# tests/functional/language_specific_features/ja/success/outlines.feature:4\033[0m\n" '\n' "\033[1;37m シナリオアウトライン: 全てのテストで何もしない \033[1;30m# tests/functional/language_specific_features/ja/success/outlines.feature:6\033[0m\n" "\033[0;36m 前提 入力値を <データ1> とし \033[1;30m# tests/functional/language_specific_features/ja/success/outlines_steps.py:13\033[0m\n" "\033[0;36m もし 処理 <方法> を使って \033[1;30m# tests/functional/language_specific_features/ja/success/outlines_steps.py:22\033[0m\n" "\033[0;36m ならば 表示は <結果> である \033[1;30m# tests/functional/language_specific_features/ja/success/outlines_steps.py:31\033[0m\n" '\n' "\033[1;37m 例:\033[0m\n" "\033[0;36m \033[1;37m |\033[0;36m データ1\033[1;37m |\033[0;36m 方法\033[1;37m |\033[0;36m 結果 \033[1;37m |\033[0;36m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 何か \033[1;37m |\033[1;32m これ\033[1;37m |\033[1;32m 機能 \033[1;37m |\033[1;32m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m その他 \033[1;37m |\033[1;32m ここ\033[1;37m |\033[1;32m 同じ \033[1;37m |\033[1;32m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m データ \033[1;37m |\033[1;32m 動く\033[1;37m |\033[1;32m unicodeで!\033[1;37m |\033[1;32m\033[0m\n" '\n' "\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n" "\033[1;37m3 scenarios (\033[1;32m3 passed\033[1;37m)\033[0m\n" "\033[1;37m9 steps (\033[1;32m9 passed\033[1;37m)\033[0m\n" )
def test_output_of_table_with_success_colorless(): """Language: fr -> sucess table colorless""" with capture_output() as (out, err): runner = Runner(join_path('fr', 'success', 'table.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u""" Fonctionnalité: Test des sorties, avec table # tests/functional/language_specific_features/fr/success/table.feature:4 En tant que programmeur # tests/functional/language_specific_features/fr/success/table.feature:5 Je veux tester les sorties de scénario avec table # tests/functional/language_specific_features/fr/success/table.feature:6 #1 Scénario: NE rien faire, mais avec des tables # tests/functional/language_specific_features/fr/success/table.feature:8 Soit les éléments suivant # tests/functional/language_specific_features/fr/success/table_steps.py:6 | id | élément | | 50 | Un | | 59 | 42 | | 29 | sieste | ---------------------------------------------------------------------------- 1 feature (1 passed) 1 scenario (1 passed) 1 step (1 passed) """)
def test_output_with_successful_outline_colorful(): "Testing the colorful output of a scenario outline" runner = Runner(feature_name('success_outline'), verbosity=4) runner.run() assert_stdout_lines( '\n' '\033[1;37mFeature: Successful Scenario Outline \033[1;30m# tests/functional/output_features/success_outline/success_outline.feature:1\033[0m\n' '\033[1;37m As lettuce author \033[1;30m# tests/functional/output_features/success_outline/success_outline.feature:2\033[0m\n' '\033[1;37m In order to finish the first release \033[1;30m# tests/functional/output_features/success_outline/success_outline.feature:3\033[0m\n' '\033[1;37m I want to make scenario outlines work :) \033[1;30m# tests/functional/output_features/success_outline/success_outline.feature:4\033[0m\n' '\n' '\033[1;37m Scenario Outline: fill a web form \033[1;30m# tests/functional/output_features/success_outline/success_outline.feature:6\033[0m\n' '\033[0;36m Given I open browser at "http://www.my-website.com/" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:21\033[0m\n' '\033[0;36m And click on "sign-up" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:25\033[0m\n' '\033[0;36m When I fill the field "username" with "<username>" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:29\033[0m\n' '\033[0;36m And I fill the field "password" with "<password>" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:29\033[0m\n' '\033[0;36m And I fill the field "password-confirm" with "<password>" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:29\033[0m\n' '\033[0;36m And I fill the field "email" with "<email>" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:29\033[0m\n' '\033[0;36m And I click "done" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:33\033[0m\n' '\033[0;36m Then I see the message "<message>" \033[1;30m# tests/functional/output_features/success_outline/success_outline_steps.py:37\033[0m\n' '\n' '\033[1;37m Examples:\033[0m\n' '\033[0;36m \033[1;37m |\033[0;36m username\033[1;37m |\033[0;36m password\033[1;37m |\033[0;36m email \033[1;37m |\033[0;36m message \033[1;37m |\033[0;36m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m john \033[1;37m |\033[1;32m doe-1234\033[1;37m |\033[1;32m [email protected]\033[1;37m |\033[1;32m Welcome, John\033[1;37m |\033[1;32m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m mary \033[1;37m |\033[1;32m wee-9876\033[1;37m |\033[1;32m [email protected]\033[1;37m |\033[1;32m Welcome, Mary\033[1;37m |\033[1;32m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m foo \033[1;37m |\033[1;32m foo-bar \033[1;37m |\033[1;32m [email protected] \033[1;37m |\033[1;32m Welcome, Foo \033[1;37m |\033[1;32m\033[0m\n' '\n' "\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n" \ "\033[1;37m3 scenarios (\033[1;32m3 passed\033[1;37m)\033[0m\n" \ "\033[1;37m24 steps (\033[1;32m24 passed\033[1;37m)\033[0m\n" )
def test_output_snippets_with_groups_within_single_quotes_colorless(): "Testing that the proposed snippet is clever enough to identify groups within single quotes. colorless" runner = Runner(feature_name('single-quoted-snippet'), verbosity=3) runner.run() assert_stdout_lines( u'\n' u'Feature: single-quoted snippet proposal # tests/functional/output_features/single-quoted-snippet/single-quoted-snippet.feature:1\n' u'\n' u' Scenario: Propose matched groups # tests/functional/output_features/single-quoted-snippet/single-quoted-snippet.feature:2\n' u' Given I have \'stuff here\' and \'more @#$%ˆ& bizar sutff h3r3\' # tests/functional/output_features/single-quoted-snippet/single-quoted-snippet.feature:3 (undefined)\n' u'\n' u'1 feature (0 passed)\n' u'1 scenario (0 passed)\n' u'1 step (1 undefined, 0 passed)\n' u'\n' u'You can implement step definitions for undefined steps with these snippets:\n' u'\n' u'from lettuce import step\n' u'\n' u'@step(r\'Given I have \\\'(.*)\\\' and \\\'(.*)\\\'\')\n' u'def given_i_have_group1_and_group2(step, group1, group2):\n' u' pass\n' )
def test_output_with_success_colorful_many_features(): "Testing the colorful output of many successful features" runner = Runner(join(abspath(dirname(__file__)), 'output_features', 'many_successful_features'), verbosity=4) runner.run() assert_stdout_lines( "\n" "\033[1;37mFeature: First feature, of many \033[1;30m# tests/functional/output_features/many_successful_features/one.feature:1\033[0m\n" "\033[1;37m In order to make lettuce more robust \033[1;30m# tests/functional/output_features/many_successful_features/one.feature:2\033[0m\n" "\033[1;37m As a programmer \033[1;30m# tests/functional/output_features/many_successful_features/one.feature:3\033[0m\n" "\033[1;37m I want to test its output on many features \033[1;30m# tests/functional/output_features/many_successful_features/one.feature:4\033[0m\n" "\n" "\033[1;37m Scenario: Do nothing \033[1;30m# tests/functional/output_features/many_successful_features/one.feature:6\033[0m\n" "\033[1;30m Given I do nothing \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:6\033[0m\n" "\033[A\033[1;32m Given I do nothing \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:6\033[0m\n" "\033[1;30m Then I see that the test passes \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:8\033[0m\n" "\033[A\033[1;32m Then I see that the test passes \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:8\033[0m\n" "\n" "\033[1;37mFeature: Second feature, of many \033[1;30m# tests/functional/output_features/many_successful_features/two.feature:1\033[0m\n" "\033[1;37m I just want to see it green :) \033[1;30m# tests/functional/output_features/many_successful_features/two.feature:2\033[0m\n" "\n" "\033[1;37m Scenario: Do nothing \033[1;30m# tests/functional/output_features/many_successful_features/two.feature:4\033[0m\n" "\033[1;30m Given I do nothing \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:6\033[0m\n" "\033[A\033[1;32m Given I do nothing \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:6\033[0m\n" "\033[1;30m Then I see that the test passes \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:8\033[0m\n" "\033[A\033[1;32m Then I see that the test passes \033[1;30m# tests/functional/output_features/many_successful_features/dumb_steps.py:8\033[0m\n" "\n" "\033[1;37m2 features (\033[1;32m2 passed\033[1;37m)\033[0m\n" \ "\033[1;37m2 scenarios (\033[1;32m2 passed\033[1;37m)\033[0m\n" \ "\033[1;37m4 steps (\033[1;32m4 passed\033[1;37m)\033[0m\n" )
def test_output_with_successful_outline_colorless(): "Testing the colorless output of a scenario outline" runner = Runner(feature_name('success_outline'), verbosity=3) runner.run() assert_stdout_lines( '\n' 'Feature: Successful Scenario Outline # tests/functional/output_features/success_outline/success_outline.feature:1\n' ' As lettuce author # tests/functional/output_features/success_outline/success_outline.feature:2\n' ' In order to finish the first release # tests/functional/output_features/success_outline/success_outline.feature:3\n' ' I want to make scenario outlines work :) # tests/functional/output_features/success_outline/success_outline.feature:4\n' '\n' ' Scenario Outline: fill a web form # tests/functional/output_features/success_outline/success_outline.feature:6\n' ' Given I open browser at "http://www.my-website.com/" # tests/functional/output_features/success_outline/success_outline_steps.py:21\n' ' And click on "sign-up" # tests/functional/output_features/success_outline/success_outline_steps.py:25\n' ' When I fill the field "username" with "<username>" # tests/functional/output_features/success_outline/success_outline_steps.py:29\n' ' And I fill the field "password" with "<password>" # tests/functional/output_features/success_outline/success_outline_steps.py:29\n' ' And I fill the field "password-confirm" with "<password>" # tests/functional/output_features/success_outline/success_outline_steps.py:29\n' ' And I fill the field "email" with "<email>" # tests/functional/output_features/success_outline/success_outline_steps.py:29\n' ' And I click "done" # tests/functional/output_features/success_outline/success_outline_steps.py:33\n' ' Then I see the message "<message>" # tests/functional/output_features/success_outline/success_outline_steps.py:37\n' '\n' ' Examples:\n' ' | username | password | email | message |\n' ' | john | doe-1234 | [email protected] | Welcome, John |\n' ' | mary | wee-9876 | [email protected] | Welcome, Mary |\n' ' | foo | foo-bar | [email protected] | Welcome, Foo |\n' '\n' '1 feature (1 passed)\n' '3 scenarios (3 passed)\n' '24 steps (24 passed)\n' )
def test_output_with_success_colorless_many_features(): "Testing the output of many successful features" runner = Runner(join(abspath(dirname(__file__)), 'output_features', 'many_successful_features'), verbosity=3) runner.run() assert_stdout_lines( "\n" "Feature: First feature, of many # tests/functional/output_features/many_successful_features/one.feature:1\n" " In order to make lettuce more robust # tests/functional/output_features/many_successful_features/one.feature:2\n" " As a programmer # tests/functional/output_features/many_successful_features/one.feature:3\n" " I want to test its output on many features # tests/functional/output_features/many_successful_features/one.feature:4\n" "\n" " Scenario: Do nothing # tests/functional/output_features/many_successful_features/one.feature:6\n" " Given I do nothing # tests/functional/output_features/many_successful_features/dumb_steps.py:6\n" "\033[A Given I do nothing # tests/functional/output_features/many_successful_features/dumb_steps.py:6\n" " Then I see that the test passes # tests/functional/output_features/many_successful_features/dumb_steps.py:8\n" "\033[A Then I see that the test passes # tests/functional/output_features/many_successful_features/dumb_steps.py:8\n" "\n" "Feature: Second feature, of many # tests/functional/output_features/many_successful_features/two.feature:1\n" " I just want to see it green :) # tests/functional/output_features/many_successful_features/two.feature:2\n" "\n" " Scenario: Do nothing # tests/functional/output_features/many_successful_features/two.feature:4\n" " Given I do nothing # tests/functional/output_features/many_successful_features/dumb_steps.py:6\n" "\033[A Given I do nothing # tests/functional/output_features/many_successful_features/dumb_steps.py:6\n" " Then I see that the test passes # tests/functional/output_features/many_successful_features/dumb_steps.py:8\n" "\033[A Then I see that the test passes # tests/functional/output_features/many_successful_features/dumb_steps.py:8\n" "\n" "2 features (2 passed)\n" "2 scenarios (2 passed)\n" "4 steps (4 passed)\n" )
def run(self, verbosity, pattern, start_dir): """ Harvest all Lettuce features from the current application """ paths = self.get_path(start_dir, pattern) results = [] failed = False app_factory = self.app_factory @before.each_scenario def setup_scenario(feature): world.app = app_factory() world.client = world.app.test_client() @after.each_scenario def teardown_scenario(scenario): del world.client del world.app registry.call_hook('before', 'harvest', locals()) try: for path in paths: runner = Runner(path, verbosity=verbosity) result = runner.run() results.append(result) if not result or result.steps != result.steps_passed: failed = True except Exception, e: import traceback traceback.print_exc(e)
def test_output_outlines_success_colorless(): "Language: fr -> sucess outlines colorless" runner = Runner(join_path('fr', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_stdout_lines( '\n' 'Fonctionnalité: Plan de scénario en français # tests/functional/language_specific_features/fr/success/outlines.feature:4\n' ' En tant que programmeur # tests/functional/language_specific_features/fr/success/outlines.feature:5\n' ' Je veux tester les plans de scénario # tests/functional/language_specific_features/fr/success/outlines.feature:6\n' ' Et surtout les sorties # tests/functional/language_specific_features/fr/success/outlines.feature:7\n' '\n' ' Plan de Scénario: Faire la sieste # tests/functional/language_specific_features/fr/success/outlines.feature:9\n' ' Soit un après midi de <mois> # tests/functional/language_specific_features/fr/success/outlines_steps.py:13\n' ' Quand je veux faire la sieste # tests/functional/language_specific_features/fr/success/outlines_steps.py:22\n' ' Je peux aller <lieux> # tests/functional/language_specific_features/fr/success/outlines_steps.py:26\n' '\n' ' Exemples:\n' ' | mois | lieux |\n' ' | janvier | près de la cheminé |\n' ' | aôut | dans le transat |\n' ' | octobre | dans le canapé |\n' '\n' '1 feature (1 passed)\n' '3 scenarios (3 passed)\n' '9 steps (9 passed)\n' )
def test_output_outlines2_success_colorful(): "Language: fr -> sucess outlines colorful, alternate name" runner = Runner(join_path('fr', 'success', 'outlines2.feature'), verbosity=4) runner.run() assert_stdout_lines( '\n' '\033[1;37mFonctionnalité: Plan de scénario en français \033[1;30m# tests/functional/language_specific_features/fr/success/outlines2.feature:4\033[0m\n' '\033[1;37m En tant que programmeur \033[1;30m# tests/functional/language_specific_features/fr/success/outlines2.feature:5\033[0m\n' '\033[1;37m Je veux tester les plans de scénario \033[1;30m# tests/functional/language_specific_features/fr/success/outlines2.feature:6\033[0m\n' '\033[1;37m Et surtout les sorties \033[1;30m# tests/functional/language_specific_features/fr/success/outlines2.feature:7\033[0m\n' '\n' '\033[1;37m Plan de Scénario: Faire la sieste \033[1;30m# tests/functional/language_specific_features/fr/success/outlines2.feature:9\033[0m\n' '\033[0;36m Soit un après midi de <mois> \033[1;30m# tests/functional/language_specific_features/fr/success/outlines_steps.py:13\033[0m\n' '\033[0;36m Quand je veux faire la sieste \033[1;30m# tests/functional/language_specific_features/fr/success/outlines_steps.py:22\033[0m\n' '\033[0;36m Je peux aller <lieux> \033[1;30m# tests/functional/language_specific_features/fr/success/outlines_steps.py:26\033[0m\n' '\n' '\033[1;37m Exemples:\033[0m\n' '\033[0;36m \033[1;37m |\033[0;36m mois \033[1;37m |\033[0;36m lieux \033[1;37m |\033[0;36m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m janvier\033[1;37m |\033[1;32m près de la cheminé\033[1;37m |\033[1;32m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m aôut \033[1;37m |\033[1;32m dans le transat \033[1;37m |\033[1;32m\033[0m\n' '\033[1;32m \033[1;37m |\033[1;32m octobre\033[1;37m |\033[1;32m dans le canapé \033[1;37m |\033[1;32m\033[0m\n' '\n' '\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n' '\033[1;37m3 scenarios (\033[1;32m3 passed\033[1;37m)\033[0m\n' '\033[1;37m9 steps (\033[1;32m9 passed\033[1;37m)\033[0m\n' )
def test_output_snippets_with_groups_within_single_quotes_colorful(): "Testing that the proposed snippet is clever enough to identify groups within single quotes. colorful" runner = Runner(feature_name('single-quoted-snippet'), verbosity=4) runner.run() assert_stdout_lines( u'\n' u'\033[1;37mFeature: single-quoted snippet proposal \033[1;30m# tests/functional/output_features/single-quoted-snippet/single-quoted-snippet.feature:1\033[0m\n' u'\n' u'\033[1;37m Scenario: Propose matched groups \033[1;30m# tests/functional/output_features/single-quoted-snippet/single-quoted-snippet.feature:2\033[0m\n' u'\033[0;33m Given I have \'stuff here\' and \'more @#$%ˆ& bizar sutff h3r3\' \033[1;30m# tests/functional/output_features/single-quoted-snippet/single-quoted-snippet.feature:3\033[0m\n' u'\n' "\033[1;37m1 feature (\033[0;31m0 passed\033[1;37m)\033[0m\n" \ "\033[1;37m1 scenario (\033[0;31m0 passed\033[1;37m)\033[0m\n" \ "\033[1;37m1 step (\033[0;33m1 undefined\033[1;37m, \033[1;32m0 passed\033[1;37m)\033[0m\n" u'\n' u'\033[0;33mYou can implement step definitions for undefined steps with these snippets:\n' u'\n' u'from lettuce import step\n' u'\n' u'@step(r\'Given I have \\\'(.*)\\\' and \\\'(.*)\\\'\')\n' u'def given_i_have_group1_and_group2(step, group1, group2):\n' u' pass\033[0m\n' )
def test_output_outlines_success_colorless(): "Language: ja -> sucess outlines colorless" runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_stdout_lines( "\n" "フィーチャ: アウトラインを日本語で書く # tests/functional/language_specific_features/ja/success/outlines.feature:3\n" " 図表のテストをパスすること # tests/functional/language_specific_features/ja/success/outlines.feature:4\n" "\n" " シナリオアウトライン: 全てのテストで何もしない # tests/functional/language_specific_features/ja/success/outlines.feature:6\n" " 前提 入力値を <データ1> とし # tests/functional/language_specific_features/ja/success/outlines_steps.py:13\n" " もし 処理 <方法> を使って # tests/functional/language_specific_features/ja/success/outlines_steps.py:22\n" " ならば 表示は <結果> である # tests/functional/language_specific_features/ja/success/outlines_steps.py:31\n" "\n" " 例:\n" " | データ1 | 方法 | 結果 |\n" " | 何か | これ | 機能 |\n" " | その他 | ここ | 同じ |\n" " | データ | 動く | unicodeで! |\n" "\n" "1 feature (1 passed)\n" "3 scenarios (3 passed)\n" "9 steps (9 passed)\n" )
def test_output_snippets_with_groups_within_redundant_quotes(): "Testing that the proposed snippet is clever enough to avoid duplicating the same snippet" runner = Runner(feature_name('redundant-steps-quotes'), verbosity=3) runner.run() assert_stdout_lines( u'\n' u'Feature: avoid duplicating same snippet # tests/functional/output_features/redundant-steps-quotes/redundant-steps-quotes.feature:1\n' u'\n' u' Scenario: Propose matched groups # tests/functional/output_features/redundant-steps-quotes/redundant-steps-quotes.feature:2\n' u' Given I have "stuff here" and "more @#$%ˆ& bizar sutff h3r3" # tests/functional/output_features/redundant-steps-quotes/redundant-steps-quotes.feature:3 (undefined)\n' u' Given I have "blablabla" and "12345" # tests/functional/output_features/redundant-steps-quotes/redundant-steps-quotes.feature:4 (undefined)\n' u'\n' u'1 feature (0 passed)\n' u'1 scenario (0 passed)\n' u'2 steps (2 undefined, 0 passed)\n' u'\n' u'You can implement step definitions for undefined steps with these snippets:\n' u'\n' u'from lettuce import step\n' u'\n' u'@step(r\'Given I have "(.*)" and "(.*)"\')\n' u'def given_i_have_group1_and_group2(step, group1, group2):\n' u' pass\n' )
def test_output_outlines_success_colorful(): "Language: ru -> sucess outlines colorful" runner = Runner(join_path("ru", "success", "outlines.feature"), verbosity=4) runner.run() assert_stdout_lines( "\n" "\x1b[1;37m\u0424\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b: \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0432\u044b\u0432\u043e\u0434 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u043e\u0433\u043e \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines.feature:3\x1b[0m\n" "\x1b[1;37m \u041a\u0430\u043a \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines.feature:4\x1b[0m\n" "\x1b[1;37m \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u043e\u0431\u044b lettuce \u0431\u044b\u043b \u043d\u0430\u0434\u0435\u0436\u043d\u044b\u043c \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines.feature:5\x1b[0m\n" "\x1b[1;37m \u042f \u0445\u043e\u0447\u0443, \u0447\u0442\u043e \u0431\u044b \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u0438 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0430 \u0440\u0443\u0441\u0441\u043a\u043e\u043c \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines.feature:6\x1b[0m\n" "\n" "\x1b[1;37m \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044f: \u0417\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines.feature:8\x1b[0m\n" '\x1b[0;36m \u041f\u0443\u0441\u043a\u0430\u0439 \u044f \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u044e \u0432 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0435 "http://sona-studio.com/contacts/" \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines_steps.py:12\x1b[0m\n' '\x1b[0;36m \u041a\u043e\u0433\u0434\u0430 \u044f \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e \u0432 \u043f\u043e\u043b\u0435 "\u0418\u043c\u044f" "<\u0438\u043c\u044f>" \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines_steps.py:16\x1b[0m\n' '\x1b[0;36m \u0418 \u044f \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e \u0432 \u043f\u043e\u043b\u0435 "Email" "<email>" \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines_steps.py:24\x1b[0m\n' '\x1b[0;36m \u0418 \u044f \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u044e \u0432 \u043f\u043e\u043b\u0435 "\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435" "<\u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435>" \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines_steps.py:32\x1b[0m\n' '\x1b[0;36m \u0418 \u044f \u043d\u0430\u0436\u0438\u043c\u0430\u044e "\u041e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c" \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines_steps.py:40\x1b[0m\n' '\x1b[0;36m \u0422\u043e\u0433\u0434\u0430 \u044f \u043f\u043e\u043b\u0443\u0447\u0430\u044e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 "\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u0430\u0448\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435" \x1b[1;30m# tests/functional/language_specific_features/ru/success/outlines_steps.py:43\x1b[0m\n' "\n" "\x1b[1;37m \u041f\u0440\u0438\u043c\u0435\u0440\u044b:\x1b[0m\n" "\x1b[0;36m \x1b[1;37m |\x1b[0;36m \u0438\u043c\u044f \x1b[1;37m |\x1b[0;36m email \x1b[1;37m |\x1b[0;36m \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \x1b[1;37m |\x1b[0;36m\x1b[0m\n" "\x1b[1;32m \x1b[1;37m |\x1b[1;32m \u0412\u0438\u0442\u0430\u043b\u0438\u0439 \u0418\u0433\u043e\u0440\u0435\u0432\u0438\u0447\x1b[1;37m |\x1b[1;32m [email protected]\x1b[1;37m |\x1b[1;32m \u0415\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043d\u0443\u0436\u043d\u043e \u043e\u0431\u0441\u0443\u0434\u0438\u0442\u044c\x1b[1;37m |\x1b[1;32m\x1b[0m\n" "\x1b[1;32m \x1b[1;37m |\x1b[1;32m \u041c\u0430\u0440\u0438\u043d\u0430 \u0411\u0430\u043d\u0440\u0430\u0443\u043b \x1b[1;37m |\x1b[1;32m [email protected]\x1b[1;37m |\x1b[1;32m \u041c\u043d\u0435 \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f \u0432\u0430\u0448\u0438 \u0434\u0438\u0437\u0430\u0439\u043d\u044b, \u0445\u043e\u0447\u0443 \u0441\u0430\u0439\u0442 \x1b[1;37m |\x1b[1;32m\x1b[0m\n" "\n" "\x1b[1;37m1 feature (\x1b[1;32m1 passed\x1b[1;37m)\x1b[0m\n" "\x1b[1;37m2 scenarios (\x1b[1;32m2 passed\x1b[1;37m)\x1b[0m\n" "\x1b[1;37m12 steps (\x1b[1;32m12 passed\x1b[1;37m)\x1b[0m\n" )
def test_output_with_success_colorless(): """Language: ru -> success colorless""" with capture_output() as (out, err): runner = Runner(join_path("ru", "success", "dumb.feature"), verbosity=3) runner.run() assert_equals( out.getvalue(), u"\n" u"Функционал: тупая фича # tests/functional/language_specific_features/ru/success/dumb.feature:3\n" u" Чтобы lettuce был более надежным # tests/functional/language_specific_features/ru/success/dumb.feature:4\n" u" Как программист # tests/functional/language_specific_features/ru/success/dumb.feature:5\n" u" Я хочу что бы тест был зеленый # tests/functional/language_specific_features/ru/success/dumb.feature:6\n" u"\n" u" #1\n" u" Сценарий: Ничего не делать # tests/functional/language_specific_features/ru/success/dumb.feature:8\n" u" Когда Пуская я ничего не делаю # tests/functional/language_specific_features/ru/success/dumb_steps.py:6\n" u" Тогда я вижу что тест выполняется # tests/functional/language_specific_features/ru/success/dumb_steps.py:10\n" u"\n" u" ----------------------------------------------------------------------------\n" u"\n" u"1 feature (1 passed)\n" u"1 scenario (1 passed)\n" u"2 steps (2 passed)\n", )
def test_output_with_success_colorless(): """ Language: fr -> success colorless """ with capture_output() as (out, err): runner = Runner(join_path('fr', 'success', 'dumb.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u""" Fonctionnalité: Test complet # tests/functional/language_specific_features/fr/success/dumb.feature:3 En tant que programmeur # tests/functional/language_specific_features/fr/success/dumb.feature:4 Je veux valider les tests # tests/functional/language_specific_features/fr/success/dumb.feature:5 #1 Scénario: On ne fait rien # tests/functional/language_specific_features/fr/success/dumb.feature:7 Quand je ne fait rien # tests/functional/language_specific_features/fr/success/dumb_steps.py:6 ---------------------------------------------------------------------------- 1 feature (1 passed) 1 scenario (1 passed) 1 step (1 passed) """)
def test_output_of_table_with_success_colorless(): """Language: ru -> success table colorless""" with capture_output() as (out, err): runner = Runner(join_path("ru", "success", "table.feature"), verbosity=3) runner.run() assert_equals( out.getvalue(), u"\n" u"Функционал: фича с табличкой # tests/functional/language_specific_features/ru/success/table.feature:3\n" u" Для того, что бы lettuce был надежным # tests/functional/language_specific_features/ru/success/table.feature:4\n" u" Как программист # tests/functional/language_specific_features/ru/success/table.feature:5\n" u" Я хочу, что бы тесты с таблицами работали отлично и на русском # tests/functional/language_specific_features/ru/success/table.feature:6\n" u"\n" u" #1\n" u" Сценарий: Проверить таблички # tests/functional/language_specific_features/ru/success/table.feature:8\n" u" Когда Пускай имеем таблицу пациентов: # tests/functional/language_specific_features/ru/success/table_steps.py:5\n" u" | ФИО | Диагноз |\n" u" | Петров ПП | диарея |\n" u" | Сидоров НА | хронический снобизм |\n" u"\n" u" ----------------------------------------------------------------------------\n" u"\n" u"1 feature (1 passed)\n" u"1 scenario (1 passed)\n" u"1 step (1 passed)\n", )
def test_xunit_output_with_one_error(): 'Test xunit output with one errors' called = [] def assert_correct_xml(filename, content): called.append(True) assert_xsd_valid(filename, content) root = etree.fromstring(content) assert_equals(root.get("tests"), "2") assert_equals(root.get("failures"), "1") assert_equals(len(root.getchildren()), 2) passed, failed = root.findall("testcase") assert_equals(passed.get("name"), "Given my step that passes") assert_true(float(passed.get("time")) > 0) assert_equals(failed.get("name"), "Given my step that blows a exception") assert_true(float(failed.get("time")) > 0) assert_true(failed.find("failure") is not None) old = xunit_output.wrt_output xunit_output.wrt_output = assert_correct_xml runner = Runner(feature_name('error_traceback'), enable_xunit=True) runner.run() assert_equals(1, len(called), "Function not called") xunit_output.wrt_output = old
def test_output_outlines_success_colorless(): """Language: ru -> success outlines colorless""" with capture_output() as (out, err): runner = Runner(join_path("ru", "success", "outlines.feature"), verbosity=3) runner.run() raise SkipTest("broken") assert_equals( out.getvalue(), u""" Функционал: Проверить вывод структурного сценария # tests/functional/language_specific_features/ru/success/outlines.feature:3 Как программист # tests/functional/language_specific_features/ru/success/outlines.feature:4 Для того чобы lettuce был надежным # tests/functional/language_specific_features/ru/success/outlines.feature:5 Я хочу, что бы сценарии со структурой работали на русском # tests/functional/language_specific_features/ru/success/outlines.feature:6 Структура сценария: Заполнить форму # tests/functional/language_specific_features/ru/success/outlines.feature:8 Пускай я открываю в браузере "http://sona-studio.com/contacts/" # tests/functional/language_specific_features/ru/success/outlines_steps.py:12 Когда я заполняю в поле "Имя" "<имя>" # tests/functional/language_specific_features/ru/success/outlines_steps.py:16 И я заполняю в поле "Email" "<email>" # tests/functional/language_specific_features/ru/success/outlines_steps.py:24 И я заполняю в поле "Сообщение" "<сообщение>" # tests/functional/language_specific_features/ru/success/outlines_steps.py:32 И я нажимаю "Отправить" # tests/functional/language_specific_features/ru/success/outlines_steps.py:40 Тогда я получаю сообщение "Спасибо за ваше сообщение" # tests/functional/language_specific_features/ru/success/outlines_steps.py:43 Примеры: | имя | email | сообщение | | Виталий Игоревич | [email protected] | Есть интересный проект, нужно обсудить | | Марина Банраул | [email protected] | Мне нравятся ваши дизайны, хочу сайт | 1 feature (1 passed) 2 scenarios (2 passed) 12 steps (12 passed) """, )
def test_output_outlines_success_colorful(): "Language: zh-CN -> sucess outlines colorful" runner = Runner(join_path('zh-CN', 'success', 'outlines.feature'), verbosity=4) runner.run() assert_stdout_lines( '\n' "\033[1;37m特性: 中文场景模板 \033[1;30m# tests/functional/language_specific_features/zh-CN/success/outlines.feature:3\033[0m\n" "\033[1;37m 中文场景模板图表测试 \033[1;30m# tests/functional/language_specific_features/zh-CN/success/outlines.feature:4\033[0m\n" '\n' "\033[1;37m 场景模板: 用表格描述场景 \033[1;30m# tests/functional/language_specific_features/zh-CN/success/outlines.feature:6\033[0m\n" "\033[0;36m 如果 输入是<输入> \033[1;30m# tests/functional/language_specific_features/zh-CN/success/outlines_steps.py:13\033[0m\n" "\033[0;36m 当 执行<处理>时 \033[1;30m# tests/functional/language_specific_features/zh-CN/success/outlines_steps.py:22\033[0m\n" "\033[0;36m 那么 得到<结果> \033[1;30m# tests/functional/language_specific_features/zh-CN/success/outlines_steps.py:31\033[0m\n" '\n' "\033[1;37m 例如:\033[0m\n" "\033[0;36m \033[1;37m |\033[0;36m 输入\033[1;37m |\033[0;36m 处理\033[1;37m |\033[0;36m 结果 \033[1;37m |\033[0;36m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 什么\033[1;37m |\033[1;32m 这个\033[1;37m |\033[1;32m 功能 \033[1;37m |\033[1;32m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 其他\033[1;37m |\033[1;32m 这里\033[1;37m |\033[1;32m 一样 \033[1;37m |\033[1;32m\033[0m\n" "\033[1;32m \033[1;37m |\033[1;32m 数据\033[1;37m |\033[1;32m 动作\033[1;37m |\033[1;32m unicode输出!\033[1;37m |\033[1;32m\033[0m\n" '\n' "\033[1;37m1 feature (\033[1;32m1 passed\033[1;37m)\033[0m\n" "\033[1;37m3 scenarios (\033[1;32m3 passed\033[1;37m)\033[0m\n" "\033[1;37m9 steps (\033[1;32m9 passed\033[1;37m)\033[0m\n" )
def test_after_each_all_is_executed_before_each_all(): "terrain.before.each_all and terrain.after.each_all decorators" world.all_steps = [] @before.all def set_state_to_before(): world.all_steps.append('before') @step('append 1 in world all steps') def append_1_in_world_all_steps(step): world.all_steps.append("1") @step('append 2 more') def append_2_more(step): world.all_steps.append("2") @step('append 3 in world all steps') def append_during_to_all_steps(step): world.all_steps.append("3") @after.all def set_state_to_after(total): world.all_steps.append('after') runner = Runner(join(abspath(dirname(__file__)), 'simple_features', '2nd_feature_dir')) runner.run() assert_equals( world.all_steps, ['before', '1', '2', '3', 'after'] )
def test_output_outlines_success_colorless(): "Language: pt-br -> sucess outlines colorless" runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_stdout_lines( u'\n' u'Funcionalidade: outlines em português # tests/functional/language_specific_features/pt-br/success/outlines.feature:3\n' u' Como um programador # tests/functional/language_specific_features/pt-br/success/outlines.feature:4\n' u' Eu quero testar cenários esquemáticos # tests/functional/language_specific_features/pt-br/success/outlines.feature:5\n' u' Para ver o output em pt-br # tests/functional/language_specific_features/pt-br/success/outlines.feature:6\n' u'\n' u' Esquema do Cenário: Fazer nada, repetidas vezes, através de esquemas # tests/functional/language_specific_features/pt-br/success/outlines.feature:8\n' u' Dado que tenho o <dado1> # tests/functional/language_specific_features/pt-br/success/outlines_steps.py:13\n' u' Quando eu faço algo com <isso> # tests/functional/language_specific_features/pt-br/success/outlines_steps.py:22\n' u' Então eu fico feliz em ver <aquilo> # tests/functional/language_specific_features/pt-br/success/outlines_steps.py:31\n' u'\n' u' Exemplos:\n' u' | dado1 | isso | aquilo |\n' u' | algo | assim | funcional |\n' u' | outro | aqui | também |\n' u' | dados | funcionarão | com unicode ! |\n' u'\n' u'1 feature (1 passed)\n' u'3 scenarios (3 passed)\n' u'9 steps (9 passed)\n' )
def test_output_outlines_success_colorless(): "Language: ru -> sucess outlines colorless" runner = Runner(join_path("ru", "success", "outlines.feature"), verbosity=3) runner.run() assert_stdout_lines( "\n" "Функционал: Проверить вывод структурного сценария # tests/functional/language_specific_features/ru/success/outlines.feature:3\n" " Как программист # tests/functional/language_specific_features/ru/success/outlines.feature:4\n" " Для того чобы lettuce был надежным # tests/functional/language_specific_features/ru/success/outlines.feature:5\n" " Я хочу, что бы сценарии со структурой работали на русском # tests/functional/language_specific_features/ru/success/outlines.feature:6\n" "\n" " Структура сценария: Заполнить форму # tests/functional/language_specific_features/ru/success/outlines.feature:8\n" ' Пускай я открываю в браузере "http://sona-studio.com/contacts/" # tests/functional/language_specific_features/ru/success/outlines_steps.py:12\n' ' Когда я заполняю в поле "Имя" "<имя>" # tests/functional/language_specific_features/ru/success/outlines_steps.py:16\n' ' И я заполняю в поле "Email" "<email>" # tests/functional/language_specific_features/ru/success/outlines_steps.py:24\n' ' И я заполняю в поле "Сообщение" "<сообщение>" # tests/functional/language_specific_features/ru/success/outlines_steps.py:32\n' ' И я нажимаю "Отправить" # tests/functional/language_specific_features/ru/success/outlines_steps.py:40\n' ' Тогда я получаю сообщение "Спасибо за ваше сообщение" # tests/functional/language_specific_features/ru/success/outlines_steps.py:43\n' "\n" " Примеры:\n" " | имя | email | сообщение |\n" " | Виталий Игоревич | [email protected] | Есть интересный проект, нужно обсудить |\n" " | Марина Банраул | [email protected] | Мне нравятся ваши дизайны, хочу сайт |\n" "\n" "1 feature (1 passed)\n" "2 scenarios (2 passed)\n" "12 steps (12 passed)\n" )
def run_feature(feature, feature_will_fail, failfast, after_each_feature_count, after_each_scenario_count, after_each_step_count, after_outline_count): mock = get_after_hook_mock() define_hooks(mock) runner = Runner(feature_name(feature), failfast=failfast) if feature_will_fail: try: runner.run() except: pass else: runner.run() assert_equals(mock.after_each_feature.call_count, after_each_feature_count) assert_equals(mock.after_each_scenario.call_count, after_each_scenario_count) assert_equals(mock.after_each_step.call_count, after_each_step_count) assert_equals(mock.after_outline.call_count, after_outline_count)
def test_simple_tables_behave_as_feature(): "Basic step.behave_as behaviour is working" Runner(path_to_feature('2nd_table_steps'), verbosity=3, no_color=True).run() assert_stdout_lines( "\n" "Feature: Multiplication # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:2\n" " In order to avoid silly mistakes # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:3\n" " Cashiers must be able to multiplicate numbers :) # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:4\n" "\n" " Scenario: Regular numbers # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:6\n" " Given I multiply these numbers: # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:31\n" " | number |\n" " | 55 |\n" " | 2 |\n" " Then the result should be 110 on the screen # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:19\n" "\n" " Scenario: Shorter version of the scenario above # tests/functional/behave_as_features/2nd_table_steps/2nd_table_steps.feature:13\n" " Given I multiply 55 and 2 into the calculator # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:23\n" " Then the result should be 110 on the screen # tests/functional/behave_as_features/2nd_table_steps/simple_tables_step_definitions.py:19\n" "\n" "1 feature (1 passed)\n" "2 scenarios (2 passed)\n" "4 steps (4 passed)\n")
def test_jsonreport_output_with_no_errors(): 'Test jsonreport output with no errors' with check_jsonreport('commented_feature'): runner = Runner(feature_name('commented_feature'), enable_jsonreport=True) runner.run()
def test_jsonreport_output_with_unicode_and_bytestring(): 'Test jsonreport output with unicode and bytestring' with check_jsonreport('xunit_unicode_and_bytestring_mixing'): runner = Runner(feature_name('xunit_unicode_and_bytestring_mixing'), enable_jsonreport=True) runner.run()
def handle(self, *args, **options): setup_test_environment() settings.DEBUG = options.get('debug', False) settings.LETTUCE_BROWSER = options.get('browser', 'chrome') settings.LETTUCE_FAILED_STEP_SLEEP = options.get('failed_step_sleep') settings.DEFAULT_TABLESPACE = options.get('tablespace') settings.DISABLE_JSCOMPILE = options.get('disable_jscompile') settings.LETTUCE_BY_STEP = options.get('by_step', False) settings.LETTUCE_HEADLESS = options.get('headless', False) verbosity = int(options.get('verbosity', 3)) no_color = int(options.get('no_color', False)) apps_to_run = tuple(options.get('apps', '').split(",")) apps_to_avoid = tuple(options.get('avoid_apps', '').split(",")) run_server = not options.get('no_server', False) test_database = options.get('test_database', False) smtp_queue = options.get('smtp_queue', False) tags = options.get('tags', None) failfast = options.get('failfast', False) auto_pdb = options.get('auto_pdb', False) threading = options.get('use_threading', True) with_summary = options.get('summary_display', False) if test_database: migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True) try: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() except: migrate_south = False pass from django.test.utils import get_runner self._testrunner = get_runner(settings)(interactive=False) self._testrunner.setup_test_environment() self._old_db_config = self._testrunner.setup_databases() call_command( 'syncdb', verbosity=0, interactive=False, ) if migrate_south: call_command( 'migrate', verbosity=0, interactive=False, ) paths = self.get_paths(args, apps_to_run, apps_to_avoid) if not paths: paths = options.get('paths', []) server = get_server(port=options['port'], threading=threading) os.environ['REMOTE_HOST'] = options['host'] if run_server: try: server.start() except LettuceServerException as e: raise SystemExit(e) os.environ['SERVER_NAME'] = str(server.address) os.environ['SERVER_PORT'] = str(server.port) failed = False registry.call_hook('before', 'harvest', locals()) results = [] try: for path in paths: app_module = None if isinstance(path, tuple) and len(path) is 2: path, app_module = path if app_module is not None: registry.call_hook('before_each', 'app', app_module) runner = Runner(path, options.get('scenarios'), verbosity, no_color, enable_xunit=options.get('enable_xunit'), enable_subunit=options.get('enable_subunit'), xunit_filename=options.get('xunit_file'), subunit_filename=options.get('subunit_file'), tags=tags, failfast=failfast, auto_pdb=auto_pdb, smtp_queue=smtp_queue) result = runner.run() if app_module is not None: registry.call_hook('after_each', 'app', app_module, result) results.append(result) if not result or result.steps != result.steps_passed: failed = True except SystemExit as e: failed = e.code except Exception as e: failed = True import traceback traceback.print_exc(0) finally: summary = SummaryTotalResults(results) summary.summarize_all() registry.call_hook('after', 'harvest', summary) if test_database: self._testrunner.teardown_databases(self._old_db_config) teardown_test_environment() server.stop(failed) raise SystemExit(int(failed))
def run(self): try: return Runner(**self.run_args).run() except BaseException: print "Lettuce raised the following exception:" raise
def test_jsonreport_output_with_one_error(): 'Test jsonreport output with one errors' with check_jsonreport('error_traceback'): runner = Runner(feature_name('error_traceback'), enable_jsonreport=True) runner.run()
def test_xunit_does_not_throw_exception_when_missing_step_definition(): with check_jsonreport('missing_steps'): runner = Runner(feature_name('missing_steps'), enable_jsonreport=True) runner.run()
class Command(BaseCommand): help = u'Run lettuce tests all along installed apps' args = '[PATH to feature file or folder]' requires_model_validation = False option_list = ( make_option( '-a', '--apps', action='store', dest='apps', default='', help= 'Run ONLY the django apps that are listed here. Comma separated'), make_option( '-A', '--avoid-apps', action='store', dest='avoid_apps', default='', help= 'AVOID running the django apps that are listed here. Comma separated' ), make_option('-S', '--no-server', action='store_true', dest='no_server', default=False, help="will not run django's builtin HTTP server"), make_option('--nothreading', action='store_false', dest='use_threading', default=True, help='Tells Django to NOT use threading.'), make_option( '-T', '--test-server', action='store_true', dest='test_database', default=getattr(settings, "LETTUCE_USE_TEST_DATABASE", False), help= "will run django's builtin HTTP server using the test databases"), make_option('-P', '--port', type='int', dest='port', help="the port in which the HTTP server will run at"), make_option( '-d', '--debug-mode', action='store_true', dest='debug', default=False, help= "when put together with builtin HTTP server, forces django to run with settings.DEBUG=True" ), make_option('-s', '--scenarios', action='store', dest='scenarios', default=None, help='Comma separated list of scenarios to run'), make_option("-t", "--tag", dest="tags", type="str", action='append', default=None, help='Tells lettuce to run the specified tags only; ' 'can be used multiple times to define more tags' '(prefixing tags with "-" will exclude them and ' 'prefixing with "~" will match approximate words)'), make_option('--with-xunit', action='store_true', dest='enable_xunit', default=False, help='Output JUnit XML test results to a file'), make_option( '--smtp-queue', action='store_true', dest='smtp_queue', default=False, help='Use smtp for mail queue (usefull with --no-server option'), make_option( '--xunit-file', action='store', dest='xunit_file', default=None, help='Write JUnit XML to this file. Defaults to lettucetests.xml'), make_option('--with-subunit', action='store_true', dest='enable_subunit', default=False, help='Output Subunit test results to a file'), make_option( '--subunit-file', action='store', dest='subunit_file', default=None, help='Write Subunit to this file. Defaults to subunit.bin'), make_option("--failfast", dest="failfast", default=False, action="store_true", help='Stop running in the first failure'), make_option("--pdb", dest="auto_pdb", default=False, action="store_true", help='Launches an interactive debugger upon error'), ) def stopserver(self, failed=False): raise SystemExit(int(failed)) def get_paths(self, args, apps_to_run, apps_to_avoid): if args: for path, exists in zip(args, map(os.path.exists, args)): if not exists: sys.stderr.write( "You passed the path '%s', but it does not exist.\n" % path) sys.exit(1) else: paths = args else: paths = harvest_lettuces( apps_to_run, apps_to_avoid) # list of tuples with (path, app_module) return paths def handle(self, *args, **options): setup_test_environment() verbosity = int(options.get('verbosity', 4)) apps_to_run = tuple(options.get('apps', '').split(",")) apps_to_avoid = tuple(options.get('avoid_apps', '').split(",")) run_server = not options.get('no_server', False) test_database = options.get('test_database', False) smtp_queue = options.get('smtp_queue', False) tags = options.get('tags', None) failfast = options.get('failfast', False) auto_pdb = options.get('auto_pdb', False) threading = options.get('use_threading', True) with_summary = options.get('summary_display', False) if test_database: migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True) try: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() except: migrate_south = False pass from django.test.utils import get_runner self._testrunner = get_runner(settings)(interactive=False) self._testrunner.setup_test_environment() self._old_db_config = self._testrunner.setup_databases() call_command( 'syncdb', verbosity=0, interactive=False, ) if migrate_south: call_command( 'migrate', verbosity=0, interactive=False, ) settings.DEBUG = options.get('debug', False) paths = self.get_paths(args, apps_to_run, apps_to_avoid) server = get_server(port=options['port'], threading=threading) if run_server: try: server.start() except LettuceServerException, e: raise SystemExit(e) os.environ['SERVER_NAME'] = str(server.address) os.environ['SERVER_PORT'] = str(server.port) failed = False registry.call_hook('before', 'harvest', locals()) results = [] try: for path in paths: app_module = None if isinstance(path, tuple) and len(path) is 2: path, app_module = path if app_module is not None: registry.call_hook('before_each', 'app', app_module) runner = Runner(path, options.get('scenarios'), verbosity, enable_xunit=options.get('enable_xunit'), enable_subunit=options.get('enable_subunit'), xunit_filename=options.get('xunit_file'), subunit_filename=options.get('subunit_file'), tags=tags, failfast=failfast, auto_pdb=auto_pdb, smtp_queue=smtp_queue) result = runner.run() if app_module is not None: registry.call_hook('after_each', 'app', app_module, result) results.append(result) if not result or result.steps != result.steps_passed: failed = True except SystemExit, e: failed = e.code
def test_background_colorless_output(): 'Test Background color output' runner = Runner(feature_name('background_feature'), verbosity=3) runner.run() assert_equals(sys.stdout.getvalue(), OUTPUT1)
def handle(self, *args, **options): setup_test_environment() verbosity = options['verbosity'] no_color = options.get('no_color', False) apps_to_run = tuple(options['apps'].split(",")) apps_to_avoid = tuple(options['avoid_apps'].split(",")) run_server = not options['no_server'] test_database = options['test_database'] smtp_queue = options['smtp_queue'] tags = options['tags'] failfast = options['failfast'] auto_pdb = options['auto_pdb'] threading = options['use_threading'] if test_database: migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True) try: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() except: migrate_south = False pass from django.test.utils import get_runner self._testrunner = get_runner(settings)(interactive=False) if DJANGO_VERSION > StrictVersion('1.10'): self._testrunner.teardown_test_environment() self._testrunner.setup_test_environment() self._old_db_config = self._testrunner.setup_databases() if DJANGO_VERSION < StrictVersion('1.7'): call_command( 'syncdb', verbosity=0, interactive=False, ) if migrate_south: call_command( 'migrate', verbosity=0, interactive=False, ) else: call_command( 'migrate', verbosity=0, interactive=False, ) settings.DEBUG = options.get('debug', False) paths = self.get_paths(args, apps_to_run, apps_to_avoid) server = get_server(port=options['port'], threading=threading) if run_server: try: server.start() except LettuceServerException as e: raise CommandError("Couldn't start Django server: %s" % e) os.environ['SERVER_NAME'] = str(server.address) os.environ['SERVER_PORT'] = str(server.port) failed = False registry.call_hook('before', 'harvest', locals()) results = [] try: for path in paths: app_module = None if isinstance(path, tuple) and len(path) is 2: path, app_module = path if app_module is not None: registry.call_hook('before_each', 'app', app_module) runner = Runner( path, options.get('scenarios'), verbosity, no_color, enable_xunit=options.get('enable_xunit'), enable_subunit=options.get('enable_subunit'), enable_jsonreport=options.get('enable_jsonreport'), xunit_filename=options.get('xunit_file'), subunit_filename=options.get('subunit_file'), jsonreport_filename=options.get('jsonreport_file'), tags=tags, failfast=failfast, auto_pdb=auto_pdb, root_dir=path, smtp_queue=smtp_queue) result = runner.run() if app_module is not None: registry.call_hook('after_each', 'app', app_module, result) results.append(result) if not result or result.steps != result.steps_passed: failed = True except LettuceRunnerError: failed = True except Exception as e: failed = True traceback.print_exc(e) finally: summary = SummaryTotalResults(results) summary.summarize_all() registry.call_hook('after', 'harvest', summary) if test_database: self._testrunner.teardown_databases(self._old_db_config) teardown_test_environment() server.stop(failed) if failed: raise CommandError("Lettuce tests failed.")
class Command(BaseCommand): help = u'Run lettuce tests all along installed apps' args = '[PATH to feature file or folder]' requires_model_validation = False option_list = BaseCommand.option_list[1:] + ( make_option('-v', '--verbosity', action='store', dest='verbosity', default='4', type='choice', choices=map(str, range(5)), help='Verbosity level; 0=no output, 1=only dots, 2=only scenario names, 3=colorless output, 4=normal output (colorful)'), make_option('-a', '--apps', action='store', dest='apps', default='', help='Run ONLY the django apps that are listed here. Comma separated'), make_option('-A', '--avoid-apps', action='store', dest='avoid_apps', default='', help='AVOID running the django apps that are listed here. Comma separated'), make_option('-S', '--no-server', action='store_true', dest='no_server', default=False, help="will not run django's builtin HTTP server"), make_option('-P', '--port', type='int', dest='port', help="the port in which the HTTP server will run at"), make_option('-d', '--debug-mode', action='store_true', dest='debug', default=False, help="when put together with builtin HTTP server, forces django to run with settings.DEBUG=True"), make_option('-s', '--scenarios', action='store', dest='scenarios', default=None, help='Comma separated list of scenarios to run'), make_option("-t", "--tag", dest="tags", type="str", action='append', default=None, help='Tells lettuce to run the specified tags only; ' 'can be used multiple times to define more tags' '(prefixing tags with "-" will exclude them and ' 'prefixing with "~" will match approximate words)'), make_option('--with-xunit', action='store_true', dest='enable_xunit', default=False, help='Output JUnit XML test results to a file'), make_option('--xunit-file', action='store', dest='xunit_file', default=None, help='Write JUnit XML to this file. Defaults to lettucetests.xml'), ) def stopserver(self, failed=False): raise SystemExit(int(failed)) def get_paths(self, args, apps_to_run, apps_to_avoid): if args: for path, exists in zip(args, map(os.path.exists, args)): if not exists: sys.stderr.write("You passed the path '%s', but it does not exist.\n" % path) sys.exit(1) else: paths = args else: paths = harvest_lettuces(apps_to_run, apps_to_avoid) # list of tuples with (path, app_module) return paths def handle(self, *args, **options): setup_test_environment() settings.DEBUG = options.get('debug', False) verbosity = int(options.get('verbosity', 4)) apps_to_run = tuple(options.get('apps', '').split(",")) apps_to_avoid = tuple(options.get('avoid_apps', '').split(",")) run_server = not options.get('no_server', False) tags = options.get('tags', None) server = Server(port=options['port']) paths = self.get_paths(args, apps_to_run, apps_to_avoid) if run_server: try: server.start() except LettuceServerException, e: raise SystemExit(e) os.environ['SERVER_NAME'] = server.address os.environ['SERVER_PORT'] = str(server.port) failed = False registry.call_hook('before', 'harvest', locals()) results = [] try: for path in paths: app_module = None if isinstance(path, tuple) and len(path) is 2: path, app_module = path if app_module is not None: registry.call_hook('before_each', 'app', app_module) runner = Runner(path, options.get('scenarios'), verbosity, enable_xunit=options.get('enable_xunit'), xunit_filename=options.get('xunit_file'), tags=tags) result = runner.run() if app_module is not None: registry.call_hook('after_each', 'app', app_module, result) results.append(result) if not result or result.steps != result.steps_passed: failed = True except SystemExit, e: failed = e.code
def test_jsonreport_output_with_unicode_characters_in_error_messages(): with check_jsonreport('unicode_traceback'): runner = Runner(feature_name('unicode_traceback'), enable_jsonreport=True) runner.run()
def test_discard_invalid_filenames(): "If a module has a invalid file name, we just discard it" runner = Runner(join(abspath(dirname(__file__)), 'invalid_module_name'), verbosity=0) runner.run()
def test_jsonreport_output_with_no_steps(): 'Test jsonreport output with no steps' with check_jsonreport('missing_steps'): runner = Runner(feature_name('missing_steps'), enable_jsonreport=True) runner.run()
def handle(self, *args, **options): setup_test_environment() verbosity = int(options.get('verbosity', 3)) no_color = int(options.get('no_color', False)) apps_to_run = tuple(options.get('apps', '').split(",")) apps_to_avoid = tuple(options.get('avoid_apps', '').split(",")) run_server = not options.get('no_server', False) test_database = options.get('test_database', False) smtp_queue = options.get('smtp_queue', False) tags = options.get('tags', None) failfast = options.get('failfast', False) auto_pdb = options.get('auto_pdb', False) threading = options.get('use_threading', True) with_summary = options.get('summary_display', False) processes = int(options.get('processes', 1)) if test_database: migrate_south = getattr(settings, "SOUTH_TESTS_MIGRATE", True) try: from south.management.commands import patch_for_test_db_setup patch_for_test_db_setup() except: migrate_south = False pass from django.test.utils import get_runner self._testrunner = get_runner(settings)(interactive=False) self._testrunner.setup_test_environment() self._old_db_config = self._testrunner.setup_databases() if StrictVersion(django.get_version()) < StrictVersion('1.7'): call_command( 'syncdb', verbosity=0, interactive=False, ) if migrate_south: call_command( 'migrate', verbosity=0, interactive=False, ) else: call_command( 'migrate', verbosity=0, interactive=False, ) settings.DEBUG = options.get('debug', False) paths = self.get_paths(args, apps_to_run, apps_to_avoid) server = get_server(port=options['port'], threading=threading) if run_server: try: server.start() except LettuceServerException as e: raise SystemExit(e) os.environ['SERVER_NAME'] = str(server.address) os.environ['SERVER_PORT'] = str(server.port) failed = False registry.call_hook('before', 'harvest', locals()) results = [] try: for path in paths: app_module = None if isinstance(path, tuple) and len(path) is 2: path, app_module = path if app_module is not None: registry.call_hook('before_each', 'app', app_module) if processes > 1: runner = ParallelRunner( path, options.get('scenarios'), verbosity, no_color, enable_xunit=options.get('enable_xunit'), enable_subunit=options.get('enable_subunit'), xunit_filename=options.get('xunit_file'), subunit_filename=options.get('subunit_file'), failfast=failfast, auto_pdb=auto_pdb, tags=tags, workers=processes) else: runner = Runner( path, options.get('scenarios'), verbosity, no_color, enable_xunit=options.get('enable_xunit'), enable_subunit=options.get('enable_subunit'), xunit_filename=options.get('xunit_file'), subunit_filename=options.get('subunit_file'), tags=tags, failfast=failfast, auto_pdb=auto_pdb, smtp_queue=smtp_queue) result = runner.run() if app_module is not None: registry.call_hook('after_each', 'app', app_module, result) results.append(result) if not result or result.steps != result.steps_passed: failed = True except SystemExit as e: failed = e.code except Exception as e: failed = True import traceback traceback.print_exc(e) finally: registry.call_hook('after', 'harvest', results) if test_database: self._testrunner.teardown_databases(self._old_db_config) teardown_test_environment() server.stop(failed) raise SystemExit(int(failed))
def test_flaky(): """Test basic flaky functionality""" runner = Runner(join(abspath(dirname(__file__)), 'flaky_features', 'flaky_test'), verbosity=3) runner.run() assert_stdout_lines_with_traceback( ("\n" "Feature: Test a feature with non-parametrized flaky tag # tests/functional/flaky_features/flaky_test/flaky.feature:2\n" "\n" " @flaky\n" " Scenario: This scenario always Fail # tests/functional/flaky_features/flaky_test/flaky.feature:4\n" " Given this test step fail # tests/functional/flaky_features/flaky_test/flaky.py:14\n" " Traceback (most recent call last):\n" ' File "%(lettuce_core_file)s", line %(call_line)d, in __call__\n' " ret = self.function(self.step, *args, **kw)\n" ' File "%(step_file)s", line 15, in this_step\n' " assert step_actions[action]\n" " AssertionError\n" " Given this test step fail # tests/functional/flaky_features/flaky_test/flaky.py:14\n" " Traceback (most recent call last):\n" ' File "%(lettuce_core_file)s", line %(call_line)d, in __call__\n' " ret = self.function(self.step, *args, **kw)\n" ' File "%(step_file)s", line 15, in this_step\n' " assert step_actions[action]\n" " AssertionError\n" "\n" " @flaky(3,2) @flaky\n" " Scenario: This scenario always Pass# tests/functional/flaky_features/flaky_test/flaky.feature:8\n" " Given this test step pass # tests/functional/flaky_features/flaky_test/flaky.py:14\n" " Given this test step pass # tests/functional/flaky_features/flaky_test/flaky.py:14\n" "\n" " @flaky\n" " Scenario: This scenario Passes on second run # tests/functional/flaky_features/flaky_test/flaky.feature:11\n" " Given execute the steps # tests/functional/flaky_features/flaky_test/flaky.py:19\n" " Traceback (most recent call last):\n" ' File "%(lettuce_core_file)s", line %(call_line)d, in __call__\n' " ret = self.function(self.step, *args, **kw)\n" ' File "%(step_file)s", line 25, in conditional_step\n' " assert False\n" " AssertionError\n" " Given execute the steps # tests/functional/flaky_features/flaky_test/flaky.py:19\n" " Traceback (most recent call last):\n" ' File "%(lettuce_core_file)s", line %(call_line)d, in __call__\n' " ret = self.function(self.step, *args, **kw)\n" ' File "%(step_file)s", line 25, in conditional_step\n' " assert False\n" " AssertionError\n" "\n" " @flaky(3,2) @flaky\n" " Scenario Outline: Factorials [0-4]# tests/functional/flaky_features/flaky_test/flaky.feature:15\n" " Given I have the number <number> # tests/functional/flaky_features/flaky_test/flaky.py:29\n" " When I compute its factorial # tests/functional/flaky_features/flaky_test/flaky.py:34\n" " Then I see the number <result> # tests/functional/flaky_features/flaky_test/flaky.py:39\n" "\n" " Examples:\n" " | number | result |\n" " | 0 | 1 |\n" " Given I have the number <number> # tests/functional/flaky_features/flaky_test/flaky.py:29\n" " When I compute its factorial # tests/functional/flaky_features/flaky_test/flaky.py:34\n" " Then I see the number <result> # tests/functional/flaky_features/flaky_test/flaky.py:39\n" "\n" " Examples:\n" " | number | result |\n" " | 0 | 1 |\n" " | 1 | 1 |\n" " | 1 | 1 |\n" " | 2 | 2 |\n" " | 2 | 2 |\n" " | 3 | 6 |\n" " | 3 | 6 |\n" " | 4 | 24 |\n" " | 4 | 24 |\n" "\n" "1 feature (0 passed)\n" "8 scenarios (7 passed)\n" "18 steps (1 failed, 17 passed)\n" "\n" "List of failed scenarios:\n" " @flaky\n" " Scenario: This scenario always Fail # tests/functional/flaky_features/flaky_test/flaky.feature:4\n" "\n") % { 'lettuce_core_file': lettuce_path('core.py'), 'step_file': abspath(lettuce_path('..', 'tests', 'functional', 'flaky_features', 'flaky_test')), 'call_line': call_line, } )
def test_background_runs_before_each_scenario(): 'Test Background runs before each scenario' runner = Runner(feature_name('background_feature')) results = runner.run() assert_equals(results.steps_passed, 5)