def testmain(*args, **kw):
    new_kw = kw.copy()
    if not new_kw.has_key('testLoader'):
        new_kw['testLoader'] = TestLoader()
    try:
        unittest.main(*args, **new_kw)
    finally:
        _xpcom.NS_ShutdownXPCOM()
        ni = _xpcom._GetInterfaceCount()
        ng = _xpcom._GetGatewayCount()
        if ni or ng:
            print "********* WARNING - Leaving with %d/%d objects alive" % (ni,ng)
示例#2
0
def testmain(*args, **kw):
    new_kw = kw.copy()
    if not new_kw.has_key('testLoader'):
        new_kw['testLoader'] = TestLoader()
    try:
        unittest.main(*args, **new_kw)
    finally:
        _xpcom.NS_ShutdownXPCOM()
        ni = _xpcom._GetInterfaceCount()
        ng = _xpcom._GetGatewayCount()
        if ni or ng:
            print "********* WARNING - Leaving with %d/%d objects alive" % (ni,
                                                                            ng)
示例#3
0
    _TestLocalFile()
    # And our temp file
    _TestTempFile()


def _TestURI(url):
    test_file = URIFile(url)
    print "Opened file is", test_file
    got = test_file.read(-1)
    print "Read %d bytes of data from %r" % (len(got), url)
    test_file.close()


if __name__ == '__main__':
    print "Performing self-test"
    _TestAll()

    if filename_to_check_after_shutdown is not None:
        assert os.path.exists(filename_to_check_after_shutdown)

    from xpcom import _xpcom
    _xpcom.NS_ShutdownXPCOM()

    if filename_to_check_after_shutdown is not None:
        if os.path.exists(filename_to_check_after_shutdown):
            raise RuntimeError, "The delete-temp-files-on-shutdown trick did not delete the temp file!"

    if _xpcom._GetInterfaceCount() or _xpcom._GetGatewayCount():
        print "Warning - exiting with", _xpcom._GetInterfaceCount(
        ), "interfaces and", _xpcom._GetGatewayCount(), "gateways!!"
示例#4
0
            mod = __import__(base)
            if hasattr(mod, "suite"):
                test = mod.suite()
            else:
                test = unittest.defaultTestLoader.loadTestsFromModule(mod)
            suite.addTest(test)
    return suite

class CustomLoader(unittest.TestLoader):
    def loadTestsFromModule(self, module):
        return suite()

try:
    unittest.TestProgram(testLoader=CustomLoader())(argv=sys.argv)
finally:
    from xpcom import _xpcom
    _xpcom.NS_ShutdownXPCOM() # To get leak stats and otherwise ensure life is good.
    ni = _xpcom._GetInterfaceCount()
    ng = _xpcom._GetGatewayCount()
    if ni or ng:
        # The old 'regrtest' that was not based purely on unittest did not
        # do this check at the end - it relied on each module doing it itself.
        # Thus, these leaks are not new, just newly noticed :)  Likely to be
        # something silly like module globals.
        if ni == 6 and ng == 1:
            print "Sadly, there are 6/1 leaks, but these appear normal and benign"
        else:
            print "********* WARNING - Leaving with %d/%d objects alive" % (ni,ng)
    else:
        print "yay! Our leaks have all vanished!"
示例#5
0
                test = unittest.defaultTestLoader.loadTestsFromModule(mod)
            suite.addTest(test)
    return suite


class CustomLoader(unittest.TestLoader):
    def loadTestsFromModule(self, module):
        return suite()


try:
    unittest.TestProgram(testLoader=CustomLoader())(argv=sys.argv)
finally:
    from xpcom import _xpcom
    _xpcom.NS_ShutdownXPCOM(
    )  # To get leak stats and otherwise ensure life is good.
    ni = _xpcom._GetInterfaceCount()
    ng = _xpcom._GetGatewayCount()
    if ni or ng:
        # The old 'regrtest' that was not based purely on unittest did not
        # do this check at the end - it relied on each module doing it itself.
        # Thus, these leaks are not new, just newly noticed :)  Likely to be
        # something silly like module globals.
        if ni == 6 and ng == 1:
            print "Sadly, there are 6/1 leaks, but these appear normal and benign"
        else:
            print "********* WARNING - Leaving with %d/%d objects alive" % (ni,
                                                                            ng)
    else:
        print "yay! Our leaks have all vanished!"
示例#6
0
    print "Local file read test worked."

    # Now do the full test of our pointless, demo object!
    _TestLocalFile()
    # And our temp file
    _TestTempFile()

def _TestURI(url):
    test_file = URIFile(url)
    print "Opened file is", test_file
    got = test_file.read(-1)
    print "Read %d bytes of data from %r" % (len(got), url)
    test_file.close()

if __name__=='__main__':
    print "Performing self-test"
    _TestAll()
    
    if filename_to_check_after_shutdown is not None:
        assert os.path.exists(filename_to_check_after_shutdown)

    from xpcom import _xpcom
    _xpcom.NS_ShutdownXPCOM()

    if filename_to_check_after_shutdown is not None:
        if os.path.exists(filename_to_check_after_shutdown):
            raise RuntimeError, "The delete-temp-files-on-shutdown trick did not delete the temp file!"

    if _xpcom._GetInterfaceCount() or _xpcom._GetGatewayCount():
            print "Warning - exiting with", _xpcom._GetInterfaceCount(), "interfaces and", _xpcom._GetGatewayCount(), "gateways!!"