Hello community,
here is the log from the commit of package python-junitxml for openSUSE:Factory checked in at 2012-12-03 11:21:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-junitxml (Old)
and /work/SRC/openSUSE:Factory/.python-junitxml.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-junitxml", Maintainer is ""
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-junitxml/python-junitxml.changes 2012-03-27 08:58:04.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.python-junitxml.new/python-junitxml.changes 2012-12-03 11:21:25.000000000 +0100
@@ -1,0 +2,14 @@
+Fri Nov 30 14:31:48 UTC 2012 - toddrme2178@gmail.com
+
+- Add missing executable
+
+-------------------------------------------------------------------
+Fri Nov 23 11:10:24 UTC 2012 - saschpe@suse.de
+
+- Update to version 0.7:
+ + Added a .testr.conf file for running tests with testrepository.
+ + Change from skip to skipped to fit the 'standard' better.
+ + There is now a runner compatible with the unittest2 command line options, for
+ easy 'just give me XML' usage.
+
+-------------------------------------------------------------------
Old:
----
junitxml-0.6.tar.gz
New:
----
junitxml-0.7.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-junitxml.spec ++++++
--- /var/tmp/diff_new_pack.hVtMNO/_old 2012-12-03 11:21:26.000000000 +0100
+++ /var/tmp/diff_new_pack.hVtMNO/_new 2012-12-03 11:21:26.000000000 +0100
@@ -11,12 +11,13 @@
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
-#
+
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
+
Name: python-junitxml
-Version: 0.6
+Version: 0.7
Release: 0
Url: https://launchpad.net/pyjunitxml
Summary: A pyunit extension to output JUnit compatible XML
@@ -25,6 +26,7 @@
Source: http://pypi.python.org/packages/source/j/junitxml/junitxml-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: python-devel
+BuildRequires: python-nose
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%else
@@ -43,9 +45,14 @@
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
+#TODO: Fix, doesn't run:
+#%%check
+#nosetests
+
%files
%defattr(-,root,root,-)
%doc COPYING README
+%{_bindir}/pyjunitxml
%{python_sitelib}/*
%changelog
++++++ junitxml-0.6.tar.gz -> junitxml-0.7.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/.bzrignore new/junitxml-0.7/.bzrignore
--- old/junitxml-0.6/.bzrignore 2009-12-12 13:45:23.000000000 +0100
+++ new/junitxml-0.7/.bzrignore 2011-12-03 08:28:04.000000000 +0100
@@ -1 +1,3 @@
dist
+./MANIFEST
+./.testrepository
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/NEWS new/junitxml-0.7/NEWS
--- old/junitxml-0.6/NEWS 2010-09-12 00:33:16.000000000 +0200
+++ new/junitxml-0.7/NEWS 2012-11-18 21:54:08.000000000 +0100
@@ -1,6 +1,17 @@
NEXT
====
+0.7
+===
+
+* Added a .testr.conf file for running tests with testrepository.
+
+* Change from skip to skipped to fit the 'standard' better.
+ (Leo Arias, #982293)
+
+* There is now a runner compatible with the unittest2 command line options, for
+ easy 'just give me XML' usage. (Duncan Findlay)
+
0.6
===
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/PKG-INFO new/junitxml-0.7/PKG-INFO
--- old/junitxml-0.6/PKG-INFO 2010-09-12 00:34:07.000000000 +0200
+++ new/junitxml-0.7/PKG-INFO 2012-11-18 21:55:43.000000000 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: junitxml
-Version: 0.6
+Version: 0.7
Summary: PyJUnitXML, a pyunit extension to output JUnit compatible XML.
Home-page: https://launchpad.net/pyjunitxml
Author: Robert Collins
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/README new/junitxml-0.7/README
--- old/junitxml-0.6/README 2009-08-01 09:45:38.000000000 +0200
+++ new/junitxml-0.7/README 2011-12-07 17:55:37.000000000 +0100
@@ -33,6 +33,16 @@
``stopTestRun`` method is not being invoked, and you will need to arrange for it
to be invoked.
+There is a command line runner you can use::
+
+ $ python -m junitxml.main discover
+
+or
+
+ $ junitxml discover
+
+If the package scripts have been installed.
+
Troubleshooting
---------------
@@ -55,6 +65,9 @@
$ python -m subunit.run junitxml.test_suite | subunit2gtk
+If you have testrepository you can simply run testr::
+
+ $ testr run
Enjoy,
Rob Collins
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/__init__.py new/junitxml-0.7/junitxml/__init__.py
--- old/junitxml-0.6/junitxml/__init__.py 2010-09-12 00:33:34.000000000 +0200
+++ new/junitxml-0.7/junitxml/__init__.py 2012-11-18 21:54:24.000000000 +0100
@@ -9,8 +9,11 @@
import datetime
import re
-import time
-import unittest
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
# same format as sys.version_info: "A tuple containing the five components of
# the version number: major, minor, micro, releaselevel, and serial. All
@@ -23,7 +26,7 @@
# established at this point, and setup.py will use a version of next-$(revno).
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
# Otherwise it is major.minor.micro~$(revno).
-__version__ = (0, 6, 0, 'final', 0)
+__version__ = (0, 7, 0, 'final', 0)
def test_suite():
@@ -89,7 +92,7 @@
class JUnitXmlResult(unittest.TestResult):
"""A TestResult which outputs JUnit compatible XML."""
-
+
def __init__(self, stream):
"""Create a JUnitXmlResult.
@@ -198,7 +201,7 @@
pass
self._test_case_string(test)
self._results.append('>\n')
- self._results.append('<skip>%s</skip>\n</testcase>\n'% _escape_attr(reason))
+ self._results.append('<skipped>%s</skipped>\n</testcase>\n'% _escape_attr(reason))
def addUnexpectedSuccess(self, test):
try:
@@ -219,3 +222,6 @@
self._test_case_string(test)
self._results.append('/>\n')
+if __name__ == '__main__':
+ import junitxml.main
+ junitxml.main.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/__main__.py new/junitxml-0.7/junitxml/__main__.py
--- old/junitxml-0.6/junitxml/__main__.py 1970-01-01 01:00:00.000000000 +0100
+++ new/junitxml-0.7/junitxml/__main__.py 2011-12-03 08:56:22.000000000 +0100
@@ -0,0 +1,12 @@
+"""Command line functionality for junitxml.
+
+:Author: Duncan Findlay
+"""
+import sys
+
+import junitxml.main
+
+if __name__ == '__main__':
+ if sys.argv[0].endswith('__main__.py'):
+ sys.argv[0] = 'python -m junitxml'
+ junitxml.main.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/main.py new/junitxml-0.7/junitxml/main.py
--- old/junitxml-0.6/junitxml/main.py 1970-01-01 01:00:00.000000000 +0100
+++ new/junitxml-0.7/junitxml/main.py 2011-12-03 08:56:22.000000000 +0100
@@ -0,0 +1,167 @@
+"""Command line functionality for junitxml.
+
+Runs specific tests or does automatic discovery with output in XML format.
+
+:Author: Duncan Findlay
+"""
+import optparse
+import sys
+
+# If we're using Python < 2.7, we want unittest2 if we can get it, otherwise
+# unittest will suffice.
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+import junitxml
+import junitxml.runner
+
+ADDITIONAL_HELP_NO_DISCOVERY = """\
+
+<xml file> is the name of a file used for output.
+<tests> is a list of any number of test modules, classes and test
+methods. If no tests are specified, automatic discovery is performed.
+
+Example for executing specific tests:
+ %(prog_name)s -o junit.xml test_module
+ %(prog_name)s test_module.TestClass
+ %(prog_name)s test_module.TestClass.test_method
+"""
+
+ADDITIONAL_HELP_DISCOVERY = """\
+
+<xml file> is the name of a file used for output.
+[tests] can be a list of any number of test modules, classes and test
+methods. If no tests are specified, automatic discovery is performed.
+
+Example for executing specific tests:
+ %(prog_name)s -o junit.xml test_module
+ %(prog_name)s test_module.TestClass
+ %(prog_name)s test_module.TestClass.test_method
+
+Example for test discovery:
+ %(prog_name)s
+ %(prog_name)s -o junit.xml -s tests/ -p '*.py'
+ %(prog_name)s -t myproj/ -s myproj/tests/ -p '*.py'
+
+For test discovery all test modules must be importable from the top
+level directory of the project.
+
+It is an error to specify discovery options and specific tests.
+"""
+
+class XmlTestProgram(object):
+ """Command line program for running tests with XML output."""
+
+ loader = unittest.defaultTestLoader
+ runner_class = junitxml.runner.JUnitXmlTestRunner
+
+ def __init__(self, can_discover=None):
+ self.tests = None
+ self.output_filename = None
+
+ self._can_discover = can_discover
+ if self._can_discover is None:
+ self._can_discover = bool(hasattr(self.loader, 'discover'))
+
+ if self._can_discover:
+ self._usage = 'Usage: %prog [options] [tests]'
+ self._help = ADDITIONAL_HELP_DISCOVERY
+ else:
+ self._usage = 'Usage: %prog [options] <tests>'
+ self._help = ADDITIONAL_HELP_NO_DISCOVERY
+
+ def parse_args(self, argv=None):
+ """Parse command line arguments."""
+ parser = optparse.OptionParser(
+ usage=self._usage, add_help_option=False)
+
+ parser.add_option('-h', '--help', dest='help', action='store_true',
+ help='Show option summary and exit')
+ parser.add_option(
+ '-o', '--output-file', dest='output',
+ help='Specify name of output XML file. (Default: %default)',
+ default='./junit.xml')
+
+ if self._can_discover:
+ discovery_group = optparse.OptionGroup(
+ parser, 'Discovery options',
+ 'Used to control discovery (when no tests specified).')
+
+ discovery_group.add_option(
+ '-s', '--start-directory', dest='start',
+ default=None, help="Directory to start discovery "
+ "('.' default)")
+ discovery_group.add_option(
+ '-p', '--pattern', dest='pattern', default=None,
+ help="Pattern to match tests ('test*.py' default)")
+ discovery_group.add_option(
+ '-t', '--top-level-directory', dest='top', default=None,
+ help='Top level directory of project (defaults to start '
+ 'directory)')
+ parser.add_option_group(discovery_group)
+
+ if argv is None:
+ argv = sys.argv[1:]
+ options, args = parser.parse_args(argv)
+
+ if options.help:
+ parser.print_help()
+ sys.stdout.write(self._help % ({'prog_name': sys.argv[0]}))
+ sys.exit(1)
+
+ self.output_filename = options.output
+
+ if self._can_discover and args and \
+ (options.start or options.pattern or options.top):
+ parser.error(
+ 'Cannot specify discovery options and specific tests.')
+ elif args:
+ self.tests = self._load_tests(args)
+ elif self._can_discover:
+ self.tests = self._do_discovery(options.start, options.pattern,
+ options.top)
+ else:
+ parser.error('Must specify tests to run.')
+
+ def _do_discovery(self, start_dir, pattern, top_level_dir):
+ assert self._can_discover
+
+ if start_dir is None:
+ start_dir = '.'
+ if pattern is None:
+ pattern = 'test*.py'
+ if top_level_dir is None:
+ top_level_dir = start_dir
+
+ return self.loader.discover(start_dir, pattern, top_level_dir)
+
+ def _load_tests(self, test_names):
+ return self.loader.loadTestsFromNames(test_names)
+
+ def run(self):
+ """Run the specified tests.
+
+ :Returns: TestResult object.
+ """
+ stream = open(self.output_filename, 'w')
+ try:
+ test_runner = self.runner_class(xml_stream=stream)
+ return test_runner.run(self.tests)
+ finally:
+ stream.close()
+
+
+def main(args=None, prog=None):
+ if args is None:
+ args = sys.argv[1:]
+ if prog is None:
+ prog = XmlTestProgram()
+
+ prog.parse_args(args)
+ result = prog.run()
+ sys.exit(int(not result.wasSuccessful()))
+
+if __name__ == '__main__':
+ main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/runner.py new/junitxml-0.7/junitxml/runner.py
--- old/junitxml-0.6/junitxml/runner.py 1970-01-01 01:00:00.000000000 +0100
+++ new/junitxml-0.7/junitxml/runner.py 2011-12-03 08:56:22.000000000 +0100
@@ -0,0 +1,71 @@
+"""Simple Test Runner for XML output.
+
+Writes XML output and reports test status to stderr.
+
+:Author: Duncan Findlay
+"""
+import sys
+import time
+
+import junitxml
+
+class JUnitXmlTestRunner(object):
+
+ """Simple Test Runner that writes XML output and reports status.
+
+ Provides high-level status suitable for command-line operation as well as
+ XML output.
+ """
+
+ resultclass = junitxml.JUnitXmlResult
+
+ def __init__(self, xml_stream, txt_stream=None, **kwargs):
+ if txt_stream is None:
+ txt_stream = sys.stderr
+ self._txt_stream = txt_stream
+ self._xml_stream = xml_stream
+
+ def _make_result(self):
+ return self.resultclass(self._xml_stream)
+
+ def run(self, test):
+ result = self._make_result()
+ result.startTestRun()
+
+ start_time = time.time()
+ test.run(result)
+ end_time = time.time()
+
+ result.stopTestRun()
+
+ self._write_summary(result, end_time - start_time)
+ return result
+
+ def _write_summary(self, result, time_elapsed):
+
+ plural = ''
+ if result.testsRun != 1:
+ plural = 's'
+
+ self._txt_stream.write('Ran %d test%s in %.3fs\n\n' %
+ (result.testsRun, plural, time_elapsed))
+ test_info = []
+
+ for result_attr, desc in (
+ ('failures', 'failures'), ('errors', 'errors'),
+ ('skipped', 'skipped'), ('expectedFailures', 'expected failures'),
+ ('unexpectedSuccesses', 'unexpected successes')):
+
+ num = len(getattr(result, result_attr, []))
+ if num > 0:
+ test_info.append('%s=%s' % (desc, num))
+
+ test_info_str = ''
+ if test_info:
+ test_info_str = ' (%s)' % (', '.join(test_info),)
+
+ if result.wasSuccessful():
+ self._txt_stream.write('OK%s\n' % (test_info_str,))
+ else:
+ self._txt_stream.write('FAILED%s\n' % (test_info_str,))
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/tests/__init__.py new/junitxml-0.7/junitxml/tests/__init__.py
--- old/junitxml-0.6/junitxml/tests/__init__.py 2009-08-01 08:37:48.000000000 +0200
+++ new/junitxml-0.7/junitxml/tests/__init__.py 2011-12-03 08:56:22.000000000 +0100
@@ -8,9 +8,17 @@
from junitxml.tests import (
test_junitxml,
+ test_main,
+ test_runner
)
def test_suite():
return unittest.TestLoader().loadTestsFromNames([
'junitxml.tests.test_junitxml',
+ 'junitxml.tests.test_main',
+ 'junitxml.tests.test_runner'
])
+
+if __name__ == '__main__':
+ suite = test_suite()
+ unittest.TextTestRunner(verbosity=2).run(suite)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/tests/test_junitxml.py new/junitxml-0.7/junitxml/tests/test_junitxml.py
--- old/junitxml-0.6/junitxml/tests/test_junitxml.py 2010-09-12 00:29:09.000000000 +0200
+++ new/junitxml-0.7/junitxml/tests/test_junitxml.py 2011-12-03 08:56:22.000000000 +0100
@@ -12,9 +12,13 @@
import datetime
import re
import sys
-import unittest
import xml.dom.minidom
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
import junitxml
class TestImports(unittest.TestCase):
@@ -155,7 +159,7 @@
output = self.get_output()
expected = """<testsuite errors="0" failures="0" name="" tests="1" time="0.000">
<testcase classname="junitxml.tests.test_junitxml.Skips" name="test_me" time="0.000">
-<skip>yo</skip>
+<skipped>yo</skipped>
</testcase>
</testsuite>
"""
@@ -262,7 +266,7 @@
doc = self._run_and_parse_test(SkipWithLt())
if self.has_skip:
self.assertEqual('2.7 <= version',
- doc.getElementsByTagName("skip")[0].firstChild.nodeValue)
+ doc.getElementsByTagName("skipped")[0].firstChild.nodeValue)
else:
self.assertTrue(
doc.getElementsByTagName("failure")[0].firstChild.nodeValue
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/tests/test_main.py new/junitxml-0.7/junitxml/tests/test_main.py
--- old/junitxml-0.6/junitxml/tests/test_main.py 1970-01-01 01:00:00.000000000 +0100
+++ new/junitxml-0.7/junitxml/tests/test_main.py 2011-12-03 08:56:59.000000000 +0100
@@ -0,0 +1,194 @@
+"""Test "main" functionality for junitxml.
+
+:Author: Duncan Findlay
+"""
+import os
+import shutil
+import sys
+import tempfile
+import xml.dom.minidom
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from io import StringIO
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+import junitxml.main
+
+def _skip_if(condition):
+ """Decorator for skipping tests no matter what version of unittest."""
+ if condition:
+ def decorator(func):
+ if hasattr(unittest, 'skip'):
+ # If we don't have discovery, we probably don't skip, but we'll
+ # try anyways...
+ return unittest.skip('Discovery not supported.')(func)
+ else:
+ return None
+ return decorator
+ else:
+ # Condition is false, return the do-nothing decorator.
+ def decorator(func):
+ return func
+ return decorator
+
+
+class FakeLoader(object):
+ """Fake TestLoader to stub out test loading."""
+
+ def discover(self, start_dir, pattern=None, top_level_dir=None):
+ self._did_discovery = (start_dir, pattern, top_level_dir)
+ return unittest.TestSuite()
+
+ def loadTestsFromNames(self, names, module=None):
+ self._loaded_tests = (names, module)
+ return unittest.TestSuite()
+
+
+class RedirectedTestCase(unittest.TestCase):
+
+ """Redirects test output away from stdout/stderr."""
+
+ def setUp(self):
+ self._stderr = StringIO()
+ self._stdout = StringIO()
+ self._old_stderr = sys.stderr
+ self._old_stdout = sys.stdout
+ sys.stderr = self._stderr
+ sys.stdout = self._stdout
+
+ def tearDown(self):
+ sys.stderr = self._old_stderr
+ sys.stdout = self._old_stdout
+
+
+class TestArgs(RedirectedTestCase):
+
+ def _test_bad_args(self, args, can_discover=None):
+ # XmlTestPrograrm uses some magic to figure out whether it can do test
+ # discovery. We want to manually control that, sometimes.
+ try:
+ if can_discover is not None:
+ prog = junitxml.main.XmlTestProgram(can_discover=can_discover)
+ junitxml.main.main(args, prog=prog)
+ else:
+ junitxml.main.main(args)
+ self.fail('No exception thrown')
+ except SystemExit:
+ e = sys.exc_info()[1]
+ self.assertEqual(e.code, 2, self._stderr.getvalue())
+ except:
+ self.fail('No SystemExit exception thrown')
+
+ def test_bad_opts(self):
+ """Bad option combinations are rejected."""
+ # Mix of tests and discovery opts.
+ self._test_bad_args(['-s', '..', 'my_test'])
+ self._test_bad_args(['-p', 'foo*.py', 'my_test'])
+ self._test_bad_args(['-t', '..', 'my_test'])
+ self._test_bad_args(['--top', '..', 'my_test'])
+
+ # Incomplete options.
+ self._test_bad_args(['-o'])
+ self._test_bad_args(['-p'])
+ self._test_bad_args(['-s'])
+ self._test_bad_args(['-t'])
+
+ def test_help(self):
+ """Help is displayed with --help."""
+ try:
+ junitxml.main.main(['--help'])
+ except SystemExit:
+ e = sys.exc_info()[1]
+ self.assertEqual(e.code, 1)
+ except:
+ self.fail('No SystemExit exception thrown.')
+ self.assertTrue('Example ' in self._stdout.getvalue())
+
+ def test_no_discovery(self):
+ """Discovery options are rejected if discovery is not available."""
+ self._test_bad_args([], can_discover=False)
+ self._test_bad_args(['-s', '..'], can_discover=False)
+ self._test_bad_args(['-t', '..'], can_discover=False)
+ self._test_bad_args(['-p', '*.*'], can_discover=False)
+
+
+class TestLoad(RedirectedTestCase):
+
+ def setUp(self):
+ super(TestLoad, self).setUp()
+ self._tmpdir = tempfile.mkdtemp(prefix='unittest_junitxml_')
+ self._output_file = os.path.join(self._tmpdir, 'junit.xml')
+
+ def tearDown(self):
+ super(TestLoad, self).tearDown()
+ shutil.rmtree(self._tmpdir)
+
+ def test_loaded_tests(self):
+ """Verify named tests are properly loaded."""
+ prog = junitxml.main.XmlTestProgram()
+ prog.loader = FakeLoader()
+ prog.parse_args(['-o', self._output_file, 'my_test1', 'my_test2'])
+ result = prog.run()
+
+ document = xml.dom.minidom.parse(self._output_file)
+ self.assertEqual(document.documentElement.tagName, 'testsuite')
+ self.assertEqual(document.documentElement.getAttribute('tests'), '0')
+
+ self.assertEqual(result.wasSuccessful(), True)
+ self.assertTrue(hasattr(prog.loader, '_loaded_tests'))
+ self.assertEqual(prog.loader._loaded_tests,
+ (['my_test1', 'my_test2'], None))
+
+ def test_discovery_all_args(self):
+ """Verify cmdline opts are used for discovery."""
+ prog = junitxml.main.XmlTestProgram(can_discover=True)
+ prog.loader = FakeLoader()
+ prog.parse_args(['-o', self._output_file, '-s', self._tmpdir,
+ '--pattern', '*.py', '-t', '.'])
+ result = prog.run()
+
+ document = xml.dom.minidom.parse(self._output_file)
+ self.assertEqual(document.documentElement.tagName, 'testsuite')
+ self.assertEqual(document.documentElement.getAttribute('tests'), '0')
+
+ self.assertEqual(result.wasSuccessful(), True)
+ self.assertTrue(hasattr(prog.loader, '_did_discovery'))
+ self.assertEqual(prog.loader._did_discovery,
+ (self._tmpdir, '*.py', '.'))
+
+ def test_discovery_top_dir(self):
+ """Verify top-level dir properly defaults to start directory."""
+ prog = junitxml.main.XmlTestProgram(can_discover=True)
+ prog.loader = FakeLoader()
+ prog.parse_args(['-o', self._output_file, '--start-dir', self._tmpdir])
+ result = prog.run()
+
+ document = xml.dom.minidom.parse(self._output_file)
+ self.assertEqual(document.documentElement.tagName, 'testsuite')
+ self.assertEqual(document.documentElement.getAttribute('tests'), '0')
+
+ self.assertEqual(result.wasSuccessful(), True)
+ self.assertTrue(hasattr(prog.loader, '_did_discovery'))
+ self.assertEqual(prog.loader._did_discovery,
+ (self._tmpdir, 'test*.py', self._tmpdir))
+
+ def test_discovery_no_args(self):
+ """Verify good defaults are used for discovery when not specified."""
+ prog = junitxml.main.XmlTestProgram(can_discover=True)
+ prog.loader = FakeLoader()
+ prog.parse_args(['-o', self._output_file])
+ result = prog.run()
+
+ document = xml.dom.minidom.parse(self._output_file)
+ self.assertEqual(document.documentElement.tagName, 'testsuite')
+ self.assertEqual(document.documentElement.getAttribute('tests'), '0')
+
+ self.assertEqual(result.wasSuccessful(), True)
+ self.assertTrue(hasattr(prog.loader, '_did_discovery'))
+ self.assertEqual(prog.loader._did_discovery,
+ ('.', 'test*.py', '.'))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/junitxml/tests/test_runner.py new/junitxml-0.7/junitxml/tests/test_runner.py
--- old/junitxml-0.6/junitxml/tests/test_runner.py 1970-01-01 01:00:00.000000000 +0100
+++ new/junitxml-0.7/junitxml/tests/test_runner.py 2011-12-03 08:57:05.000000000 +0100
@@ -0,0 +1,115 @@
+"""Test XmlTestRunner functionality for junitxml.
+
+:Author: Duncan Findlay
+"""
+import xml.dom.minidom
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from io import StringIO
+
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+
+import junitxml.runner
+
+
+# Old versions of unittest don't have these "fancy" types of results.
+_FANCY_UNITTEST = (hasattr(unittest, 'skip') and
+ hasattr(unittest, 'expectedFailure'))
+
+
+class TestXMLTestRunner(unittest.TestCase):
+
+ class DummyTestCase(unittest.TestCase):
+
+ def test_pass(self):
+ pass
+
+ def test_fail(self):
+ self.fail()
+
+ def test_error(self):
+ raise Exception()
+
+ if _FANCY_UNITTEST:
+
+ @unittest.skip('skipped')
+ def test_skip(self):
+ pass
+
+ @unittest.expectedFailure
+ def test_xfail(self):
+ self.fail('all is good')
+
+ @unittest.expectedFailure
+ def test_unexpected_success(self):
+ pass
+
+ def _run_runner(self, test_suite):
+ xml_out = StringIO()
+ console = StringIO()
+
+ runner = junitxml.runner.JUnitXmlTestRunner(
+ xml_stream=xml_out, txt_stream=console)
+ result = runner.run(test_suite)
+
+ return (result, xml_out, console)
+
+ def test_xml_output(self):
+ """Tests that runner properly gives XML output."""
+ test_suite = unittest.TestLoader().loadTestsFromTestCase(
+ self.DummyTestCase)
+
+ result, xml_out, console = self._run_runner(test_suite)
+
+ num_tests = test_suite.countTestCases()
+
+ # Make sure the XML output looks correct.
+ value = xml_out.getvalue()
+ document = xml.dom.minidom.parseString(value)
+
+ self.assertEqual(document.documentElement.tagName, 'testsuite')
+ self.assertEqual(document.documentElement.getAttribute('tests'),
+ str(num_tests))
+
+ def test_console_output_fail(self):
+ """Tests that failure is reported properly on stderr."""
+ test_suite = unittest.TestLoader().loadTestsFromTestCase(
+ self.DummyTestCase)
+
+ result, xml_out, console = self._run_runner(test_suite)
+
+ num_tests = test_suite.countTestCases()
+
+ # Make sure the console output looks correct.
+ value = console.getvalue()
+ self.assertTrue('Ran %d tests in ' % (num_tests,) in value,
+ 'Output was:\n%s' % (value,))
+ self.assertTrue('FAILED (failures=1' in value,
+ 'Output was:\n%s' % (value,))
+ self.assertTrue('errors=1' in value,
+ 'Output was:\n%s' % (value,))
+
+ if _FANCY_UNITTEST:
+ self.assertTrue('expected failures=1' in value,
+ 'Output was:\n%s' % (value,))
+ self.assertTrue('skipped=1' in value,
+ 'Output was:\n%s' % (value,))
+ self.assertTrue('unexpected successes=1' in value,
+ 'Output was:\n%s' % (value,))
+
+ def test_console_output_ok(self):
+ """Tests that success is reported properly on stderr."""
+ test_suite = unittest.TestSuite()
+ test_suite.addTest(self.DummyTestCase('test_pass'))
+
+ result, xml_out, console = self._run_runner(test_suite)
+
+ value = console.getvalue()
+ self.assertTrue('Ran 1 test in ' in value,
+ 'Output was:\n%s' % (value,))
+ self.assertTrue('OK\n' in value,
+ 'Output was:\n%s' % (value,))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/pyjunitxml new/junitxml-0.7/pyjunitxml
--- old/junitxml-0.6/pyjunitxml 1970-01-01 01:00:00.000000000 +0100
+++ new/junitxml-0.7/pyjunitxml 2011-12-07 17:54:58.000000000 +0100
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+"""Script to run unit tests under junitxml."""
+
+if __name__ == '__main__':
+ import junitxml.main
+ junitxml.main.main()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/junitxml-0.6/setup.py new/junitxml-0.7/setup.py
--- old/junitxml-0.6/setup.py 2010-09-12 00:33:22.000000000 +0200
+++ new/junitxml-0.7/setup.py 2012-11-18 21:54:14.000000000 +0100
@@ -3,11 +3,12 @@
from distutils.core import setup
setup(name="junitxml",
- version="0.6",
+ version="0.7",
description="PyJUnitXML, a pyunit extension to output JUnit compatible XML.",
maintainer="Robert Collins",
maintainer_email="robertc@robertcollins.net",
url="https://launchpad.net/pyjunitxml",
packages=['junitxml', 'junitxml.tests'],
+ scripts=['pyjunitxml'],
license="LGPL-3",
)
--
To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org
For additional commands, e-mail: opensuse-commit+help@opensuse.org