#36491: AttributeError: '_io.TextIOWrapper' object has no attribute 'getvalue'
when
setUpTestData raises and tests are run with –parallel –buffer
-------------------------------------+-------------------------------------
Reporter: Rafael Carlos | Owner: (none)
Soriano Marmol |
Type: Bug | Status: new
Component: Testing framework | Version: 5.2
Severity: Normal | Resolution:
Keywords: tests, parallel, | Triage Stage: Accepted
buffer |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):
* stage: Unreviewed => Accepted
Comment:
Managed to reproduce by using `unitest.TestCase` as well
{{{#!python
from unittest import TestCase
class AbortingTest(TestCase):
@classmethod
def setUpClass(cls):
raise RuntimeError("Boo!")
def test_pass(self):
pass
class AbortingTest2(TestCase):
@classmethod
def setUpClass(cls):
raise RuntimeError("Boo!")
def test_pass(self):
pas
}}}
the problem seems due to the fact that the normal `unittest`
[https://github.com/python/cpython/blob/ade19880943509945da193202ca89e0b2b6fbd75/Lib/unittest/suite.py#L162-L186
suite setup makes sure to] call `TestResutl._setupStdout`
[https://github.com/python/cpython/blob/ade19880943509945da193202ca89e0b2b6fbd75/Lib/unittest/result.py#L65-L71
method] prior to calling `setUpClass` which allows its `addError`
[https://github.com/python/cpython/blob/ade19880943509945da193202ca89e0b2b6fbd75/Lib/unittest/suite.py#L238-L253
handler] to not crash when it takes its `if self.buffer`
[https://github.com/python/cpython/blob/ade19880943509945da193202ca89e0b2b6fbd75/Lib/unittest/result.py#L197-L207
branch] in `_exc_info_to_string.
Given the buffering should happened in spawned worker process and we
basically only use the `TestResult` provided to `ParallelTestSuite.run`
for replicating the events sent from the pool in the main process and
there's no test output to capture on the main process (no tests are run in
the main process) a potential solution could be to simply disable `buffer`
on the accumulator test result.
{{{#!diff
diff --git a/django/test/runner.py b/django/test/runner.py
index 3e5c319ade..a44180b3b6 100644
--- a/django/test/runner.py
+++ b/django/test/runner.py
@@ -561,6 +561,11 @@ def run(self, result):
]
test_results = pool.imap_unordered(self.run_subsuite.__func__,
args)
+ # Disable buffering on the local test result that will accumulate
+ # remote suites results as each process will take care of its own
+ # buffering and there's nothing to capture on the main process.
+ result.buffer = False
+
while True:
if result.shouldStop:
pool.terminate()
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/36491#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 visit
https://groups.google.com/d/msgid/django-updates/01070197d626e68b-55ace8bb-50ce-4aae-a28d-a8beba4001ed-000000%40eu-central-1.amazonses.com.