mirror of https://github.com/streamlink/streamlink
chore: fix PT0{11,12,18} ruff rules
This commit is contained in:
parent
cb8c8df7d5
commit
cc7159611f
|
@ -132,7 +132,7 @@ class TestRingBuffer:
|
|||
assert buffer.length == 0
|
||||
|
||||
def test_read_timeout(self, buffer: RingBuffer):
|
||||
with pytest.raises(IOError):
|
||||
with pytest.raises(OSError, match=r"^Read timeout$"):
|
||||
buffer.read(timeout=0)
|
||||
|
||||
def test_read_after_close(self, buffer: RingBuffer):
|
||||
|
|
|
@ -128,8 +128,8 @@ class TestIO:
|
|||
ValueError,
|
||||
])
|
||||
def test_save_fail_jsondump(self, cache: Cache, side_effect: Type[Exception]):
|
||||
with pytest.raises(side_effect):
|
||||
with patch("json.dump", side_effect=side_effect):
|
||||
with pytest.raises(side_effect):
|
||||
cache.set("key", "value")
|
||||
assert not cache.filename.exists()
|
||||
|
||||
|
|
|
@ -35,8 +35,8 @@ class TestLogging:
|
|||
def log_failure(self, request, log: logging.Logger, output: StringIO):
|
||||
params = getattr(request, "param", {})
|
||||
root = logging.getLogger("streamlink")
|
||||
with pytest.raises(Exception) as cm:
|
||||
with patch("streamlink.logger.root", root):
|
||||
with pytest.raises(Exception) as cm: # noqa: PT011
|
||||
logger.basicConfig(stream=output, **params)
|
||||
return cm.value
|
||||
|
||||
|
|
|
@ -114,12 +114,11 @@ class TestPluginMatcher:
|
|||
|
||||
# noinspection PyUnusedLocal
|
||||
def test_named_duplicate(self):
|
||||
with pytest.raises(ValueError) as cm:
|
||||
with pytest.raises(ValueError, match=r"^A matcher named 'foo' has already been registered$"):
|
||||
@pluginmatcher(re.compile("http://foo"), name="foo")
|
||||
@pluginmatcher(re.compile("http://foo"), name="foo")
|
||||
class MyPlugin(FakePlugin):
|
||||
pass
|
||||
assert str(cm.value) == "A matcher named 'foo' has already been registered"
|
||||
|
||||
def test_no_matchers(self):
|
||||
class MyPlugin(FakePlugin):
|
||||
|
@ -238,8 +237,9 @@ class TestPluginArguments:
|
|||
assert tuple(arg.name for arg in MixedPlugin.arguments) == ("qux", "foo", "bar", "baz")
|
||||
|
||||
def test_decorator_typerror(self):
|
||||
with pytest.raises(TypeError) as cm:
|
||||
with patch("builtins.repr", Mock(side_effect=lambda obj: obj.__name__)):
|
||||
with pytest.raises(TypeError) as cm:
|
||||
# noinspection PyUnusedLocal
|
||||
@pluginargument("foo")
|
||||
class Foo:
|
||||
pass
|
||||
|
|
|
@ -74,7 +74,8 @@ class TestPlugins:
|
|||
|
||||
def test_matchers(self, plugin):
|
||||
pluginclass = plugin.__plugin__
|
||||
assert isinstance(pluginclass.matchers, list) and len(pluginclass.matchers) > 0, "Has at least one matcher"
|
||||
assert isinstance(pluginclass.matchers, list), "Has at a matchers list"
|
||||
assert len(pluginclass.matchers) > 0, "Has at least one matcher"
|
||||
assert all(isinstance(matcher, Matcher) for matcher in pluginclass.matchers), "Only has valid matchers"
|
||||
|
||||
def test_plugin_api(self, plugin):
|
||||
|
|
|
@ -215,7 +215,7 @@ async def test_onoutput_exception(event_loop: asyncio.BaseEventLoop, processoutp
|
|||
error = ValueError("error")
|
||||
processoutput.onstdout = Mock(side_effect=error)
|
||||
|
||||
with pytest.raises(ValueError) as cm:
|
||||
with pytest.raises(ValueError) as cm: # noqa: PT011
|
||||
await processoutput._run()
|
||||
|
||||
assert cm.value is error
|
||||
|
|
Loading…
Reference in New Issue