示例#1
0
def test_make_package_pre_signed_dist(upload_settings, capsys):
    """Create a PackageFile and print path, size, and user-provided signature."""
    filename = helpers.WHEEL_FIXTURE
    expected_size = "15.4 KB"
    signed_filename = helpers.WHEEL_FIXTURE + ".asc"
    signatures = {os.path.basename(signed_filename): signed_filename}

    upload_settings.sign = True
    upload_settings.verbose = True

    package = upload._make_package(filename, signatures, upload_settings)

    assert package.filename == filename
    assert package.gpg_signature is not None

    captured = capsys.readouterr()
    assert captured.out.count(f"{filename} ({expected_size})") == 1
    assert captured.out.count(f"Signed with {signed_filename}") == 1
示例#2
0
def test_make_package_unsigned_dist(upload_settings, monkeypatch, capsys):
    """Create a PackageFile and print path, size, and Twine-generated signature."""
    filename = helpers.NEW_WHEEL_FIXTURE
    expected_size = "21.9 KB"
    signatures = {}

    upload_settings.sign = True
    upload_settings.verbose = True

    def stub_sign(package, *_):
        package.gpg_signature = (package.signed_basefilename, b"signature")

    monkeypatch.setattr(package_file.PackageFile, "sign", stub_sign)

    package = upload._make_package(filename, signatures, upload_settings)

    assert package.filename == filename
    assert package.gpg_signature is not None

    captured = capsys.readouterr()
    assert captured.out.count(f"{filename} ({expected_size})") == 1
    assert captured.out.count(f"Signed with {package.signed_filename}") == 1