summaryrefslogtreecommitdiff
path: root/python/samba/subunit/run.py
AgeCommit message (Collapse)AuthorFilesLines
2026-04-07subunit: Do not return successful exit code if tests fail or errorJennifer Sutton1-32/+28
TestProtocolClient.writeOutcome() removed items from self.errors and self.failures via TestProtocolClient._filterErrors(). This made wasSuccessful() inappropriately return True even if there were errors or failures. subunit.run.runTests() uses wasSuccessful() to determine the exit code. To fix this, do not remove items from self.errors or self.failures, but instead use indices to keep track of how many items we have already processed in each of self.errors and self.failures. This fixes a regression introduced by commit 421dc7fc4d83629d3a5f9e558d378f44c7b9dad3. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15691 Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz> Autobuild-User(master): Gary Lockyer <gary@samba.org> Autobuild-Date(master): Tue Apr 7 04:17:08 UTC 2026 on atb-devel-224
2026-04-07selftest: Add keywords arguments to addDuration() methodJennifer Sutton1-2/+2
Without these, the type checker complains: Method "addDuration" overrides class "TestResult" in an incompatible manner. Signed-off-by: Jennifer Sutton <jennifersutton@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2026-01-15python subunit: add dummy addDuration methodsDouglas Bagnall1-0/+6
preventing this message: /usr/lib/python3.12/unittest/case.py:580: RuntimeWarning: TestResult has no addDuration method warnings.warn("TestResult has no addDuration method", as far as I can tell we have no real use for addDuration, since we already measure time in other ways. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
2023-12-15python: use python3 style super statementsRob van der Linde1-4/+4
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-13python:subunit: Use now() instead of utcnow()Joseph Sutton1-1/+1
utcnow() is deprecated and will be removed in a future version of Python. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-21python:subunit: Use ‘is’ to compare variables with singletonsJoseph Sutton1-4/+4
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-08-21python:subunit: Fix docstringJoseph Sutton1-1/+1
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-06-23python:samba:subunit: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-11python:subunit: Avoid misleading "Test was never started" error messageJoseph Sutton1-67/+84
subunithelper.py keeps track of tests that have been started, and displays an error message if a test reports an outcome without having previously been started. However, it makes the assumption that a test has finished once it has reported a single outcome. This means that a misleading error message will be displayed if it receives multiple outcomes from the same test (which can happen if a test using the Python unittest framework does not complete successfully, and the cleanup subsequently fails), and any actual errors from the cleanup remain undisplayed. This commit ensures that only a single outcome is reported for each test, and only after the test has finished. Outcomes are buffered up until the stopTest() function is called, when a single outcome is determined and all errors received for that test are output. FilterOps still needs to output test outcomes immediately rather than buffering them, otherwise they are never picked up and passed on to the remote test case by subunithelper.parse_results(). This would result in an error as the test would be considered to have never finished. Example subunitrun output before the change: time: 2021-04-28 01:28:49.862123Z test: samba.tests.example.ExampleTests.test time: 2021-04-28 01:28:49.862215Z failure: samba.tests.example.ExampleTests.test [ Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 28, in test self.fail() AssertionError: None ] time: 2021-04-28 01:28:49.862407Z failure: samba.tests.example.ExampleTests.test [ Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 31, in tearDown self.fail() AssertionError: None ] time: 2021-04-28 01:28:49.862467Z time: 2021-04-28 01:28:49.862510Z and after: time: 2021-04-28 01:29:19.949347Z test: samba.tests.example.ExampleTests.test time: 2021-04-28 01:29:19.949440Z time: 2021-04-28 01:29:19.949590Z time: 2021-04-28 01:29:19.949640Z failure: samba.tests.example.ExampleTests.test [ Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 28, in test self.fail() AssertionError: None Traceback (most recent call last): File "bin/python/samba/tests/example.py", line 31, in tearDown self.fail() AssertionError: None ] time: 2021-04-28 01:29:19.949702Z Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-11python:subunit: Remove write_traceback()Joseph Sutton1-44/+7
This functionality is already present in the Python unittest framework, and so is not necessary to include here. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-06-11python:subunit: Fix skipping a test with no reason givenJoseph Sutton1-2/+2
Not specifying a reason means addSkip() is passed an empty string rather than None. As a result, this condition was never hit, and the call to _addOutcome() had an incorrect parameter. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2021-02-02python:subunit: Use UTC timezone from datatime moduleAndreas Schneider1-4/+2
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2019-03-07subunit/run.py: change shebang to python3Joe Guo1-1/+1
always use explicit python version at current stage. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org> Autobuild-User(master): Noel Power <npower@samba.org> Autobuild-Date(master): Thu Mar 7 13:03:56 UTC 2019 on sn-devel-144
2019-03-07subunit/run.py: make iso8601 UTC usage python 2/3 compatibleJoe Guo1-3/+3
In `iso8601/iso8601.py`: if sys.version_info >= (3, 2, 0): UTC = datetime.timezone.utc ... else: class Utc(datetime.tzinfo): ... UTC = Utc() The class `Utc` is only available for python < 3.2.0. Use `UTC` instance instead, which is python 2/3 compatible. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2018-04-13python: bulk replace file to open for py3Joe Guo1-1/+1
The builtin function `file` was removed in py3. Use `open` instead. Signed-off-by: Joe Guo <joeg@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
2018-02-09subunit.run: report failure in process return codeDouglas Bagnall1-0/+7
The protocol requires that the TestResult object remembers when it has failed, but in subclassing unittest.TestResult we forgot to ensure this is true. Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2016-12-01python: samba.subunit.run: Fix Python 3 compatibility.Lumir Balhar1-8/+2
Usage of function _test_id() which generates test id in bytes breaks Python 3 compatibility. After fix, this function is not used any more. Signed-off-by: Lumir Balhar <lbalhar@redhat.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
2015-03-06Drop support for failfast mode, rather than adding support for it everywhere.Jelmer Vernooij1-38/+7
Change-Id: I4d6070a0e3b89d5e390f84754dddba9ec17ddf21 Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-03-06Import UTC definition from utc8601 module.Jelmer Vernooij1-3/+3
Change-Id: I3ccd81090c4721b161aff272100aa71bc2f17055 Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-03-06Set default testRunner rather than requiring the user pass it in.Jelmer Vernooij1-2/+3
Change-Id: I8b5a5925030049975a83b090e5c7b76d5245c07d Signed-Off-By: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-03-06Use Samba-only subunit module in selftest/tests/.Jelmer Vernooij1-19/+2
Change-Id: I48c61f975c1fa49f6e244ad39dd720fe507db45b Signed-off-by: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2015-03-06Add simple subunit runner outputting subunit v1.Jelmer Vernooij1-0/+750
This is a short module (< 1k lines) that removes the need to depend on subunit, testtools, extras and mimeparse. It is based on an extract from testtools and subunit. Change-Id: I0a4f3060b25f7bde602a07ed6bef71c8196fca64 Signed-Off-By: Jelmer Vernooij <jelmer@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>