~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/__init__.py

[testfix][r=allenap][ui=none][no-qa] Don't pass a UTF8 decoded stream
        reader to subunit.TestProtocolServer.readFrom().

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    'ZopeTestInSubProcess',
47
47
    ]
48
48
 
49
 
import codecs
50
49
from contextlib import contextmanager
51
50
from datetime import (
52
51
    datetime,
835
834
        if pid == 0:
836
835
            # Child.
837
836
            os.close(pread)
838
 
            fdwrite = os.fdopen(pwrite, 'w', 1)
 
837
            fdwrite = os.fdopen(pwrite, 'wb', 1)
839
838
            # Send results to both the Zope result object (so that
840
839
            # layer setup and teardown are done properly, etc.) and to
841
840
            # the subunit stream client so that the parent process can
853
852
        else:
854
853
            # Parent.
855
854
            os.close(pwrite)
856
 
            fdread = os.fdopen(pread, 'rU')
 
855
            fdread = os.fdopen(pread, 'rb')
857
856
            # Skip all the Zope-specific result stuff by using a
858
857
            # super() of the result. This is because the Zope result
859
858
            # object calls testSetUp() and testTearDown() on the
865
864
            result = super(ZopeTestResult, result)
866
865
            # Accept the result from the child process.
867
866
            protocol = subunit.TestProtocolServer(result)
868
 
            protocol.readFrom(codecs.getreader("utf8")(fdread))
 
867
            protocol.readFrom(fdread)
869
868
            fdread.close()
870
869
            os.waitpid(pid, 0)
871
870