<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:10pt"><div id="yiv1168000802" class="" style=""><div class="" style=""><div style="background-color: rgb(255, 255, 255);" class=""><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><span style="font-size: 10pt;" class="">I am a consultant working on some python testing tools for a Java Application.</span><br style=""></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><span style="font-size: 10pt;" class="">I am using Python 2.7, Jython 2.7b2 and Java 7 on Windows 7</span></div><div
 id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><span style="font-size: 10pt;" class=""><br class="" style=""></span></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><span style="background-color: transparent;" class="">Python is the language of choice for test scripting for my customer. &nbsp;</span></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><span style="background-color: transparent;" class="">Some of the tools require calling java classes. &nbsp;&nbsp;</span><span style="background-color:
 transparent;" class="">That is easy enough using Jython. &nbsp;&nbsp;</span></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal; background-color: transparent;" class=""><span class="" style="">But, I am struggling how to get code coverage data for the jython/python code. &nbsp;</span></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal; background-color: transparent;" class=""><span id="yiv1168000802yui_3_16_0_7_1407155359467_28" class="" style=""><br class="" style=""></span></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida
 Grande', sans-serif; font-size: 13px; font-style: normal; background-color: transparent;" class=""><span style="background-color: transparent;" class="">My command line for executing the Unit test is</span><br class="" style=""></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" style="background-color: transparent;" class=""><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;"><span class="" style=""><span class="Apple-tab-span" style="white-space:pre">        </span>java -cp \jython2.7b2\jython.jar org.python.util.jython TestClassForName.py</span></div><div class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;"><br></div><div class="" style="color: rgb(0, 0, 0); font-family:
 HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;">I cannot run coverage.exe against the python/jython below.</div><div class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;">The command line I am using is&nbsp;</div><div class="" style=""><span class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal; white-space: pre;">        </span><span style="background-color: transparent;" class="">coverage run TestClassForName.py</span></div><div class="" style=""><span style="background-color: transparent;" class=""><br class="" style=""></span></div><div class="" style=""><span style="background-color: transparent;" class="">Coverage does work for other python
 unittests</span></div><div class="" style=""><span style="font-size: 10pt; background-color: transparent;">Thanks in advance</span><br></div><div class="" style=""><span style="background-color: transparent;" class=""><div id="yiv1168000802yui_3_16_0_7_1407155359467_8" class="" style="font-size: 10pt;"><br class="" style=""></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_10" class="" style="font-size: 10pt;">C Bannan<br class="" style=""></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_10" class="" style="font-size: 10pt;"><br></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_10" class="" style="font-size: 10pt;"><br></div></span></div><div class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;"><span class="" style="">&lt;code&gt;</span></div><div class="" style="">"""Unit test sample for Jython &nbsp;</div><div class=""
 style="">"""</div><div class="" style="">import unittest</div><div class="" style="">from java.lang import Class</div><div class="" style="">from java.lang import ClassNotFoundException</div><div class="" style=""><br class="" style=""></div><div class="" style="">class TestClassForName(unittest.TestCase):</div><div class="" style=""><br class="" style=""></div><div class="" style="">&nbsp; &nbsp; def test_ShouldFailWithInvalidClassName(self):</div><div class="" style=""><br class="" style=""></div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; return_value = load_class('java.lang.Spring')</div><div class="" style=""><br class="" style=""></div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; self.assertEquals(return_value, 'failure')</div><div class="" style=""><br class="" style=""></div><div class="" style="">&nbsp; &nbsp; def test_ShouldPassWithValidClassName(self):</div><div class="" style=""><br class="" style=""></div><div class=""
 style="">&nbsp; &nbsp; &nbsp; &nbsp; return_value = load_class('java.lang.String')</div><div class="" style=""><br class="" style=""></div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; self.assertEquals(return_value, 'success')</div><div class="" style=""><br class="" style=""></div><div class="" style="">def load_class(class_name):</div><div class="" style="">&nbsp; &nbsp; try:</div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; # for non Java folks, this causes 'class_name' to be loaded</div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; jclass = Class.forName(class_name).newInstance()</div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; return 'success'</div><div class="" style="">&nbsp; &nbsp; except ClassNotFoundException as cnf_excp:</div><div class="" style="">&nbsp; &nbsp; &nbsp; &nbsp; return 'failure' &nbsp; &nbsp; &nbsp; &nbsp;</div><div class="" style=""><br class="" style=""></div><div class="" style="">if __name__ ==
 '__main__':</div><div class="" style="">&nbsp; &nbsp; unittest.main()</div><div class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;"><span class="" style="">&lt;/code&gt;</span></div><div class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; font-style: normal;"><span class="" style="">&nbsp;</span></div></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_6" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"></div><div id="yiv1168000802yui_3_16_0_7_1407155359467_8" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><br class="" style=""></div><div
 id="yiv1168000802yui_3_16_0_7_1407155359467_8" class="" style="color: rgb(0, 0, 0); font-family: HelveticaNeue, 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 10pt;"><div id="yiv1168000802yui_3_16_0_7_1407155359467_4" class="" style=""><br class="" style=""></div></div></div></div></div></div></body></html>