Exemple #1
0
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": []}
Exemple #2
0
    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
Exemple #3
0
def test_check():
    complete = fixtures_dir / 'complete.toml'
    with complete.open() as f:
        content = toml.loads(f.read())['tool']['poetry']

    assert Poetry.check(content)
Exemple #4
0
def test_check():
    complete = TomlFile(fixtures_dir / "complete.toml")
    content = complete.read()["tool"]["poetry"]

    assert Poetry.check(content) == {"errors": [], "warnings": []}
Exemple #5
0
def test_check():
    complete = fixtures_dir / "complete.toml"
    with complete.open() as f:
        content = toml.loads(f.read())["tool"]["poetry"]

    assert Poetry.check(content)
Exemple #6
0
def test_check():
    complete = TomlFile(fixtures_dir / "complete.toml")
    content = complete.read(raw=True)["tool"]["poetry"]

    assert Poetry.check(content)
Exemple #7
0
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)
Exemple #8
0
 def check(cls, config, strict=False):
     json.SCHEMA_DIR = Path(here / "schemas").as_posix()
     return Poetry.check(config, strict=strict)