MCPcopy Create free account
hub / github.com/pytest-dev/pytest-bdd / test_migrate

Function test_migrate

tests/scripts/test_migrate.py:12–50  ·  view source on GitHub ↗

Test if the code is migrated by a given file mask.

(monkeypatch, capsys, pytester)

Source from the content-addressed store, hash-verified

10
11
12def 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 )

Callers

nothing calls this directly

Calls 1

mainFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…