[TIP] Cannot run coverage.exe against the jython
Chris Bannan
cmbannan at yahoo.com
Mon Aug 4 12:26:13 PDT 2014
How careless of me. My apology.
Here is the command and result.
C:\cygwin64\home\cbannan\python>coverage run TestClassForName.py
Traceback (most recent call last):
File "TestClassForName.py", line 6, in <module>
from java.lang import Class
ImportError: No module named java.lang
Chris
cmbannan at yahoo.com
________________________________
From: "testing-in-python-request at lists.idyll.org" <testing-in-python-request at lists.idyll.org>
To: testing-in-python at lists.idyll.org
Sent: Monday, August 4, 2014 11:18 AM
Subject: testing-in-python Digest, Vol 91, Issue 2
Send testing-in-python mailing list submissions to
testing-in-python at lists.idyll.org
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.idyll.org/listinfo/testing-in-python
or, via email, send a message with subject or body 'help' to
testing-in-python-request at lists.idyll.org
You can reach the person managing the list at
testing-in-python-owner at lists.idyll.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of testing-in-python digest..."
Today's Topics:
1. testfixtures 4.0.1 Released! (Chris Withers)
2. Cannot run coverage.exe against the jython (Chris Bannan)
3. Re: Cannot run coverage.exe against the jython (Ned Batchelder)
----------------------------------------------------------------------
Message: 1
Date: Mon, 04 Aug 2014 12:43:29 +0100
From: Chris Withers <chris at simplistix.co.uk>
Subject: [TIP] testfixtures 4.0.1 Released!
To: testing-in-python at lists.idyll.org, Python List
<python-list at python.org>, simplistix at googlegroups.com
Message-ID: <53DF71E1.8050506 at simplistix.co.uk>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hi All,
I'm pleased to announce the release of testfixtures 4.0.1. This is a
bugfix release that fixes the following two edge cases:
- Fix bugs when string compared equal and options to compare()
were used.
- Fix bug when strictly comparing two nested structures containing
identical objects.
The package is on PyPI and a full list of all the links to docs, issue
trackers and the like can be found here:
http://www.simplistix.co.uk/software/python/testfixtures
Any questions, please do ask on the Testing in Python list or on the
Simplistix open source mailing list...
cheers,
Chris
--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk
------------------------------
Message: 2
Date: Mon, 4 Aug 2014 07:19:51 -0700
From: Chris Bannan <cmbannan at yahoo.com>
Subject: [TIP] Cannot run coverage.exe against the jython
To: "testing-in-python at lists.idyll.org"
<testing-in-python at lists.idyll.org>
Message-ID:
<1407161991.89490.YahooMailNeo at web142405.mail.bf1.yahoo.com>
Content-Type: text/plain; charset="iso-8859-1"
I am a consultant working on some python testing tools for a Java Application.
I am using Python 2.7, Jython 2.7b2 and Java 7 on Windows 7
Python is the language of choice for test scripting for my customer. ?
Some of the tools require calling java classes. ??That is easy enough using Jython. ??
But, I am struggling how to get code coverage data for the jython/python code. ?
My command line for executing the Unit test is
java -cp \jython2.7b2\jython.jar org.python.util.jython TestClassForName.py
I cannot run coverage.exe against the python/jython below.
The command line I am using is?
coverage run TestClassForName.py
Coverage does work for other python unittests
Thanks in advance
C Bannan
<code>
"""Unit test sample for Jython ?
"""
import unittest
from java.lang import Class
from java.lang import ClassNotFoundException
class TestClassForName(unittest.TestCase):
? ? def test_ShouldFailWithInvalidClassName(self):
? ? ? ? return_value = load_class('java.lang.Spring')
? ? ? ? self.assertEquals(return_value, 'failure')
? ? def test_ShouldPassWithValidClassName(self):
? ? ? ? return_value = load_class('java.lang.String')
? ? ? ? self.assertEquals(return_value, 'success')
def load_class(class_name):
? ? try:
? ? ? ? # for non Java folks, this causes 'class_name' to be loaded
? ? ? ? jclass = Class.forName(class_name).newInstance()
? ? ? ? return 'success'
? ? except ClassNotFoundException as cnf_excp:
? ? ? ? return 'failure' ? ? ? ?
if __name__ == '__main__':
? ? unittest.main()
</code>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140804/07db1829/attachment.htm>
------------------------------
Message: 3
Date: Mon, 04 Aug 2014 11:18:33 -0400
From: Ned Batchelder <ned at nedbatchelder.com>
Subject: Re: [TIP] Cannot run coverage.exe against the jython
To: testing-in-python at lists.idyll.org
Message-ID: <53DFA449.2090002 at nedbatchelder.com>
Content-Type: text/plain; charset="iso-8859-1"; Format="flowed"
On 8/4/14 10:19 AM, Chris Bannan wrote:
> I am a consultant working on some python testing tools for a Java
> Application.
> I am using Python 2.7, Jython 2.7b2 and Java 7 on Windows 7
>
> Python is the language of choice for test scripting for my customer.
> Some of the tools require calling java classes. That is easy enough
> using Jython.
> But, I am struggling how to get code coverage data for the
> jython/python code.
>
> My command line for executing the Unit test is
> java -cp \jython2.7b2\jython.jar org.python.util.jython
> TestClassForName.py
>
> I cannot run coverage.exe against the python/jython below.
> The command line I am using is
> coverage run TestClassForName.py
>
You show the command you're running, but you haven't shown what
happens. How doesn't it work?
> Coverage does work for other python unittests
> Thanks in advance
>
> C Bannan
>
>
> <code>
> """Unit test sample for Jython
> """
> import unittest
> from java.lang import Class
> from java.lang import ClassNotFoundException
>
> class TestClassForName(unittest.TestCase):
>
> def test_ShouldFailWithInvalidClassName(self):
>
> return_value = load_class('java.lang.Spring')
>
> self.assertEquals(return_value, 'failure')
>
> def test_ShouldPassWithValidClassName(self):
>
> return_value = load_class('java.lang.String')
>
> self.assertEquals(return_value, 'success')
>
> def load_class(class_name):
> try:
> # for non Java folks, this causes 'class_name' to be loaded
> jclass = Class.forName(class_name).newInstance()
> return 'success'
> except ClassNotFoundException as cnf_excp:
> return 'failure'
>
> if __name__ == '__main__':
> unittest.main()
> </code>
>
>
>
>
> _______________________________________________
> testing-in-python mailing list
> testing-in-python at lists.idyll.org
> http://lists.idyll.org/listinfo/testing-in-python
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140804/ff761e2d/attachment.htm>
------------------------------
_______________________________________________
testing-in-python mailing list
testing-in-python at lists.idyll.org
http://lists.idyll.org/listinfo/testing-in-python
End of testing-in-python Digest, Vol 91, Issue 2
************************************************
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20140804/44d0c6b3/attachment-0001.htm>
More information about the testing-in-python
mailing list