Exemplo n.º 1
0
 def test_group_PopenGateway(self):
     group = Group()
     gw = group.makegateway("popen")
     assert list(group) == [gw]
     assert group[0] == gw
     assert len(group) == 1
     group._cleanup_atexit()
     assert not group._gateways
Exemplo n.º 2
0
 def test_group_PopenGateway(self):
     group = Group()
     gw = group.makegateway("popen")
     assert list(group) == [gw]
     assert group[0] == gw
     assert len(group) == 1
     group._cleanup_atexit()
     assert not group._gateways
Exemplo n.º 3
0
    def test_basic_group(self, monkeypatch):
        import atexit

        atexitlist = []
        monkeypatch.setattr(atexit, "register", atexitlist.append)
        group = Group()
        assert atexitlist == [group._cleanup_atexit]
        exitlist = []
        joinlist = []

        class PseudoIO:
            def wait(self):
                pass

        class PseudoSpec:
            via = None

        class PseudoGW:
            id = "9999"
            _io = PseudoIO()
            spec = PseudoSpec()

            def exit(self):
                exitlist.append(self)
                group._unregister(self)

            def join(self):
                joinlist.append(self)

        gw = PseudoGW()
        group._register(gw)
        assert len(exitlist) == 0
        assert len(joinlist) == 0
        group._cleanup_atexit()
        assert len(exitlist) == 1
        assert exitlist == [gw]
        assert len(joinlist) == 1
        assert joinlist == [gw]
        group._cleanup_atexit()
        assert len(exitlist) == 1
        assert len(joinlist) == 1
Exemplo n.º 4
0
    def test_basic_group(self, monkeypatch):
        import atexit
        atexitlist = []
        monkeypatch.setattr(atexit, 'register', atexitlist.append)
        group = Group()
        assert atexitlist == [group._cleanup_atexit]
        exitlist = []
        joinlist = []

        class PseudoIO:
            def wait(self):
                pass

        class PseudoSpec:
            via = None

        class PseudoGW:
            id = "9999"
            _io = PseudoIO()
            spec = PseudoSpec()

            def exit(self):
                exitlist.append(self)
                group._unregister(self)

            def join(self):
                joinlist.append(self)
        gw = PseudoGW()
        group._register(gw)
        assert len(exitlist) == 0
        assert len(joinlist) == 0
        group._cleanup_atexit()
        assert len(exitlist) == 1
        assert exitlist == [gw]
        assert len(joinlist) == 1
        assert joinlist == [gw]
        group._cleanup_atexit()
        assert len(exitlist) == 1
        assert len(joinlist) == 1