def test_check_fails(): complete = TomlFile(fixtures_dir / "complete.toml") content = complete.read()["tool"]["poetry"] content["this key is not in the schema"] = "" if PY2: expected = ("Additional properties are not allowed " "(u'this key is not in the schema' was unexpected)") else: expected = ("Additional properties are not allowed " "('this key is not in the schema' was unexpected)") assert Poetry.check(content) == {"errors": [expected], "warnings": []}
def handle(self): # Load poetry config and display errors, if any poetry_file = Poetry.locate(Path.cwd()) config = TomlFile(str(poetry_file)).read()["tool"]["poetry"] check_result = Poetry.check(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 test_check(): complete = fixtures_dir / 'complete.toml' with complete.open() as f: content = toml.loads(f.read())['tool']['poetry'] assert Poetry.check(content)
def test_check(): complete = TomlFile(fixtures_dir / "complete.toml") content = complete.read()["tool"]["poetry"] assert Poetry.check(content) == {"errors": [], "warnings": []}
def test_check(): complete = fixtures_dir / "complete.toml" with complete.open() as f: content = toml.loads(f.read())["tool"]["poetry"] assert Poetry.check(content)
def test_check(): complete = TomlFile(fixtures_dir / "complete.toml") content = complete.read(raw=True)["tool"]["poetry"] assert Poetry.check(content)
def test_check_fails(): complete = TomlFile(fixtures_dir / "complete.toml") content = complete.read()["tool"]["poetry"] content["this key is not in the schema"] = "" with pytest.raises(InvalidProjectFile): Poetry.check(content)
def check(cls, config, strict=False): json.SCHEMA_DIR = Path(here / "schemas").as_posix() return Poetry.check(config, strict=strict)