Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

texttestresult should decorate the stream with _WritelnDecorator #60943

Open
elopio mannequin opened this issue Dec 20, 2012 · 4 comments
Open

texttestresult should decorate the stream with _WritelnDecorator #60943

elopio mannequin opened this issue Dec 20, 2012 · 4 comments
Assignees
Labels
3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@elopio
Copy link
Mannequin

elopio mannequin commented Dec 20, 2012

BPO 16739
Nosy @voidspace, @ElOpio
Files
  • fix-16739-texttestresult_writeln.patch: patch
  • fix-16739-texttestresult_writeln-v2.patch: patch that doesn't decorate a stream that doesn't need it
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/voidspace'
    closed_at = None
    created_at = <Date 2012-12-20.16:16:21.815>
    labels = ['3.7', '3.8', '3.9', '3.10', 'type-feature', 'library']
    title = 'texttestresult should decorate the stream with _WritelnDecorator'
    updated_at = <Date 2020-05-31.12:49:41.048>
    user = 'https://github.com/elopio'

    bugs.python.org fields:

    activity = <Date 2020-05-31.12:49:41.048>
    actor = 'serhiy.storchaka'
    assignee = 'michael.foord'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2012-12-20.16:16:21.815>
    creator = 'elopio'
    dependencies = []
    files = ['28379', '28536']
    hgrepos = []
    issue_num = 16739
    keywords = ['patch']
    message_count = 4.0
    messages = ['177833', '177841', '177845', '178865']
    nosy_count = 2.0
    nosy_names = ['michael.foord', 'elopio']
    pr_nums = []
    priority = 'normal'
    resolution = None
    stage = None
    status = 'open'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue16739'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']

    @elopio
    Copy link
    Mannequin Author

    elopio mannequin commented Dec 20, 2012

    Using the unittest's texttestresult with stdout and verbosity 2 will fail because that stream doesn't have a writeln method.

    File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
    File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
    File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
    File "/usr/lib/python2.7/unittest/suite.py", line 70, in __call__
    return self.run(*args, **kwds)
    File "/usr/lib/python2.7/unittest/suite.py", line 108, in run
    test(result)
    File "/usr/lib/python2.7/dist-packages/unittest2/case.py", line 398, in __call__
    return self.run(*args, **kwds)
    File "/usr/lib/python2.7/dist-packages/unittest2/case.py", line 375, in run
    result.addSuccess(self)
    File "/home/elopio/canonical/ubuntuone/photos-acceptance-2/lib/testtools/testresult/real.py", line 253, in addSuccess
    return self._dispatch('addSuccess', test, details=details)
    File "/home/elopio/canonical/ubuntuone/photos-acceptance-2/lib/testtools/testresult/real.py", line 231, in _dispatch
    for result in self._results)
    File "/home/elopio/canonical/ubuntuone/photos-acceptance-2/lib/testtools/testresult/real.py", line 231, in <genexpr>
    for result in self._results)
    File "/home/elopio/canonical/ubuntuone/photos-acceptance-2/lib/testtools/testresult/real.py", line 555, in addSuccess
    return self.decorated.addSuccess(test)
    File "/usr/lib/python2.7/unittest/runner.py", line 60, in addSuccess
    self.stream.writeln("ok")
    AttributeError: 'file' object has no attribute 'writeln'

    It would be nice if the stream is decorated with _WritelnDecorator, as it is done on TextTestRunner.

    @elopio elopio mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Dec 20, 2012
    @elopio
    Copy link
    Mannequin Author

    elopio mannequin commented Dec 20, 2012

    A test with a fix.

    I'm not sure if this is the way to go, because the stream in TextTestRunner will be decorated twice.

    @voidspace
    Copy link
    Contributor

    TextTestResult could decorate a raw stream (and not redecorate an already decorated one).

    @voidspace voidspace self-assigned this Dec 20, 2012
    @elopio
    Copy link
    Mannequin Author

    elopio mannequin commented Jan 3, 2013

    What if we check if the stream has the writeln method?

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life 3.8 only security fixes 3.9 only security fixes 3.10 only security fixes labels May 31, 2020
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    @iritkatriel iritkatriel added 3.12 bugs and security fixes and removed 3.10 only security fixes 3.9 only security fixes 3.8 only security fixes 3.7 (EOL) end of life labels Oct 6, 2022
    @erlend-aasland erlend-aasland added 3.13 new features, bugs and security fixes and removed 3.12 bugs and security fixes labels Jan 5, 2024
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.13 new features, bugs and security fixes stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    Status: No status
    Development

    No branches or pull requests

    4 participants