Esempio n. 1
0
def test_pilinfo():
    buf = io.StringIO()
    features.pilinfo(buf)
    out = buf.getvalue()
    lines = out.splitlines()
    assert lines[0] == "-" * 68
    assert lines[1].startswith("Pillow ")
    assert lines[2].startswith("Python ")
    lines = lines[3:]
    while lines[0].startswith("    "):
        lines = lines[1:]
    assert lines[0] == "-" * 68
    assert lines[1].startswith("Python modules loaded from ")
    assert lines[2].startswith("Binary modules loaded from ")
    assert lines[3] == "-" * 68
    jpeg = (
        "\n"
        + "-" * 68
        + "\n"
        + "JPEG image/jpeg\n"
        + "Extensions: .jfif, .jpe, .jpeg, .jpg\n"
        + "Features: open, save\n"
        + "-" * 68
        + "\n"
    )
    assert jpeg in out
Esempio n. 2
0
def pytest_report_header(config):
    try:
        from PIL import features

        with io.StringIO() as out:
            features.pilinfo(out=out, supported_formats=False)
            return out.getvalue()
    except Exception as e:
        return f"pytest_report_header failed: {e}"
Esempio n. 3
0
 def test_pilinfo(self):
     buf = io.StringIO()
     features.pilinfo(buf)
     out = buf.getvalue()
     lines = out.splitlines()
     self.assertEqual(lines[0], "-" * 68)
     self.assertTrue(lines[1].startswith("Pillow "))
     self.assertEqual(lines[2], "-" * 68)
     self.assertTrue(lines[3].startswith("Python modules loaded from "))
     self.assertTrue(lines[4].startswith("Binary modules loaded from "))
     self.assertEqual(lines[5], "-" * 68)
     self.assertTrue(lines[6].startswith("Python "))
     jpeg = ("\n" + "-" * 68 + "\n" + "JPEG image/jpeg\n" +
             "Extensions: .jfif, .jpe, .jpeg, .jpg\n" +
             "Features: open, save\n" + "-" * 68 + "\n")
     self.assertIn(jpeg, out)
Esempio n. 4
0
    ('F', (128, 128))

    PIL can do many other things, but I'll leave that for another
    day.  If you're curious, check the handbook, available from:

        http://www.pythonware.com

    Cheers /F
    """


if __name__ == "__main__":
    # check build sanity

    exit_status = 0

    features.pilinfo(sys.stdout, False)

    # use doctest to make sure the test program behaves as documented!
    import doctest

    print("Running selftest:")
    status = doctest.testmod(sys.modules[__name__])
    if status[0]:
        print("*** %s tests of %d failed." % status)
        exit_status = 1
    else:
        print("--- %s tests passed." % status[1])

    sys.exit(exit_status)