events = win32file.WSAEnumNetworkEvents(client, client_event)
        self.assertEquals(events, {win32file.FD_WRITE: 0})

        client.shutdown(socket.SHUT_WR)
        res = win32event.WaitForSingleObject(server_event, 1000)
        self.assertEquals(res, win32event.WAIT_OBJECT_0)
        # strange timing issues...
        for i in range(5):
            events = win32file.WSAEnumNetworkEvents(server, server_event)
            if events: break
            win32api.Sleep(100)
        else:
            raise AssertionError("failed to get events")
        self.assertEquals(events, {win32file.FD_CLOSE: 0})
        events = win32file.WSAEnumNetworkEvents(client)
        self.assertEquals(events, {})

        server.close()
        res = win32event.WaitForSingleObject(client_event, 1000)
        self.assertEquals(res, win32event.WAIT_OBJECT_0)
        events = win32file.WSAEnumNetworkEvents(client, client_event)
        self.assertEquals(events, {win32file.FD_CLOSE: 0})

        client.close()
        events = win32file.WSAEnumNetworkEvents(port)
        self.assertEquals(events, {})


if __name__ == '__main__':
    testmain()
Ejemplo n.º 2
0
            else:
                test = unittest.defaultTestLoader.loadTestsFromModule(mod)
            suite.addTest(test)
    for test in get_demo_tests():
        suite.addTest(test)
    return suite


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


if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser(
        description="Test runner for PyWin32/win32")
    parser.add_argument("-no-user-interaction",
                        default=no_user_interaction,
                        action='store_true',
                        help="Run all tests without user interaction")

    parsed_args, remains = parser.parse_known_args()

    no_user_interaction = parsed_args.no_user_interaction

    sys.argv = [sys.argv[0]] + remains

    pywin32_testutil.testmain(testLoader=CustomLoader())
Ejemplo n.º 3
0
def testmain(*args, **kw):
    pywin32_testutil.testmain(*args, **kw)
    CheckClean()
Ejemplo n.º 4
0
    except NameError:
        me = sys.argv[0]
    me = os.path.abspath(me)
    files = os.listdir(os.path.dirname(me))
    suite = unittest.TestSuite()
    suite.addTest(unittest.FunctionTestCase(import_all))
    for file in files:
        base, ext = os.path.splitext(file)
        if ext=='.py' and os.path.basename(me) != file:
            try:
                mod = __import__(base)
            except:
                print("FAILED to import test module %r" % base)
                traceback.print_exc()
                continue
            if hasattr(mod, "suite"):
                test = mod.suite()
            else:
                test = unittest.defaultTestLoader.loadTestsFromModule(mod)
            suite.addTest(test)
    for test in get_demo_tests():
        suite.addTest(test)
    return suite

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

if __name__=='__main__':
    pywin32_testutil.testmain(testLoader=CustomLoader())
Ejemplo n.º 5
0
def testmain(*args, **kw):
    pywin32_testutil.testmain(*args, **kw)
    CheckClean()
Ejemplo n.º 6
0
        events = win32file.WSAEnumNetworkEvents(client, client_event)
        self.assertEquals(events, {win32file.FD_WRITE: 0})

        client.shutdown(socket.SHUT_WR)
        res = win32event.WaitForSingleObject(server_event, 1000)
        self.assertEquals(res, win32event.WAIT_OBJECT_0)
        # strange timing issues...
        for i in range(5):
            events = win32file.WSAEnumNetworkEvents(server, server_event)
            if events: break
            win32api.Sleep(100)
        else:
            raise AssertionError("failed to get events")
        self.assertEquals(events, {win32file.FD_CLOSE: 0})
        events = win32file.WSAEnumNetworkEvents(client)
        self.assertEquals(events, {})

        server.close()
        res = win32event.WaitForSingleObject(client_event, 1000)
        self.assertEquals(res, win32event.WAIT_OBJECT_0)
        events = win32file.WSAEnumNetworkEvents(client, client_event)
        self.assertEquals(events, {win32file.FD_CLOSE: 0})

        client.close()
        events = win32file.WSAEnumNetworkEvents(port)
        self.assertEquals(events, {})


if __name__ == '__main__':
    testmain()