Beispiel #1
0
def test_that_logger_with_high_verbosity_level_does_emit_warning_logs(
        logger: Logger, level: Verbosity):
    logger.set_verbosity(level)
    logger.warning("test")

    output = get_logger_output(logger)
    assert "WARNING" in output
Beispiel #2
0
def format_nix_files(logger: Logger) -> None:
    if is_nixfmt_installed():
        logger.info("Formatting nix files")
        integration_test_nix_files = find_nix_files_in_integration_tests()
        subprocess.run(
            ["nixfmt", "default.nix", "src/pypi2nix/pip/bootstrap.nix"] +
            integration_test_nix_files,
            check=True,
        )
    else:
        logger.warning(
            "Could not find `nixfmt` executable.  Cannot format .nix files")
Beispiel #3
0
    def from_wheel_directory_path(
        wheel_class: "Type[Wheel]",
        wheel_directory_path: str,
        target_platform: TargetPlatform,
        logger: Logger,
        requirement_parser: RequirementParser,
    ) -> "Wheel":
        metadata_file = os.path.join(wheel_directory_path, "METADATA")
        if os.path.exists(metadata_file):
            with open(metadata_file,
                      "r",
                      encoding="ascii",
                      errors="surrogateescape") as headers:
                metadata = email.parser.Parser().parse(headers)
            license_string = str_from_message(metadata, "license")
            if license_string is None:
                license_string = ""
            classifiers = list_from_message(metadata, "Classifier")
            if classifiers is None:
                classifiers = []
            license = find_license(classifiers=classifiers,
                                   license_string=license_string)

            if license is None:
                license = '"' + safe(license_string) + '"'
                logger.warning(
                    "Couldn't recognize license `{}` for `{}`".format(
                        license_string, metadata.get("name")))

            name = str_from_message(metadata, "name")
            if name is None:
                raise Exception("Could not extract name from wheel metadata")
            else:
                name = canonicalize_name(name)

            version = str_from_message(metadata, "version")
            if version is None:
                raise Exception(
                    "Could not extract version from wheel metadata")

            dependencies = list_from_message(metadata, "requires-dist")
            if dependencies is None:
                dependencies = []

            description = str_from_message(metadata, "summary")
            if description is None:
                description = ""

            return wheel_class(
                name=name,
                version=version,
                deps=wheel_class._extract_deps(
                    dependencies,
                    target_platform,
                    requirement_parser,
                    current_wheel_name=name,
                ),
                homepage=safe(find_homepage(metadata)),
                license=license,
                description=safe(description),
                build_dependencies=RequirementSet(target_platform),
                target_platform=target_platform,
            )

        raise click.ClickException("Unable to find METADATA in `%s` folder." %
                                   wheel_directory_path)
Beispiel #4
0
def test_can_log_warning(logger: Logger):
    logger.warning("test")

    assert "WARNING: test" in get_logger_output(logger)