I apologize for a cross post from http://stackoverflow.com/q/43991865/1653558 but it looks like this is a better place for the report
I'm getting some low coverage numbers on script with threads activated with a run() method. It seems that the coverage module is unable to keep track of all hits. Here is the code that demonstrates the problem. Running it should produce 100% coverage, but I'm getting 71.
from threading import Thread class MyNestedThread(Thread): def run(self): print("hello from the nested thread!") class MyThread(Thread): def run(self): print("Hello from thread") t = MyNestedThread() t.start() return if __name__ == '__main__': for i in range(3): t = MyThread() t.start()
Hello from thread hello from the nested thread! Hello from thread Hello from thread hello from the nested thread! hello from the nested thread! Name Stmts Miss Cover ---------------------------- foo.py 14 4 71%
re-running 'coverage run foo.py' sometimes gives a different %, and even 100% on occasion.