# Path: pytest_bdd/scripts.py
# def main() -> None:
#     """Main entry point."""
#     parser = argparse.ArgumentParser(prog="pytest-bdd")
#     subparsers = parser.add_subparsers(help="sub-command help", dest="command")
#     subparsers.required = True
#     parser_generate = subparsers.add_parser("generate", help="generate help")
#     parser_generate.add_argument(
#         "files",
#         metavar="FEATURE_FILE",
#         type=check_existense,
#         nargs="+",
#         help="Feature files to generate test code with",
#     )
#     parser_generate.set_defaults(func=print_generated_code)
# 
#     parser_migrate = subparsers.add_parser("migrate", help="migrate help")
#     parser_migrate.add_argument("path", metavar="PATH", help="Migrate outdated tests to the most recent form")
#     parser_migrate.set_defaults(func=migrate_tests)
# 
#     args = parser.parse_args()
#     if hasattr(args, "func"):
#         args.func(args)


import os
import sys
import textwrap
from pytest_bdd.scripts import main
"""Test code generation command."""



PATH = os.path.dirname(__file__)


def test_migrate(monkeypatch, capsys, testdir):
    """Test if the code is migrated by a given file mask."""
    tests = testdir.mkpydir("tests")

    tests.join("test_foo.py").write(
        textwrap.dedent(
            '''
        """Foo bar tests."""
        from pytest_bdd import scenario

        test_foo = scenario('foo_bar.feature', 'Foo bar')
    '''
        )
    )

    monkeypatch.setattr(sys, "argv", ["", "migrate", tests.strpath])

# Path: pytest_bdd/scripts.py
# def main() -> None:
#     """Main entry point."""
#     parser = argparse.ArgumentParser(prog="pytest-bdd")
#     subparsers = parser.add_subparsers(help="sub-command help", dest="command")
#     subparsers.required = True
#     parser_generate = subparsers.add_parser("generate", help="generate help")
#     parser_generate.add_argument(
#         "files",
#         metavar="FEATURE_FILE",
#         type=check_existense,
#         nargs="+",
#         help="Feature files to generate test code with",
#     )
#     parser_generate.set_defaults(func=print_generated_code)
# 
#     parser_migrate = subparsers.add_parser("migrate", help="migrate help")
#     parser_migrate.add_argument("path", metavar="PATH", help="Migrate outdated tests to the most recent form")
#     parser_migrate.set_defaults(func=migrate_tests)
# 
#     args = parser.parse_args()
#     if hasattr(args, "func"):
#         args.func(args)


# Path: tests/scripts/test_migrate.py
import os
import sys
import textwrap
from pytest_bdd.scripts import main

"""Test code generation command."""



PATH = os.path.dirname(__file__)


def test_migrate(monkeypatch, capsys, testdir):
    """Test if the code is migrated by a given file mask."""
    tests = testdir.mkpydir("tests")

    tests.join("test_foo.py").write(
        textwrap.dedent(
            '''
        """Foo bar tests."""
        from pytest_bdd import scenario

        test_foo = scenario('foo_bar.feature', 'Foo bar')
    '''
        )
    )

    monkeypatch.setattr(sys, "argv", ["", "migrate", tests.strpath])

    main()