def test_pyproject_toml_invalid() -> None: toml = TOMLFile(FIXTURE_DIR / "complete_invalid.toml").read() content = toml["tool"]["poetry"] assert Factory.validate(content) == { "errors": ["[source.0] 'url' is a required property"], "warnings": [], }
def test_validate_fails(): complete = TOMLFile(fixtures_dir / "complete.toml") content = complete.read()["tool"]["poetry"] content["this key is not in the schema"] = "" expected = ("Additional properties are not allowed " "('this key is not in the schema' was unexpected)") assert Factory.validate(content) == {"errors": [expected], "warnings": []}
def handle(self): # Load poetry config and display errors, if any poetry_file = Factory.locate(Path.cwd()) config = PyProjectTOML(poetry_file).poetry_config check_result = Factory.validate(config, strict=True) if not check_result["errors"] and not check_result["warnings"]: self.info("All set!") return 0 for error in check_result["errors"]: self.line("<error>Error: {}</error>".format(error)) for error in check_result["warnings"]: self.line("<warning>Warning: {}</warning>".format(error)) return 1
def handle(self) -> int: from poetry.core.pyproject.toml import PyProjectTOML from poetry.factory import Factory # Load poetry config and display errors, if any poetry_file = Factory.locate(Path.cwd()) config = PyProjectTOML(poetry_file).poetry_config check_result = Factory.validate(config, strict=True) if not check_result["errors"] and not check_result["warnings"]: self.info("All set!") return 0 for error in check_result["errors"]: self.line_error(f"<error>Error: {error}</error>") for error in check_result["warnings"]: self.line_error(f"<warning>Warning: {error}</warning>") return 1
def test_validate(): complete = TOMLFile(fixtures_dir / "complete.toml") content = complete.read()["tool"]["poetry"] assert Factory.validate(content) == {"errors": [], "warnings": []}
def test_pyproject_toml_valid() -> None: toml = TOMLFile(FIXTURE_DIR / "complete_valid.toml").read() content = toml["tool"]["poetry"] assert Factory.validate(content) == {"errors": [], "warnings": []}