generating results from python unittest problem

the_transporter

Limp Gawd
Joined
Aug 19, 2004
Messages
223
I created a class (i.e. results.py) that generates a HTML file based on the results produced by a test class, say test.py

Every time a test method is run in test.py, it will add the test method name to a pass or fail list (depending on the result) in generate.py

The only problem I have is that every time a test method is run in test.py, it will create a new instance of generate.py. So essentially the final HTML file that is created only contains the results of the last run test. I am having trouble getting all the test cases to use the same instance of generate.py.

Any idea on how to avoid this problem? What would be the correct way to implement some notion of global in the test.py?

Thank you
 
Well, you could us a global variable in your test script & then iterate over that when you finish writing all your tests. You could open generate.py in append mode ('w+'). You could make a results display object that needs an explicit writeFile() called on it.

Ther'es plenty of different ways to do it.
 
Back
Top