mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1155969 - Make runtests.py flake8 compliant. r=ted
This commit is contained in:
parent
a83a2b3a10
commit
0ae6398038
@ -32,15 +32,14 @@
|
||||
|
||||
import difflib
|
||||
import os
|
||||
import shutil
|
||||
from StringIO import StringIO
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import mozunit
|
||||
import unittest
|
||||
import xpt
|
||||
|
||||
|
||||
def get_output(bin, file):
|
||||
p = subprocess.Popen([bin, file], stdout=subprocess.PIPE)
|
||||
stdout, _ = p.communicate()
|
||||
@ -53,7 +52,7 @@ if "MOZILLA_OBJDIR" in os.environ:
|
||||
xptdump = os.path.abspath(os.path.join(MOZILLA_OBJDIR,
|
||||
"dist", "bin", "xpt_dump"))
|
||||
components = os.path.abspath(os.path.join(MOZILLA_OBJDIR,
|
||||
"dist", "bin", "components"))
|
||||
"dist", "bin", "components"))
|
||||
for f in os.listdir(components):
|
||||
if not f.endswith(".xpt"):
|
||||
continue
|
||||
@ -72,6 +71,7 @@ if "MOZILLA_OBJDIR" in os.environ:
|
||||
print line
|
||||
self.assert_(out == out2, "xpt_dump output should be identical for %s" % f)
|
||||
|
||||
|
||||
class TestIIDString(unittest.TestCase):
|
||||
def test_iid_str_roundtrip(self):
|
||||
iid_str = "11223344-5566-7788-9900-aabbccddeeff"
|
||||
@ -83,6 +83,7 @@ class TestIIDString(unittest.TestCase):
|
||||
iid_str = xpt.Typelib.iid_to_string(iid)
|
||||
self.assertEqual(iid, xpt.Typelib.string_to_iid(iid_str))
|
||||
|
||||
|
||||
class TypelibCompareMixin:
|
||||
def assertEqualTypelibs(self, t1, t2):
|
||||
self.assert_(t1 is not None, "Should not be None")
|
||||
@ -134,7 +135,7 @@ class TypelibCompareMixin:
|
||||
for p1, p2 in zip(m1.params, m2.params):
|
||||
self.assertEqualParams(p1, p2)
|
||||
self.assertEqualParams(m1.result, m2.result)
|
||||
|
||||
|
||||
def assertEqualConstants(self, c1, c2):
|
||||
self.assert_(c1 is not None, "Should not be None")
|
||||
self.assert_(c2 is not None, "Should not be None")
|
||||
@ -152,7 +153,7 @@ class TypelibCompareMixin:
|
||||
self.assertEqual(p1.shared, p2.shared)
|
||||
self.assertEqual(p1.dipper, p2.dipper)
|
||||
self.assertEqual(p1.optional, p2.optional)
|
||||
|
||||
|
||||
def assertEqualTypes(self, t1, t2):
|
||||
self.assert_(t1 is not None, "Should not be None")
|
||||
self.assert_(t2 is not None, "Should not be None")
|
||||
@ -174,6 +175,7 @@ class TypelibCompareMixin:
|
||||
self.assertEqual(t1.size_is_arg_num, t2.size_is_arg_num)
|
||||
self.assertEqual(t1.length_is_arg_num, t2.length_is_arg_num)
|
||||
|
||||
|
||||
class TestTypelibReadWrite(unittest.TestCase, TypelibCompareMixin):
|
||||
def test_read_file(self):
|
||||
"""
|
||||
@ -191,7 +193,7 @@ class TestTypelibReadWrite(unittest.TestCase, TypelibCompareMixin):
|
||||
self.assertEqualTypelibs(t, t2)
|
||||
|
||||
|
||||
#TODO: test flags in various combinations
|
||||
# TODO: test flags in various combinations
|
||||
class TestTypelibRoundtrip(unittest.TestCase, TypelibCompareMixin):
|
||||
def checkRoundtrip(self, t):
|
||||
s = StringIO()
|
||||
@ -200,13 +202,13 @@ class TestTypelibRoundtrip(unittest.TestCase, TypelibCompareMixin):
|
||||
t2 = xpt.Typelib.read(s)
|
||||
self.assert_(t2 is not None)
|
||||
self.assertEqualTypelibs(t, t2)
|
||||
|
||||
|
||||
def test_simple(self):
|
||||
t = xpt.Typelib()
|
||||
# add an unresolved interface
|
||||
t.interfaces.append(xpt.Interface("IFoo"))
|
||||
self.checkRoundtrip(t)
|
||||
|
||||
|
||||
t = xpt.Typelib()
|
||||
# add an unresolved interface with an IID
|
||||
t.interfaces.append(xpt.Interface("IBar", "11223344-5566-7788-9900-aabbccddeeff"))
|
||||
@ -305,7 +307,7 @@ class TestTypelibRoundtrip(unittest.TestCase, TypelibCompareMixin):
|
||||
xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32)),
|
||||
]))
|
||||
self.checkRoundtrip(t)
|
||||
|
||||
|
||||
# add a method with a StringWithSize and WideStringWithSize arguments
|
||||
i.methods.append(xpt.Method("StringWithSizeMethod", xpt.Param(xpt.SimpleType(xpt.Type.Tags.void)),
|
||||
params=[
|
||||
@ -320,11 +322,12 @@ class TestTypelibRoundtrip(unittest.TestCase, TypelibCompareMixin):
|
||||
]))
|
||||
self.checkRoundtrip(t)
|
||||
|
||||
|
||||
class TestInterfaceCmp(unittest.TestCase):
|
||||
def test_unresolvedName(self):
|
||||
"""
|
||||
Test comparison function on xpt.Interface by name.
|
||||
|
||||
|
||||
"""
|
||||
i1 = xpt.Interface("ABC")
|
||||
i2 = xpt.Interface("DEF")
|
||||
@ -334,7 +337,7 @@ class TestInterfaceCmp(unittest.TestCase):
|
||||
def test_unresolvedEqual(self):
|
||||
"""
|
||||
Test comparison function on xpt.Interface with equal names and IIDs.
|
||||
|
||||
|
||||
"""
|
||||
i1 = xpt.Interface("ABC")
|
||||
i2 = xpt.Interface("ABC")
|
||||
@ -343,7 +346,7 @@ class TestInterfaceCmp(unittest.TestCase):
|
||||
def test_unresolvedIID(self):
|
||||
"""
|
||||
Test comparison function on xpt.Interface with different IIDs.
|
||||
|
||||
|
||||
"""
|
||||
# IIDs sort before names
|
||||
i1 = xpt.Interface("ABC", iid="22334411-5566-7788-9900-aabbccddeeff")
|
||||
@ -355,7 +358,7 @@ class TestInterfaceCmp(unittest.TestCase):
|
||||
"""
|
||||
Test comparison function on xpt.Interface with interfaces with
|
||||
identical names and IIDs but different resolved status.
|
||||
|
||||
|
||||
"""
|
||||
i1 = xpt.Interface("ABC", iid="11223344-5566-7788-9900-aabbccddeeff")
|
||||
p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
|
||||
@ -369,7 +372,7 @@ class TestInterfaceCmp(unittest.TestCase):
|
||||
"""
|
||||
Test comparison function on xpt.Interface with interfaces with
|
||||
identical names and IIDs, both of which are resolved.
|
||||
|
||||
|
||||
"""
|
||||
p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
|
||||
m = xpt.Method("Bar", p)
|
||||
@ -379,12 +382,13 @@ class TestInterfaceCmp(unittest.TestCase):
|
||||
methods=[m])
|
||||
self.assert_(i2 == i1)
|
||||
|
||||
|
||||
class TestXPTLink(unittest.TestCase):
|
||||
def test_mergeDifferent(self):
|
||||
"""
|
||||
Test that merging two typelibs with completely different interfaces
|
||||
produces the correctly merged typelib.
|
||||
|
||||
|
||||
"""
|
||||
t1 = xpt.Typelib()
|
||||
# add an unresolved interface
|
||||
@ -393,7 +397,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
# add an unresolved interface
|
||||
t2.interfaces.append(xpt.Interface("IBar", scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
# Interfaces should wind up sorted
|
||||
self.assertEqual("IBar", t3.interfaces[0].name)
|
||||
@ -407,7 +411,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
# add an unresolved interface
|
||||
t2.interfaces.append(xpt.Interface("IBar", iid="44332211-6655-8877-0099-aabbccddeeff", scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
# Interfaces should wind up sorted
|
||||
self.assertEqual("IFoo", t3.interfaces[0].name)
|
||||
@ -417,7 +421,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
"""
|
||||
Test that merging two typelibs with conflicting interface definitions
|
||||
raises an error.
|
||||
|
||||
|
||||
"""
|
||||
# Same names, different IIDs
|
||||
t1 = xpt.Typelib()
|
||||
@ -452,7 +456,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
# add an unresolved interface, no IID
|
||||
t2.interfaces.append(xpt.Interface("IFoo"))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(1, len(t3.interfaces))
|
||||
self.assertEqual("IFoo", t3.interfaces[0].name)
|
||||
self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
|
||||
@ -464,7 +468,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
# add an unresolved interface with a valid IID
|
||||
t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff", scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(1, len(t3.interfaces))
|
||||
self.assertEqual("IFoo", t3.interfaces[0].name)
|
||||
self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
|
||||
@ -488,7 +492,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(1, len(t3.interfaces))
|
||||
self.assertEqual("IFoo", t3.interfaces[0].name)
|
||||
self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
|
||||
@ -507,7 +511,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
# add an unresolved interface
|
||||
t2.interfaces.append(xpt.Interface("IFoo"))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(1, len(t3.interfaces))
|
||||
self.assertEqual("IFoo", t3.interfaces[0].name)
|
||||
self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
|
||||
@ -538,7 +542,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IChild", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
@ -566,7 +570,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IChild", iid="11111111-1111-1111-1111-111111111111",
|
||||
resolved=True, parent=pi, scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IChild", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
@ -603,7 +607,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IRetval", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
@ -636,7 +640,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IRetval", iid="11111111-1111-1111-1111-111111111111",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IRetval", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
@ -675,7 +679,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IParam", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
@ -708,7 +712,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IParam", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
@ -721,7 +725,6 @@ class TestXPTLink(unittest.TestCase):
|
||||
self.assertEqual(t3.interfaces[1],
|
||||
t3.interfaces[0].methods[0].params[0].type.iface)
|
||||
|
||||
|
||||
def test_mergeReplaceArrayTypeParams(self):
|
||||
"""
|
||||
Test that merging an interface correctly updates ArrayType
|
||||
@ -750,7 +753,7 @@ class TestXPTLink(unittest.TestCase):
|
||||
t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
|
||||
methods=[m], scriptable=True))
|
||||
t3 = xpt.xpt_link([t1, t2])
|
||||
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
self.assertEqual("IParam", t3.interfaces[0].name)
|
||||
self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
|
||||
|
Loading…
Reference in New Issue
Block a user