Ejemplo n.º 1
0
    def test_lifecycle_2(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()
Ejemplo n.º 2
0
    def test_lifecycle_2(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()
Ejemplo n.º 3
0
    def test_raise_error_join(self):
        def run():
            time.sleep(0.5)
            raise ValueError("raise_error_join")

        thread = Thread(target=run)
        thread.start()
        with self.assertRaises(ValueError):
            thread.join()
Ejemplo n.º 4
0
    def test_success(self):
        q = queue.Queue()
        def run():
            q.put(2)

        thread = Thread(target=run)
        thread.start()
        thread.join()
        self.assertEqual(2, q.get(False)) 
Ejemplo n.º 5
0
    def test_raise_error_start(self):
        def run():
            raise ValueError("raise_error_start")

        thread = Thread(target=run)
        with self.assertRaises(KeyboardInterrupt):
            thread.start()
            while thread.is_alive():
                time.sleep(0.1)

        self.assertIsInstance(thread.exception, ValueError)
Ejemplo n.º 6
0
    def test_raise_error_start(self):
        def run():
            raise ValueError("raise_error_start")

        thread = Thread(target=run)
        with self.assertRaises(KeyboardInterrupt):
            thread.start()
            while thread.is_alive():
                time.sleep(0.1)

        self.assertIsInstance(thread.exception, ValueError)
Ejemplo n.º 7
0
    def test_lifecycle_1(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 1")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        while not thread.exception:
            pass

        pout.v(thread.exception)
Ejemplo n.º 8
0
    def test_lifecycle_1(self):
        def run():
            time.sleep(0.25)
            raise ValueError("lifecycle 1")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        while not thread.exception:
            pass

        pout.v(thread.exception)
Ejemplo n.º 9
0
    def test_raise_error_daemon_join(self):
        def run():
            time.sleep(0.5)
            raise ValueError("raise_error_daemon_join")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()
        with self.assertRaises(ValueError):
            thread.join()
Ejemplo n.º 10
0
    def test_success(self):
        q = queue.Queue()
        def run():
            q.put(2)

        thread = Thread(target=run)
        thread.start()
        thread.join()
        self.assertEqual(2, q.get(False)) 
Ejemplo n.º 11
0
    def test_join_2(self):
        def run():
            time.sleep(0.5)
            raise ValueError("join_2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        try:
            thread.join()

        except ValueError as e:
            self.assertEqual("join_2", str(e))
Ejemplo n.º 12
0
    def test_join_2(self):
        def run():
            time.sleep(0.5)
            raise ValueError("join_2")

        thread = Thread(target=run)
        thread.daemon = True
        thread.start()

        try:
            thread.join()

        except ValueError as e:
            self.assertEqual("join_2", str(e))