(pytester, ini_base_dir)
| 58 | |
| 59 | |
| 60 | def prepare_testdir(pytester, ini_base_dir): |
| 61 | pytester.makeini( |
| 62 | """ |
| 63 | [pytest] |
| 64 | bdd_features_base_dir={} |
| 65 | """.format( |
| 66 | ini_base_dir |
| 67 | ) |
| 68 | ) |
| 69 | |
| 70 | feature_file = pytester.mkdir("features").joinpath("steps.feature") |
| 71 | feature_file.write_text( |
| 72 | """ |
| 73 | Feature: Feature path |
| 74 | Scenario: When scenario found |
| 75 | Given found |
| 76 | """ |
| 77 | ) |
| 78 | |
| 79 | pytester.makepyfile( |
| 80 | """ |
| 81 | import os.path |
| 82 | |
| 83 | import pytest |
| 84 | |
| 85 | from pytest_bdd import scenario, scenarios |
| 86 | |
| 87 | FEATURE = 'steps.feature' |
| 88 | |
| 89 | |
| 90 | @pytest.fixture(params=[ |
| 91 | 'When scenario found', |
| 92 | ]) |
| 93 | def scenario_name(request): |
| 94 | return request.param |
| 95 | |
| 96 | |
| 97 | @pytest.mark.parametrize( |
| 98 | 'multiple', [True, False] |
| 99 | ) |
| 100 | def test_not_found_by_ini(scenario_name, multiple): |
| 101 | with pytest.raises(IOError) as exc: |
| 102 | if multiple: |
| 103 | scenarios(FEATURE) |
| 104 | else: |
| 105 | scenario(FEATURE, scenario_name) |
| 106 | assert os.path.abspath(os.path.join('{}', FEATURE)) in str(exc.value) |
| 107 | |
| 108 | |
| 109 | @pytest.mark.parametrize( |
| 110 | 'multiple', [True, False] |
| 111 | ) |
| 112 | def test_ok_by_ini(scenario_name, multiple): |
| 113 | # Shouldn't raise any exception |
| 114 | if multiple: |
| 115 | scenarios(FEATURE) |
| 116 | else: |
| 117 | scenario(FEATURE, scenario_name) |
no outgoing calls
no test coverage detected
searching dependent graphs…