def test_black_passes(cookies, context_override): """Generated project should pass black.""" result = cookies.bake(extra_context=context_override) try: sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/") except sh.ErrorReturnCode as e: pytest.fail(e.stdout.decode())
def test_black_is_able_to_correct_files( cookies: Cookies, context: Dict[str, str], context_override: Dict[str, str]) -> None: """Black is run on the post hooks, make sure it runs without problem.""" result = cookies.bake(extra_context={**context, **context_override}) try: sh.black("--exclude", "migrations", _cwd=str(result.project)) except sh.ErrorReturnCode as error: pytest.fail(error.stdout.decode())
def test_black_passes(cookies, context_combination): """ Generated project should pass black. This is parametrized for each combination from ``context_combination`` fixture """ result = cookies.bake(extra_context=context_combination) try: sh.black("--check", "--diff", "--exclude", "migrations", f"{result.project}/") except sh.ErrorReturnCode as e: pytest.fail(e)
def test_black_passes(cookies, context_override): """Generated project should pass black.""" result = cookies.bake(extra_context=context_override) result_project_dir = f"{result._project_dir}" try: sh.black( "--config", str(PYPROJECT_TOML), "--check", "--diff", "--exclude", "migrations", f"{result.project}/", _cwd=result_project_dir, ) except sh.ErrorReturnCode as e: pytest.fail(e.stdout.decode())
def test_black_passes(cookies): """ Generated project should pass black. """ result = cookies.bake() try: sh.black( "--verbose", "--check", "--diff", "--exclude", "venv|docs/source/conf.py|setup.py", str(result.project), ) except sh.ErrorReturnCode as e: pytest.fail(e)
def format_code() -> None: """Correct source code following the Black style.""" print(" * Make repository Black linter compliant.") sh.black("setup.py", "src", "docs/examples", "tests")
remove_folder("assets/src/routes") if "{{ cookiecutter.content_renderer_plugin }}" == "Yes": context = {"content_kind": ""} while context["content_kind"] not in dict(content_kinds.choices): print("Choose a content kind that this plugin renders, choose from {}". format(", ".join(dict(content_kinds.choices).keys()))) context["content_kind"] = raw_input( "Select the content kind that this plugin renders: ") if context["content_kind"] not in dict(content_kinds.choices): print("Invalid kind.") context["file_extension"] = raw_input( "Please provide the file extension that this plugin renders: ") env = StrictEnvironment( context=context, keep_trailing_newline=True, ) env.loader = FileSystemLoader("/") render_file("kolibri_plugin.py", context, env) render_file("assets/src/module.js", context, env) render_file("content_types.json", context, env) else: remove_file("content_types.json") if ("{{ cookiecutter.has_own_page }}" == "Yes" and "{{ cookiecutter.frontend_plugin }}" == "Yes"): shutil.move(location("assets/src/module.js"), location("assets/src/app.js")) sh.black(PROJECT_DIRECTORY)