Bug 283250
Summary: | webkitcorepy.terminal.Terminal.override_atty rejects typing.IO subclasses | ||
---|---|---|---|
Product: | WebKit | Reporter: | Sam Sneddon [:gsnedders] <gsnedders> |
Component: | Tools / Tests | Assignee: | Sam Sneddon [:gsnedders] <gsnedders> |
Status: | RESOLVED FIXED | ||
Severity: | Normal | CC: | webkit-bug-importer |
Priority: | P2 | Keywords: | InRadar |
Version: | WebKit Nightly Build | ||
Hardware: | Unspecified | ||
OS: | Unspecified |
Sam Sneddon [:gsnedders]
Trying to run the webkitscmpy tests under pytest leads to:
```
_____________________________________________________________ TestLog.test_git ______________________________________________________________
self = <webkitscmpy.test.log_unittest.TestLog testMethod=test_git>
def test_git(self):
> with OutputCapture() as captured, mocks.local.Git(self.path), mocks.local.Svn(), MockTime, Terminal.override_atty(sys.stdin, isatty=False):
webkitscmpy/test/log_unittest.py:43:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py:117: in __enter__
return next(self.gen)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <class 'webkitcorepy.terminal.Terminal'>, target = <_pytest.capture.DontReadFromInput object at 0x1038de910>, isatty = False
@classmethod
@contextlib.contextmanager
def override_atty(cls, target, isatty=True):
if not isinstance(target, (io.IOBase, file, StringIO)):
> raise ValueError('{} is not an IO object'.format(target))
E ValueError: <_pytest.capture.DontReadFromInput object at 0x1038de910> is not an IO object
.tox/py39/lib/python3.9/site-packages/webkitcorepy/terminal.py:135: ValueError
```
_pytest.capture.DontReadFromInput:
In [2]: DontReadFromInput.__mro__
Out[2]:
(_pytest.capture.DontReadFromInput,
typing.TextIO,
typing.IO,
typing.Generic,
object)
Thus it isn't an instance of any of the three classes we're checking for.
On the whole, this feels like somewhere where we shouldn't be doing runtime type-checking by default at all. At most, we should probably just be checking for some file-like protocol (having read/write), as there's plenty of file-like objects out there (even within the stdlib!).
Attachments | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Sam Sneddon [:gsnedders]
Pull request: https://github.com/WebKit/WebKit/pull/36766
Radar WebKit Bug Importer
<rdar://problem/140486513>
EWS
Committed 287299@main (c4740203d5ee): <https://commits.webkit.org/287299@main>
Reviewed commits have been landed. Closing PR #36766 and removing active labels.