예제 #1
0
def test_pypi_error(sampleproject_dist, monkeypatch):
    command = [
        "twine",
        "upload",
        "--repository-url",
        "https://test.pypi.org/legacy/",
        "--username",
        "foo",
        "--password",
        "bar",
        str(sampleproject_dist),
    ]
    monkeypatch.setattr(sys, "argv", command)

    message = (
        re.escape(colorama.Fore.RED) +
        r"HTTPError: 403 Forbidden from https://test\.pypi\.org/legacy/\n" +
        r".+?authentication")

    result = dunder_main.main()

    assert re.match(message, result)
예제 #2
0
def test_exception_handling(monkeypatch):
    replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration("foo"))
    monkeypatch.setattr(cli, "dispatch", replaced_dispatch)
    assert dunder_main.main() == "InvalidConfiguration: foo"
예제 #3
0
def test_exception_handling(monkeypatch):
    replaced_dispatch = pretend.raiser(exceptions.InvalidConfiguration('foo'))
    monkeypatch.setattr(dunder_main, 'dispatch', replaced_dispatch)
    assert dunder_main.main() == 'InvalidConfiguration: foo'
예제 #4
0
def test_exception_handling(monkeypatch):
    replaced_dispatch = pretend.raiser(KeyError('foo'))
    monkeypatch.setattr(dunder_main, 'dispatch', replaced_dispatch)
    assert dunder_main.main() == 'KeyError: foo'
예제 #5
0
def test_no_color_exception(monkeypatch):
    monkeypatch.setattr(sys, "argv",
                        ["twine", "--no-color", "upload", "missing.whl"])
    message = "InvalidDistribution: Cannot find file (or expand pattern): 'missing.whl'"
    assert dunder_main.main() == message
예제 #6
0
def test_exception_handling(monkeypatch):
    monkeypatch.setattr(sys, "argv", ["twine", "upload", "missing.whl"])
    message = "InvalidDistribution: Cannot find file (or expand pattern): 'missing.whl'"
    assert dunder_main.main(
    ) == colorama.Fore.RED + message + colorama.Style.RESET_ALL
예제 #7
0
                                               'main',
                                               'station_name',
                                               'ticket_count',
                                               'colored_text',
                                           ]) if '.py' == file_name[-3:]
                    and file_name not in exclude else f1.read())
    print('Shrinking finished!!')

    rmtree = shutil.rmtree
    mp.Process(target=rmtree, args=('dist', True)).start()
    mp.Process(target=rmtree, args=('build', True)).start()

    argv = sys.argv
    argv.append('bdist_wheel')  # do not delete import setup
    import setup

    mp.Process(target=rmtree, args=('build', True)).start()

    # noinspection PyProtectedMember
    import pip._internal as pip

    for dir_path, _, file_names in os.walk('dist'):
        pip.main(fr'install -U --pre --force-reinstall dist/{file_names[0]}'.
                 split())
        break

    import twine.__main__ as twine

    argv[1:] = r'upload --verbose -u jerryc05 dist\*'.split()
    twine.main()
    input('All done!!')
예제 #8
0
파일: test_main.py 프로젝트: pypa/twine
def test_exception_handling(monkeypatch):
    replaced_dispatch = pretend.raiser(
        exceptions.InvalidConfiguration('foo')
    )
    monkeypatch.setattr(dunder_main, 'dispatch', replaced_dispatch)
    assert dunder_main.main() == 'InvalidConfiguration: foo'