#32140: `startTest` result hook not called until after tests already started
when
`--parallel` used
-------------------------------------+-------------------------------------
Reporter: Bob Whitelock | Owner: nobody
Type: Bug | Status: new
Component: Testing framework | Version: 3.1
Severity: Normal | Resolution:
Keywords: startTest parallel | Triage Stage:
test runner | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Adam (Chainz) Johnson):
The reason this happens is that custom result classes aren't used in the
parallel processes, but instead `RemoteTestResult`, which mostly holds
onto the result to send it back to the main process for display. In theory
it's possible to change how that works, and might even allow the `--debug-
sql` and `--pdb` options work with `--parallel`, but it might require a
little thought.
If you're trying to do something before a test begins, you can also
override `TestCase._callTestMethod`, for example to capture output:
{{{
class ExampleTestMixin:
def _callTestMethod(self, method):
try:
out = StringIO()
err = StringIO()
with mock.patch.object(sys, "stdout", new=out),
mock.patch.object(
sys, "stderr", new=err
):
super()._callTestMethod(method)
except Exception:
print(out.getvalue(), end="")
print(err.getvalue(), end="", file=sys.stderr)
raise
class SimpleTestCase(ExampleTestMixin, test.SimpleTestCase):
pass
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32140#comment:3>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.ecf1ac3dee1cf4bab2530d320beff45f%40djangoproject.com.