Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 62 lines (51 sloc) 2.364 kB
5030cee @pjenvey o mark Skipped tests with <skipped> testcase tags and include the Exc…
pjenvey authored
1 # -*- coding: utf-8 -*-
4cc5045 @kumar303 Fixes test code when run in a python 3 that was compiled with ascii e…
kumar303 authored
2 import codecs
c5bd034 @jpellerin Committed PyCon sprint work.
jpellerin authored
3 import os
4cc5045 @kumar303 Fixes test code when run in a python 3 that was compiled with ascii e…
kumar303 authored
4 import sys
c5bd034 @jpellerin Committed PyCon sprint work.
jpellerin authored
5 import unittest
6 from nose.plugins.xunit import Xunit
7 from nose.plugins.skip import Skip
8 from nose.plugins import PluginTester
9
10 support = os.path.join(os.path.dirname(__file__), 'support')
11 xml_results_filename = os.path.join(support, "xunit.xml")
12
13 # the plugin is tested better in unit tests.
14 # this is just here for a sanity check
15
16 class TestXUnitPlugin(PluginTester, unittest.TestCase):
17 activate = '--with-xunit'
18 args = ['-v','--xunit-file=%s' % xml_results_filename]
19 plugins = [Xunit(), Skip()]
20 suitepath = os.path.join(support, 'xunit')
21
22 def runTest(self):
23 print str(self.output)
24
25 assert "ERROR: test_error" in self.output
26 assert "FAIL: test_fail" in self.output
27 assert "test_skip (test_xunit_as_suite.TestForXunit) ... SKIP: skipit" in self.output
28 assert "XML: %s" % xml_results_filename in self.output
29
4cc5045 @kumar303 Fixes test code when run in a python 3 that was compiled with ascii e…
kumar303 authored
30 f = codecs.open(xml_results_filename,'r', encoding='utf8')
c5bd034 @jpellerin Committed PyCon sprint work.
jpellerin authored
31 result = f.read()
32 f.close()
4cc5045 @kumar303 Fixes test code when run in a python 3 that was compiled with ascii e…
kumar303 authored
33 print result.encode('utf8', 'replace')
c5bd034 @jpellerin Committed PyCon sprint work.
jpellerin authored
34
35 assert '<?xml version="1.0" encoding="UTF-8"?>' in result
5030cee @pjenvey o mark Skipped tests with <skipped> testcase tags and include the Exc…
pjenvey authored
36 assert '<testsuite name="nosetests" tests="6" errors="2" failures="1" skip="1">' in result
4f679be @kumar303 Xunit plugin now shows test run time in fractions of a second (#317)
kumar303 authored
37 assert '<testcase classname="test_xunit_as_suite.TestForXunit" name="test_error" time="' in result
4cc5045 @kumar303 Fixes test code when run in a python 3 that was compiled with ascii e…
kumar303 authored
38 # TODO(Kumar) think of better x-platform code here that
39 # does not confuse 2to3
40 if sys.version_info[0:2] >= (3,0):
41 assert ('<error type="%s.Exception" message="日本">' % (Exception.__module__,)) in result
42 else:
43 assert ('<error type="%s.Exception" message="日本">' % (Exception.__module__,)).decode('utf8') in result
c5bd034 @jpellerin Committed PyCon sprint work.
jpellerin authored
44 assert '</testcase>' in result
95a044e @jpellerin Added test for issue279
jpellerin authored
45 assert '</testsuite>' in result
46
47
48 class TestIssue279(PluginTester, unittest.TestCase):
49 activate = '--with-xunit'
50 args = ['-v','--xunit-file=%s' % xml_results_filename]
51 plugins = [Xunit(), Skip()]
52 suitepath = os.path.join(support, 'issue279')
53
54 def runTest(self):
55 print str(self.output)
56 f = open(xml_results_filename,'r')
57 result = f.read()
58 f.close()
59 print result
60 assert 'tests="1" errors="1" failures="0" skip="0"' in result
61 assert "Exception: I would prefer not to" in result
Something went wrong with that request. Please try again.