| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
|
| |
Under Debian, when attempting to run tests, the debian folder
is found and conflicts with this error:
setuptools.errors.PackageDiscoveryError: Multiple top-level packages discovered in a flat-layout: ['debian', 'testtools'].
This patch fixes this (I already applied it in Debian, and it
solved the issue for me).
|
| |
|
|
| |
Not all objects have a __dict__ attribute.
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
| |
The changes for https://peps.python.org/pep-0657/ require a number of
changes in our tests.
Some tests still fail due to
https://twistedmatrix.com/trac/ticket/10336, so I'm not adding
3.11 to the test matrix yet.
Fixes #325.
|
| |\ |
|
| | | |
|
| | | |
|
| |\ \
| |/ |
|
| | | |
|
| |/ |
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Python 3, error messages have become a bit more precise. For
instance, the following code snippet:
----
class Foo():
def bar(self, a):
pass
try:
Foo().bar(1, 2)
except TypeError as e:
print(e)
----
will return:
- in Python 3.9: "bar() takes 2 positional arguments but 3 were given"
- in Python 3.10: "Foo.bar() takes 2 positional arguments but 3 were
given"
Fix our tests accordingly.
|
| |
|
|
|
|
|
| |
This is kept separately from the reintroduction of 'try_imports' to keep
that patch reasonable.
Signed-off-by: Stephen Finucane <stephen@that.guru>
|
| |
|
|
|
|
|
|
|
|
|
|
| |
There are few if any people still (knowingly) using the 'extras' lib.
OpenStack users have their own implementation (sigh) in 'oslo.utils' and
everyone else is getting by with try-except statements. Reintroduce this
utility to 'testtools.helpers', allowing us to eventually drop the
dependency on extras. Note however that we can't actually do this yet
since 'fixtures' has an implicit dependency on 'extras' through
'testtools', and we break that by removing it here.
Signed-off-by: Stephen Finucane <stephen@that.guru>
|
| |
|
|
|
|
|
|
| |
This was being used in places to handle differences between Python 2 and
Python 3. Since we only care about the latter now, the utility can be
removed.
Signed-off-by: Stephen Finucane <stephen@that.guru>
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
This was used to workaround some issues with 'hasattr' on Python 2.x
versions, discussed in the source for extras (where this utility was
moved to make it more useful to others) [1] and elsewhere on the
internet [2]. These issues are no longer present on the versions of
Python we now support (Python 3.6+) so this is no longer necessary.
[1] https://github.com/testing-cabal/extras/blob/1.0.0/extras/__init__.py#L101-L108
[2] https://hynek.me/articles/hasattr/
Signed-off-by: Stephen Finucane <stephen@that.guru>
|
| |\ |
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
On Python 3.9 the zero-width no-break space Unicode character U+FEFF
does not get printed in syntax errors.
See:
https://bugzilla.redhat.com/show_bug.cgi?id=1831126
This is reproducible in a virtual environment as well.
Before:
```
.venv ❯ make check
PYTHONPATH=/home/michel/src/github/testing-cabal/testtools python -m testtools.run testtools.tests.test_suite
/usr/lib64/python3.9/runpy.py:127: RuntimeWarning: 'testtools.run' found in sys.modules after import of package 'testtools', but prior to execution of 'testtools.run'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
Tests running...
======================================================================
FAIL: testtools.tests.test_testresult.TestNonAsciiResults.test_syntax_error_line_utf_8
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/michel/src/github/testing-cabal/testtools/testtools/tests/test_testresult.py", line 2744, in test_syntax_error_line_utf_8
self.assertThat(
File "/home/michel/src/github/testing-cabal/testtools/testtools/testcase.py", line 499, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 'Tests running...\n======================================================================\nERROR: test_syntax_error_line_utf_8.Test.runTest\n----------------------------------------------------------------------\nTraceback (most recent call last):\n File "/tmp/TestNonAsciiResultsblblh75h/test_syntax_error_line_utf_8.py", line 6, in runTest\n import bad\n File "/tmp/TestNonAsciiResultsblblh75h/bad.py", line 1\n \ufeff^ = 0 # paɪθən\n ^\nSyntaxError: invalid syntax\n\nRan 1 test in 0.001s\nFAILED (failures=1)\n' does not match /.*bad.py", line 1\n\s*\^ = 0 # pa\u026a\u03b8\u0259n\n \s*\^\nSyntaxError:.*/
======================================================================
FAIL: testtools.tests.test_testresult.TestNonAsciiResultsWithUnittest.test_syntax_error_line_utf_8
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/michel/src/github/testing-cabal/testtools/testtools/tests/test_testresult.py", line 2744, in test_syntax_error_line_utf_8
self.assertThat(
File "/home/michel/src/github/testing-cabal/testtools/testtools/testcase.py", line 499, in assertThat
raise mismatch_error
testtools.matchers._impl.MismatchError: 'E\n======================================================================\nERROR: runTest (test_syntax_error_line_utf_8.Test)\ntest_syntax_error_line_utf_8.Test.runTest\n----------------------------------------------------------------------\ntesttools.testresult.real._StringException: Traceback (most recent call last):\n File "/tmp/TestNonAsciiResultsWithUnittest_zzswpmj/test_syntax_error_line_utf_8.py", line 6, in runTest\n import bad\n File "/tmp/TestNonAsciiResultsWithUnittest_zzswpmj/bad.py", line 1\n \ufeff^ = 0 # paɪθən\n ^\nSyntaxError: invalid syntax\n\n\n----------------------------------------------------------------------\nRan 1 test in 0.000s\n\nFAILED (errors=1)\n' does not match /.*bad.py", line 1\n\s*\^ = 0 # pa\u026a\u03b8\u0259n\n \s*\^\nSyntaxError:.*/
Ran 2627 tests in 0.569s
FAILED (failures=2)
make: *** [Makefile:7: check] Error 1
```
After:
```
.venv ❯ make check
PYTHONPATH=/home/michel/src/github/testing-cabal/testtools python -m testtools.run testtools.tests.test_suite
/usr/lib64/python3.9/runpy.py:127: RuntimeWarning: 'testtools.run' found in sys.modules after import of package 'testtools', but prior to execution of 'testtools.run'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
Tests running...
Ran 2627 tests in 0.492s
OK
```
|
| |\ \
| |/ |
|
| | |\ |
|
| | | |\ |
|
| | | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
In unittest/unittest2 the skip/skipIf/skipUnless decorators can be used to
decorate either individual test methods or entire TestCase classes.
However, the testtools equivalents could previously only be used to
decorate test methods. If used on a TestCase the class would be replaced
with a function, resulting in the tests either not be discovered at all or
(if a custom test loader was used) potentially an error.
This change allows the skip decorators to be used on the TestCase subclass,
for equivalent functionality with unittest.
Fixes #205
Signed-off-by: Zane Bitter <zbitter@redhat.com>
|
| | | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
All of the python versions we support have functools.wraps(), so there is
no need to have a soft import for it any more (indeed, we use it
unconditionally elsewhere).
Also, avoid modifying the attributes of the function passed in and relying
on functools.wraps() to copy them to the function we're actually returning.
Just add the attributes to the substitute function and return it as the
user is probably expecting.
Signed-off-by: Zane Bitter <zbitter@redhat.com>
|
| | | | | |
|
| | | | | |
|
| | | | | |
|
| | | | | |
|
| | | |/
| |/| |
|
| |\ \ \
| |/ / |
|
| | | | |
|
| | |/
| |
| |
| |
| |
| |
| | |
eval() has security implications so security scanners such as Bandit warn about
the use of eval(). In the context of the test suite where eval() is used there
are no security problems, but changing to ast.literal_eval is trivial so do it
anyway.
|
| |/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Currently testtools bases all of it's unittest extensions off of
unittest2 instead of the stdlib unittest. At one point this made sense
since unittest2 provided a stable base as unittest in stdlib added
features. But it's been ~5 years since there was a unittest2 release
(or a patch merged) and things have changed since then. The best
example of this is of the supported python versions listed in the
unittest2 project description/README only one is still supported by
upstream python, 2.7, which goes end of life at the end of this year.
More specific to testtools the use of unittest2 causes a whole slew of
issues because of differences in behavior with stdlib unittest. For
example here a couple issues encountered:
https://bugs.launchpad.net/testtools/+bug/1467558
https://bugs.launchpad.net/testtools/+bug/1417803
mtreinish/stestr#238
testing-cabal/testtools#272
which are caused, at least in part, by unittest2. There are likely other
bugs related to it that haven't been reported (or I just missed/forgot
about). At this point it's better to remove the unittest2 usage and just
rely on the upstream stdlib unittest which if nothing else is actively
maintained. It'll improve compatibility using the testtools runner with
stdlib unittest test suites and removes the class of bugs caused by the differences in unittest2.
Fixes #263
|
| |
|
|
|
|
| |
Exception's repr got changed not to include trailing comma
Fixes https://github.com/testing-cabal/testtools/issues/270
|
| | |
|
| | |
|
| | |
|
| |
|
| |
https://docs.python.org/3/whatsnew/3.6.html#deprecated-python-behavior
|
| |
|
|
|
| |
integration (#243)
This new decorator implements the TestResult protocol extension supported by test resources. For example, tt makes it possible to easily have resource-related events streamed to subunit.
|
| |
|
|
| |
Make KeysEqual usable with no arguments, i.e. match a dict with no keys.
|
| |
|
|
|
| |
In the test record API, skip adding file details to the record if there
are not bytes. This reduces that amount of data kept when there is none.
|
| | |
|
| | |
|
| |
|
|
|
|
|
|
|
| |
This provides a way to make it easier to test with
unicode text strings. The value returned will be like
TestCase.getUniqueString but the value is six.text_type
and contains unicode.
Change-Id: I3f144e1294a801b23793f7a2520465e15f3a5222
|
| |
|
|
|
|
|
|
|
| |
Previously, when gathering details caused by a setUp failure,
a traceback occurred if the fixture used the newer _setUp().
This also had the side effect of not clearing up fixtures properly.
Change-Id: I9d138e8d559e176867c6e3f4b89f784cf4d29f05
Fixes: https://bugs.launchpad.net/testtools/+bug/1469759
|
| |
|
|
|
|
| |
When we get a suspected KeyboardInterrupt (no result from Deferred),
explicitly stop the result and report the error as if it were a user
error.
|
| |
|
|
|
|
|
|
|
| |
* Move test code to testtools.tests.twistedsupport, to parallel matchers
* Add testtools.deferredruntest to preserve backwards compatibility
* Move NeedsTwistedTestCase out of test_spinner into shared module for
Twisted tests
Closes #202
|
| |
|
|
|
|
| |
This reverts commit e571d9c25ff280a21bb879a9c4c264ef233dc9a2.
Travis CI was failing before merge.
|
| |
|
|
|
|
|
| |
* Move test code to testtools.tests.twistedsupport, to parallel matchers
* Add testtools.deferredruntest to preserve backwards compatibility
* Move NeedsTwistedTestCase out of test_spinner into shared module for
Twisted tests
|
| | |
|