nose-devs / nose

nose is nicer testing for python
http://readthedocs.org/docs/nose/en/latest/
1.36k stars 395 forks source link

Make `nose.plugins.xuint.Tee` more File-like #1100

Closed ngie-eign closed 4 years ago

ngie-eign commented 4 years ago

Core Change

If the Tee object is to be fully treated like a File-like object, it needs to also implement the .closed property, per io.IOBase.closed. If it doesn't, then the caller (in the base library) will fail to test the property before trying to close the Tee object.

This was reproduced with a custom copy of nose where the Tee object was duped to a logging.StreamHandler object, like seen below:

...
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/logging/__init__.py", line 892, in emit
    self.flush()
  File "/usr/local/lib/python2.7/logging/__init__.py", line 851, in flush
    if self.stream and hasattr(self.stream, "flush") and not self.stream.closed:
AttributeError: 'Tee' object has no attribute 'closed'
Logged from file (unknown file), line 0

Ancillary Changes

These changes also address some minor stylistic issues found by flake8, in part by using the black tool to reformat the file.

Signed-off-by: Enji Cooper yaneurabeya@gmail.com

jszakmeister commented 4 years ago

Nose is no longer maintained, please look to nose2 as the future of nose.

ngie-eign commented 4 years ago

@jszakmeister: Got it; closing the PR.