summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-salttesting
diff options
context:
space:
mode:
authorzangrc <zangrc.fnst@cn.fujitsu.com>2020-11-23 23:00:19 +0800
committerBruce Ashfield <bruce.ashfield@gmail.com>2020-12-01 16:27:22 -0500
commit4520f75b1c7a1c0c5eed275b67d787fb0913dc42 (patch)
tree878d9cd9db4ce3631b888302c600ca8acfb7da2b /meta-openstack/recipes-devtools/python/python-salttesting
parent93ccc3db29dbac229e6b16e9b25287e8634fcf1a (diff)
downloadmeta-cloud-services-4520f75b1c7a1c0c5eed275b67d787fb0913dc42.tar.gz
python3-salttesting: upgrade 2015.2.16 -> 2018.9.21
Refresh the following patch: 0001-Add-ptest-output-option-to-test-suite.patch Signed-off-by: Zang Ruochen <zangrc.fnst@cn.fujitsu.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-salttesting')
-rw-r--r--meta-openstack/recipes-devtools/python/python-salttesting/0001-Add-ptest-output-option-to-test-suite.patch229
1 files changed, 0 insertions, 229 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-salttesting/0001-Add-ptest-output-option-to-test-suite.patch b/meta-openstack/recipes-devtools/python/python-salttesting/0001-Add-ptest-output-option-to-test-suite.patch
deleted file mode 100644
index e86768a..0000000
--- a/meta-openstack/recipes-devtools/python/python-salttesting/0001-Add-ptest-output-option-to-test-suite.patch
+++ /dev/null
@@ -1,229 +0,0 @@
1From 1950b943b7173198f345a1cff7b7f771cbac2244 Mon Sep 17 00:00:00 2001
2From: Collin Richards <collin.richards@ni.com>
3Date: Tue, 28 Jun 2016 16:02:22 -0500
4Subject: [PATCH] Add ptest output option to test suite
5
6Extend salttesting to support outputing the results of running the test
7suite in ptest format.
8
9Upstream-Status: Inappropriate [OE specific]
10
11Signed-off-by: Collin Richards <collin.richards@ni.com>
12Natinst-ReviewBoard-ID: 143279
13---
14 salttesting/parser/__init__.py | 12 +++
15 salttesting/ptest.py | 165 +++++++++++++++++++++++++++++++++++++++++
16 2 files changed, 177 insertions(+)
17 create mode 100644 salttesting/ptest.py
18
19diff --git a/salttesting/parser/__init__.py b/salttesting/parser/__init__.py
20index 1e7275b..d8cba0c 100644
21--- a/salttesting/parser/__init__.py
22+++ b/salttesting/parser/__init__.py
23@@ -25,6 +25,7 @@ from functools import partial
24 from contextlib import closing
25
26 from salttesting import TestLoader, TextTestRunner
27+from salttesting.ptest import PTestRunner
28 from salttesting.version import __version_info__
29 from salttesting.xmlunit import HAS_XMLRUNNER, XMLTestRunner
30 try:
31@@ -264,6 +265,12 @@ class SaltTestingParser(optparse.OptionParser):
32 action='store_true',
33 help='Do NOT show the overall tests result'
34 )
35+ self.output_options_group.add_option(
36+ '--ptest-out',
37+ dest='ptest_out',
38+ default=False,
39+ help='Output test results in PTest format'
40+ )
41 self.add_option_group(self.output_options_group)
42
43 self.fs_cleanup_options_group = optparse.OptionGroup(
44@@ -491,6 +498,11 @@ class SaltTestingParser(optparse.OptionParser):
45 verbosity=self.options.verbosity
46 ).run(tests)
47 self.testsuite_results.append((header, runner))
48+ elif self.options.ptest_out:
49+ runner = PTestRunner(
50+ stream=sys.stdout,
51+ verbosity=self.options.verbosity).run(tests)
52+ self.testsuite_results.append((header, runner))
53 else:
54 runner = TextTestRunner(
55 stream=sys.stdout,
56diff --git a/salttesting/ptest.py b/salttesting/ptest.py
57new file mode 100644
58index 0000000..4c50f57
59--- /dev/null
60+++ b/salttesting/ptest.py
61@@ -0,0 +1,165 @@
62+# -*- coding: utf-8 -*-
63+
64+"""
65+Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
66+2011, 2012, 2013, 2014, 2015, 2016 Python Software Foundation; All Rights
67+Reserved
68+
69+PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
70+--------------------------------------------
71+
72+1. This LICENSE AGREEMENT is between the Python Software Foundation
73+("PSF"), and the Individual or Organization ("Licensee") accessing and
74+otherwise using this software ("Python") in source or binary form and
75+its associated documentation.
76+
77+2. Subject to the terms and conditions of this License Agreement, PSF hereby
78+grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
79+analyze, test, perform and/or display publicly, prepare derivative works,
80+distribute, and otherwise use Python alone or in any derivative version,
81+provided, however, that PSF's License Agreement and PSF's notice of copyright,
82+i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
83+2011, 2012, 2013, 2014, 2015, 2016 Python Software Foundation; All Rights
84+Reserved" are retained in Python alone or in any derivative version prepared by
85+Licensee.
86+
87+3. In the event Licensee prepares a derivative work that is based on
88+or incorporates Python or any part thereof, and wants to make
89+the derivative work available to others as provided herein, then
90+Licensee hereby agrees to include in any such work a brief summary of
91+the changes made to Python.
92+
93+4. PSF is making Python available to Licensee on an "AS IS"
94+basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
95+IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
96+DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
97+FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
98+INFRINGE ANY THIRD PARTY RIGHTS.
99+
100+5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
101+FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
102+A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
103+OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
104+
105+6. This License Agreement will automatically terminate upon a material
106+breach of its terms and conditions.
107+
108+7. Nothing in this License Agreement shall be deemed to create any
109+relationship of agency, partnership, or joint venture between PSF and
110+Licensee. This License Agreement does not grant permission to use PSF
111+trademarks or trade name in a trademark sense to endorse or promote
112+products or services of Licensee, or any third party.
113+
114+8. By copying, installing or otherwise using Python, Licensee
115+agrees to be bound by the terms and conditions of this License
116+Agreement.
117+
118+Modified Version of Python's TextTestRunner
119+"""
120+
121+import time
122+import sys
123+import string
124+
125+import unittest
126+TestResult = unittest.TestResult
127+
128+
129+class _WritelnDecorator(object):
130+ """Used to decorate file-like objects with a handy 'writeln' method"""
131+ def __init__(self, stream):
132+ self.stream = stream
133+
134+ def __getattr__(self, attr):
135+ if attr in ('stream', '__getstate__'):
136+ raise AttributeError(attr)
137+ return getattr(self.stream, attr)
138+
139+ def writeln(self, arg=None):
140+ if arg:
141+ self.write(arg)
142+ self.write('\n') # text-mode streams translate to \r\n if needed
143+
144+
145+class _PTestResult(TestResult):
146+ """A test result class that can print formatted text results to a stream.
147+
148+ Used by PTestRunner.
149+ """
150+ separator1 = '=' * 70
151+ separator2 = '-' * 70
152+
153+ def __init__(self, stream, descriptions, verbosity):
154+ TestResult.__init__(self)
155+ self.stream = stream
156+ self.showAll = verbosity > 1
157+ self.dots = verbosity == 1
158+ self.descriptions = descriptions
159+
160+ def getDescription(self, test):
161+ return str(test)
162+
163+ def startTest(self, test):
164+ TestResult.startTest(self, test)
165+
166+ def addSuccess(self, test):
167+ TestResult.addSuccess(self, test)
168+ if self.showAll:
169+ self.stream.writeln("PASS: {0}".format(self.getDescription(test)))
170+ elif self.dots:
171+ self.stream.write('.')
172+
173+ def addError(self, test, err):
174+ TestResult.addError(self, test, err)
175+ if self.showAll:
176+ self.stream.writeln("FAIL: ERROR {0}".format(self.getDescription(test)))
177+ elif self.dots:
178+ self.stream.write('E')
179+
180+ def addFailure(self, test, err):
181+ TestResult.addFailure(self, test, err)
182+ if self.showAll:
183+ self.stream.writeln("FAIL: {0}".format(self.getDescription(test)))
184+ elif self.dots:
185+ self.stream.write('F')
186+
187+ def printErrors(self):
188+ if self.dots or self.showAll:
189+ self.stream.writeln()
190+ self.printErrorList('ERROR', self.errors)
191+ self.printErrorList('FAIL', self.failures)
192+
193+ def printErrorList(self, flavour, errors):
194+ for test, err in errors:
195+ self.stream.writeln(self.separator1)
196+ self.stream.writeln("{0}: {0}".format(flavour, self.getDescription(test)))
197+ self.stream.writeln(self.separator2)
198+ self.stream.writeln("{0}".format(err))
199+
200+
201+class PTestRunner:
202+ """A test runner class that displays results in PTest format.
203+
204+ """
205+ def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1):
206+ self.stream = _WritelnDecorator(stream)
207+ self.descriptions = descriptions
208+ self.verbosity = 2
209+
210+ def _makeResult(self):
211+ return _PTestResult(self.stream, self.descriptions, self.verbosity)
212+
213+ def run(self, test):
214+ "Run the given test case or test suite."
215+ result = self._makeResult()
216+ startTime = time.time()
217+ test(result)
218+ stopTime = time.time()
219+ timeTaken = float(stopTime - startTime)
220+ result.printErrors()
221+ run = result.testsRun
222+ self.stream.writeln("Ran %d test%s in %.3fs" %
223+ (run, run == 1 and "" or "s", timeTaken))
224+ self.stream.writeln(result.separator2)
225+ self.stream.writeln()
226+ return result
227--
2282.13.2
229