Skip to content

Commit

Permalink
Update TestConfigInclude._test_passed to support Python 3.11
Browse files Browse the repository at this point in the history
Update snippet from linked page
  • Loading branch information
ijc committed Jan 8, 2023
1 parent eff5df1 commit 74a284c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cmakelang/test/config_include_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ def _list2reason(self, exc_list):

def _test_passed(self):
# Taken from https://stackoverflow.com/a/39606065/141023
if hasattr(self, '_outcome'): # Python 3.4+
# these 2 methods have no side effects
result = self.defaultTestResult()
# pylint: disable=no-member
self._feedErrorsToResult(result, self._outcome.errors)
else: # Python 3.2 - 3.3 or 3.0 - 3.1 and 2.7
result = getattr(
self, '_outcomeForDoCleanups',
self._resultForDoCleanups) # pylint: disable=no-member
if hasattr(self._outcome, 'errors'):
# Python 3.4 - 3.10 (These two methods have no side effects)
result = self.defaultTestResult()
self._feedErrorsToResult(result, self._outcome.errors)
else:
# Python 3.11+
result = self._outcome.result

error = self._list2reason(result.errors)
failure = self._list2reason(result.failures)
Expand Down

0 comments on commit 74a284c

Please sign in to comment.