Thread.run() isn't measured · Issue #85 · nedbat/coveragepy (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@nedbat

Description

@nedbat

In this code:

import Queue
import threading
import unittest

class TestThread(threading.Thread):
    def __init__(self, started_queue, stopping_queue):
        threading.Thread.__init__(self)
        self._started_queue = started_queue
        self._stopping_queue = stopping_queue

    def run(self):
        print "starting thread"
        self.fooey()
        self._started_queue.put('')
        msg = self._stopping_queue.get()
        print "exiting thread"

    def fooey(self):
        print "fooey"
        self.booey()
        print "fooey out:"

    def booey(self):
        print "booey"

class ThreadTest(unittest.TestCase):
    def test_threads(self):
        starting_queue = Queue.Queue()
        stopping_queue = Queue.Queue()
        thd = TestThread(starting_queue, stopping_queue)
        stopping_queue.put('')
        thd.start()
        starting_queue.get()
        thd.join()
        self.assertTrue(True)

if __name__ == '__main__':
    unittest.main()

run() is marked as not covered, but fooey() and booey() are. What's up with that?