Test if the code is migrated by a given file mask.
(monkeypatch, capsys, pytester)
| 10 | |
| 11 | |
| 12 | def test_migrate(monkeypatch, capsys, pytester): |
| 13 | """Test if the code is migrated by a given file mask.""" |
| 14 | tests = pytester.mkpydir("tests") |
| 15 | |
| 16 | tests.joinpath("test_foo.py").write_text( |
| 17 | textwrap.dedent( |
| 18 | ''' |
| 19 | """Foo bar tests.""" |
| 20 | from pytest_bdd import scenario |
| 21 | |
| 22 | test_foo = scenario('foo_bar.feature', 'Foo bar') |
| 23 | ''' |
| 24 | ) |
| 25 | ) |
| 26 | |
| 27 | monkeypatch.setattr(sys, "argv", ["", "migrate", str(tests)]) |
| 28 | main() |
| 29 | out, err = capsys.readouterr() |
| 30 | out = "\n".join(sorted(out.splitlines())) |
| 31 | expected = textwrap.dedent( |
| 32 | """ |
| 33 | migrated: {0}/test_foo.py |
| 34 | skipped: {0}/__init__.py""".format( |
| 35 | str(tests) |
| 36 | )[ |
| 37 | 1: |
| 38 | ] |
| 39 | ) |
| 40 | assert out == expected |
| 41 | assert tests.joinpath("test_foo.py").read_text() == textwrap.dedent( |
| 42 | ''' |
| 43 | """Foo bar tests.""" |
| 44 | from pytest_bdd import scenario |
| 45 | |
| 46 | @scenario('foo_bar.feature', 'Foo bar') |
| 47 | def test_foo(): |
| 48 | pass |
| 49 | ''' |
| 50 | ) |
nothing calls this directly
no test coverage detected
searching dependent graphs…