def test_help(capsys): with pytest.raises(SystemExit): main(['--help']) out, err = capsys.readouterr() assert out.startswith('usage:') assert '--extraneous' in out assert '--missing' in out
def test_missing_package_index(output, simple, caplog, missing, extra): (simple / 'index.html').write_text("""\ <html> <body> <a href="foo">foo</a> </body> </html>""") package_dir = simple / 'foo' package_dir.mkdir() main(['-o', str(output), '-m', str(missing), '-e', str(extra)]) assert len(list(find_messages(caplog.records, levelname='ERROR'))) == 1 assert missing.read_text() == str(package_dir / 'index.html') + '\n' assert extra.read_text() == ''
def test_missing_wheel_file(output, simple, caplog, missing, extra): (simple / 'index.html').write_text("""\ <html> <body> <a href="foo">foo</a> </body> </html>""") package_dir = simple / 'foo' package_dir.mkdir() (package_dir / 'index.html').write_text("""\ <html> <body> <a href="foo-0.1-py3-none-any.whl#sha256=abcdefghijkl">foo-0.1-py3-none-any.whl</a> </body> </html>""") main(['-o', str(output), '-m', str(missing), '-e', str(extra)]) assert len(list(find_messages(caplog.records, levelname='ERROR'))) == 1 assert missing.read_text() == str(package_dir / 'foo-0.1-py3-none-any.whl') + '\n' assert extra.read_text() == ''
def test_good_wheel_file(output, simple, caplog, missing, extra, broken): sha256 = hashlib.sha256() (simple / 'index.html').write_text("""\ <html> <body> <a href="foo">foo</a> </body> </html>""") package_dir = simple / 'foo' package_dir.mkdir() (package_dir / 'index.html').write_text("""\ <html> <body> <a href="foo-0.1-py3-none-any.whl#sha256={hash}">foo-0.1-py3-none-any.whl</a> </body> </html>""".format(hash=sha256.hexdigest())) (package_dir / 'foo-0.1-py3-none-any.whl').touch() main(['-o', str(output), '-m', str(missing), '-e', str(extra), '-b', str(broken)]) assert len(list(find_messages(caplog.records, levelname='ERROR'))) == 0 assert missing.read_text() == '' assert extra.read_text() == '' assert broken.read_text() == ''
def test_missing_simple_index(output, simple, caplog, missing, extra): main(['-o', str(output), '-m', str(missing), '-e', str(extra)]) assert len(list(find_messages(caplog.records, levelname='ERROR'))) == 1 assert missing.read_text() == str(simple / 'index.html') + '\n' assert extra.read_text() == ''
def test_version(capsys): with pytest.raises(SystemExit): main(['--version']) out, err = capsys.readouterr() assert out.strip() == __version__