/usr/lib/python2.7/dist-packages/nose2/tests/functional/test_junitxml_plugin.py is in python-nose2 0.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | import os
from nose2.tests._common import FunctionalTestCase
from nose2.tests._common import TestCase
from nose2.tests._common import support_file
class JunitXmlPluginFunctionalTest(FunctionalTestCase, TestCase):
_RUN_IN_TEMP = True
def run_with_junitxml_loaded(self, scenario, *args):
work_dir = os.getcwd()
test_dir = support_file(*scenario)
junit_report = os.path.join(work_dir, 'nose2-junit.xml')
if os.path.exists(junit_report):
os.remove(junit_report)
proc = self.runIn(work_dir,
'-s%s' % test_dir,
'--plugin=nose2.plugins.junitxml',
'-v',
*args)
return junit_report, proc
def test_invocation_by_double_dash_option(self):
junit_report, proc = self.run_with_junitxml_loaded(
('scenario', 'junitxml', 'happyday'),
'--junit-xml')
self.assertTestRunOutputMatches(
proc, stderr='test \(test_junitxml_happyday.Test\) ... ok')
self.assertTestRunOutputMatches(
proc, stderr='Ran 1 test')
self.assertEqual(proc.poll(), 0)
self.assertTrue(os.path.isfile(junit_report),
"junitxml report wasn't found in working directory. "
"Searched for " + junit_report)
def test_invocation_by_single_dash_option(self):
junit_report, proc = self.run_with_junitxml_loaded(
('scenario', 'junitxml', 'happyday'),
'-X')
self.assertTestRunOutputMatches(
proc, stderr='test \(test_junitxml_happyday.Test\) ... ok')
self.assertTestRunOutputMatches(
proc, stderr='Ran 1 test')
self.assertEqual(proc.poll(), 0)
self.assertTrue(os.path.isfile(junit_report),
"junitxml report wasn't found in working directory. "
"Searched for " + junit_report)
def test_no_report_written_if_loaded_but_not_invoked(self):
junit_report, proc = self.run_with_junitxml_loaded(
('scenario', 'junitxml', 'happyday'))
self.assertTestRunOutputMatches(
proc, stderr='test \(test_junitxml_happyday.Test\) ... ok')
self.assertTestRunOutputMatches(
proc, stderr='Ran 1 test')
self.assertEqual(proc.poll(), 0)
self.assertFalse(os.path.isfile(junit_report),
"junitxml report was found in working directory. "
"Report file: " + junit_report)
def test_report_location_should_be_resilent_to_chdir_in_tests(self):
junit_report, proc = self.run_with_junitxml_loaded(
('scenario', 'junitxml', 'chdir'), '--junit-xml')
self.assertTestRunOutputMatches(
proc,
stderr='test_chdir \(test_junitxml_chdir.Test\) \.* ok')
self.assertTestRunOutputMatches(
proc, stderr='Ran 1 test')
self.assertEqual(proc.poll(), 0)
self.assertTrue(os.path.isfile(junit_report),
"junitxml report wasn't found in working directory. "
"Searched for " + junit_report)
class JunitXmlPluginFunctionalFailureTest(FunctionalTestCase, TestCase):
def test_failure_to_write_report(self):
proc = self.runIn('scenario/junitxml/fail_to_write',
'--plugin=nose2.plugins.junitxml',
'-v',
'--junit-xml')
self.assertEqual(proc.poll(), 1)
self.assertTestRunOutputMatches(
proc,
stderr='test \(test_junitxml_fail_to_write.Test\) \.* ok')
self.assertTestRunOutputMatches(
proc, stderr=r'Internal Error: runTests aborted: \[Errno 2\] JUnitXML: Parent folder does not exist for file: \'/does/not/exist\.xml\'')
|