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() assert_equals(out.getvalue(), "\n" "Feature: Multiplication # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:2\n" " In order to avoid silly mistakes # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:3\n" " Cashiers must be able to multiplicate numbers :) # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:4\n" "\n" " #1\n" " Scenario: Regular numbers # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:6\n" " Given I have entered 10 into the calculator # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:11\n" " And I have entered 4 into the calculator # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:11\n" " When I press multiply # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:15\n" " Then the result should be 40 on the screen # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:19\n" "\n" " ----------------------------------------------------------------------------\n" "\n" " #2\n" " Scenario: Shorter version of the scenario above # tests/functional/behave_as_features/1st_normal_steps/1st_normal_steps.feature:12\n" " Given I multiply 10 and 4 into the calculator # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:23\n" " Then the result should be 40 on the screen # tests/functional/behave_as_features/1st_normal_steps/simple_step_definitions.py:19\n" "\n" " ----------------------------------------------------------------------------\n" "\n" "1 feature (1 passed)\n" "2 scenarios (2 passed)\n" "6 steps (6 passed)\n" )
def test_simple_tables_behave_as_feature(): "Basic step.behave_as behaviour is working" with capture_output() as (out, _): Runner(path_to_feature('2nd_table_steps'), verbosity=3).run() assert_equals(out.getvalue(), "\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" " #1\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" " ----------------------------------------------------------------------------\n" "\n" " #2\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" " ----------------------------------------------------------------------------\n" "\n" "1 feature (1 passed)\n" "2 scenarios (2 passed)\n" "4 steps (4 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: 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_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_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_of_table_with_success_colorless(): """Language: pt-br -> success table colorless""" with capture_output() as (out, err): runner = Runner(join_path('pt-br', 'success', 'table.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), 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" #1\n" u" Cenario: 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"\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_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: pt-br -> success colorless""" with capture_output() as (out, err): runner = Runner(join_path('pt-br', 'success', 'dumb.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u"\n" u"Funcionalidade: feature burra # tests/functional/language_specific_features/pt-br/success/dumb.feature:3\n" u" Como um programador # tests/functional/language_specific_features/pt-br/success/dumb.feature:4\n" u" Eu quero que este teste passe # tests/functional/language_specific_features/pt-br/success/dumb.feature:5\n" u" Para testar um cenário de sucesso # tests/functional/language_specific_features/pt-br/success/dumb.feature:6\n" u"\n" u" #1\n" u" Cenario: Fazer nada # tests/functional/language_specific_features/pt-br/success/dumb.feature:8\n" u" Dado que eu faço nada # tests/functional/language_specific_features/pt-br/success/dumb_steps.py:6\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_output_of_table_with_success_colorless(): """Language: ja -> success table colorless""" with capture_output() as (out, err): runner = Runner(join_path('ja', 'success', 'table.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u"\n" u"フィーチャ: テーブル記法 # tests/functional/language_specific_features/ja/success/table.feature:3\n" u" 日本語でのテーブル記法がパスするかのテスト # tests/functional/language_specific_features/ja/success/table.feature:4\n" u"\n" u" #1\n" u" シナリオ: 何もしないテーブル # tests/functional/language_specific_features/ja/success/table.feature:6\n" u" 前提 データは以下: # tests/functional/language_specific_features/ja/success/table_steps.py:6\n" u" | id | 定義 |\n" u" | 12 | 何かの定義 |\n" u" | 64 | 別の定義 |\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_output_outlines_success_colorless(): """Language: pt-br -> success outlines colorless""" with capture_output() as (out, err): runner = Runner(join_path('pt-br', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), 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' #1\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'\n' u' Example #1:\n' u' | dado1 | isso | aquilo |\n' u' | algo | assim | funcional |\n' u'\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" ----------------------------------------------------------------------------\n" u'\n' u' Example #2:\n' u' | dado1 | isso | aquilo |\n' u' | outro | aqui | também |\n' u'\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" ----------------------------------------------------------------------------\n" u'\n' u' Example #3:\n' u' | dado1 | isso | aquilo |\n' u' | dados | funcionarão | com unicode ! |\n' u'\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" ----------------------------------------------------------------------------\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: fr -> success outlines colorless""" with capture_output() as (out, err): runner = Runner(join_path('fr', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u""" Fonctionnalité: Plan de scénario en français # tests/functional/language_specific_features/fr/success/outlines.feature:4 En tant que programmeur # tests/functional/language_specific_features/fr/success/outlines.feature:5 Je veux tester les plans de scénario # tests/functional/language_specific_features/fr/success/outlines.feature:6 Et surtout les sorties # tests/functional/language_specific_features/fr/success/outlines.feature:7 #1 Plan du Scénario: Faire la sieste # tests/functional/language_specific_features/fr/success/outlines.feature:9 Example #1: | mois | lieux | | janvier | près de la cheminé | Soit un après midi de <mois> # tests/functional/language_specific_features/fr/success/outlines_steps.py:13 Quand je veux faire la sieste # tests/functional/language_specific_features/fr/success/outlines_steps.py:22 Et je peux aller <lieux> # tests/functional/language_specific_features/fr/success/outlines_steps.py:26 ---------------------------------------------------------------------------- Example #2: | mois | lieux | | aôut | dans le transat | Soit un après midi de <mois> # tests/functional/language_specific_features/fr/success/outlines_steps.py:13 Quand je veux faire la sieste # tests/functional/language_specific_features/fr/success/outlines_steps.py:22 Et je peux aller <lieux> # tests/functional/language_specific_features/fr/success/outlines_steps.py:26 ---------------------------------------------------------------------------- Example #3: | mois | lieux | | octobre | dans le canapé | Soit un après midi de <mois> # tests/functional/language_specific_features/fr/success/outlines_steps.py:13 Quand je veux faire la sieste # tests/functional/language_specific_features/fr/success/outlines_steps.py:22 Et je peux aller <lieux> # tests/functional/language_specific_features/fr/success/outlines_steps.py:26 ---------------------------------------------------------------------------- 1 feature (1 passed) 3 scenarios (3 passed) 9 steps (9 passed) """)
def test_output_outlines_success_colorless(): """Language: ja -> success outlines colorless""" with capture_output() as (out, err): runner = Runner(join_path('ja', 'success', 'outlines.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u""" フィーチャ: アウトラインを日本語で書く # tests/functional/language_specific_features/ja/success/outlines.feature:3 図表のテストをパスすること # tests/functional/language_specific_features/ja/success/outlines.feature:4 #1 シナリオテンプレ: 全てのテストで何もしない # tests/functional/language_specific_features/ja/success/outlines.feature:6 Example #1: | データ1 | 方法 | 結果 | | 何か | これ | 機能 | 前提 入力値を <データ1> とし # tests/functional/language_specific_features/ja/success/outlines_steps.py:13 もし 処理 <方法> を使って # tests/functional/language_specific_features/ja/success/outlines_steps.py:22 ならば 表示は <結果> である # tests/functional/language_specific_features/ja/success/outlines_steps.py:31 ---------------------------------------------------------------------------- Example #2: | データ1 | 方法 | 結果 | | その他 | ここ | 同じ | 前提 入力値を <データ1> とし # tests/functional/language_specific_features/ja/success/outlines_steps.py:13 もし 処理 <方法> を使って # tests/functional/language_specific_features/ja/success/outlines_steps.py:22 ならば 表示は <結果> である # tests/functional/language_specific_features/ja/success/outlines_steps.py:31 ---------------------------------------------------------------------------- Example #3: | データ1 | 方法 | 結果 | | データ | 動く | unicodeで! | 前提 入力値を <データ1> とし # tests/functional/language_specific_features/ja/success/outlines_steps.py:13 もし 処理 <方法> を使って # tests/functional/language_specific_features/ja/success/outlines_steps.py:22 ならば 表示は <結果> である # tests/functional/language_specific_features/ja/success/outlines_steps.py:31 ---------------------------------------------------------------------------- 1 feature (1 passed) 3 scenarios (3 passed) 9 steps (9 passed) """)
def test_output_with_success_colorless(): """Language: ja -> success colorless""" with capture_output() as (out, err): runner = Runner(join_path('ja', 'success', 'dumb.feature'), verbosity=3) runner.run() assert_equals(out.getvalue(), u"\n" u"フィーチャ: ダムフィーチャ # tests/functional/language_specific_features/ja/success/dumb.feature:3\n" u" テストをグリーンになればテスト成功 # tests/functional/language_specific_features/ja/success/dumb.feature:4\n" u"\n" u" #1\n" u" シナリオ: 何もしない # tests/functional/language_specific_features/ja/success/dumb.feature:6\n" u" 前提 何もしない # tests/functional/language_specific_features/ja/success/dumb_steps.py:6\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_failing_tables_behave_as_feature(): "Basic step.behave_as behaviour is working" with capture_output() as (out, _): assert_raises( SystemExit, Runner(path_to_feature('3rd_failing_steps'), verbosity=3).run ) assert_lines_with_traceback(out.getvalue(), '\n' 'Feature: Multiplication # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:2\n' ' In order to avoid silly mistakes # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:3\n' ' Cashiers must be able to multiplicate numbers :) # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:4\n' '\n' ' #1\n' ' Scenario: Regular numbers # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:6\n' ' Given I have entered 10 into the calculator # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:11\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 13, in i_have_entered_NUM_into_the_calculator\n' ' assert False, \'Die, die, die my darling!\'\n' ' AssertionError: Die, die, die my darling!\n' ' And I have entered 4 into the calculator # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:11\n' ' When I press multiply # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:16\n' ' Then the result should be 40 on the screen # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:20\n' '\n' ' ----------------------------------------------------------------------------\n' '\n' ' #2\n' ' Scenario: Shorter version of the scenario above # tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:12\n' ' Given I multiply 10 and 4 into the calculator # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:24\n' ' Traceback (most recent call last):\n' ' File "%(lettuce_core_file)s", line %(call_line)d, in behave_as\n' ' ret = self.function(self.step, *args, **kw)\n' ' File "%(step_file)s", line 29, in multiply_X_and_Y_into_the_calculator\n' ' \'\'\'.format(x, y))\n' ' File "%(lettuce_core_file)s", line 170, in behave_as\n' ' step.run()\n' ' File "%(lettuce_core_file)s", line 183, in run\n' ' step_definition(*groups)\n' ' File "%(lettuce_core_file)s", line 58, in __call__\n' ' raise e\n' ' AssertionError: Die, die, die my darling!\n' ' Then the result should be 40 on the screen # tests/functional/behave_as_features/3rd_failing_steps/failing_step_definitions.py:20\n' '\n' ' ----------------------------------------------------------------------------\n' '\n' '1 feature (1 failed)\n' '2 scenarios (2 failed)\n' '6 steps (4 skipped, 2 failed)\n' '\n' 'List of failed scenarios:\n' '\n' ' * Feature: Multiplication\n' ' - Scenario: Regular numbers\n' ' (tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:6)\n' ' - Scenario: Shorter version of the scenario above\n' ' (tests/functional/behave_as_features/3rd_failing_steps/3rd_failing_steps.feature:12)\n' '\n' % { 'lettuce_core_file': lettuce_path('core.py'), 'step_file': abspath(lettuce_path('..', 'tests', 'functional', 'behave_as_features', '3rd_failing_steps', 'failing_step_definitions.py')), 'call_line':call_line, } )