add Python version to selftest, rename brief parameter

This commit is contained in:
nulano 2019-10-12 15:01:18 +01:00
parent 5f4c1e113c
commit accbe58b5e
4 changed files with 24 additions and 21 deletions

View File

@ -70,11 +70,14 @@ class TestFeatures(PillowTestCase):
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 "))
self.assertTrue(lines[2].startswith("Python "))
lines = lines[3:]
while lines[0].startswith(" "):
lines = lines[1:]
self.assertEqual(lines[0], "-" * 68)
self.assertTrue(lines[1].startswith("Python modules loaded from "))
self.assertTrue(lines[2].startswith("Binary modules loaded from "))
self.assertEqual(lines[3], "-" * 68)
jpeg = (
"\n"
+ "-" * 68

View File

@ -12,11 +12,14 @@ class TestMain(TestCase):
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 "))
self.assertTrue(lines[2].startswith("Python "))
lines = lines[3:]
while lines[0].startswith(" "):
lines = lines[1:]
self.assertEqual(lines[0], "-" * 68)
self.assertTrue(lines[1].startswith("Python modules loaded from "))
self.assertTrue(lines[2].startswith("Binary modules loaded from "))
self.assertEqual(lines[3], "-" * 68)
jpeg = (
os.linesep
+ "-" * 68

View File

@ -161,7 +161,7 @@ if __name__ == "__main__":
exit_status = 0
features.pilinfo(sys.stdout, True)
features.pilinfo(sys.stdout, False)
# use doctest to make sure the test program behaves as documented!
import doctest

View File

@ -95,7 +95,7 @@ def get_supported():
return ret
def pilinfo(out=None, brief=False):
def pilinfo(out=None, supported_formats=True):
if out is None:
out = sys.stdout
@ -103,6 +103,10 @@ def pilinfo(out=None, brief=False):
print("-" * 68, file=out)
print("Pillow {}".format(PIL.__version__), file=out)
py_version = sys.version.splitlines()
print("Python {}".format(py_version[0].strip()), file=out)
for py_version in py_version[1:]:
print(" {}".format(py_version.strip()), file=out)
print("-" * 68, file=out)
print(
"Python modules loaded from {}".format(os.path.dirname(Image.__file__)),
@ -114,13 +118,6 @@ def pilinfo(out=None, brief=False):
)
print("-" * 68, file=out)
if not brief:
v = sys.version.splitlines()
print("Python {}".format(v[0].strip()), file=out)
for v in v[1:]:
print(" {}".format(v.strip()), file=out)
print("-" * 68, file=out)
for name, feature in [
("pil", "PIL CORE"),
("tkinter", "TKINTER"),
@ -135,7 +132,7 @@ def pilinfo(out=None, brief=False):
("zlib", "ZLIB (PNG/ZIP)"),
("libtiff", "LIBTIFF"),
("raqm", "RAQM (Bidirectional Text)"),
("libimagequant", "LIBIMAGEQUANT (quantization method)"),
("libimagequant", "LIBIMAGEQUANT (Quantization method)"),
]:
if check(name):
print("---", feature, "support ok", file=out)
@ -143,7 +140,7 @@ def pilinfo(out=None, brief=False):
print("***", feature, "support not installed", file=out)
print("-" * 68, file=out)
if not brief:
if supported_formats:
extensions = collections.defaultdict(list)
for ext, i in Image.EXTENSION.items():
extensions[i].append(ext)