A complete gutting of the internals of ytdl-sub to support functions in our variable syntax, in addition to being able to access a yt-dlp entry's .info.json fields using functions. Functionally, ytdl-sub should still look and behave the same from a user-perspective. With so many lines of code changed (+8927, -2708), no doubt there will be new issues. Please make a GH issue or reach out on Discord if your config/subscriptions break in any way/shape/form. Details on how to use function support will come soon in the form of proper documentation in our readthedocs.
25 lines
998 B
Python
25 lines
998 B
Python
import re
|
|
|
|
import pytest
|
|
from unit.script.conftest import single_variable_output
|
|
|
|
from ytdl_sub.script.script import Script
|
|
from ytdl_sub.script.utils.exceptions import UserThrownRuntimeError
|
|
|
|
|
|
class TestErrorFunctions:
|
|
def test_user_throw(self):
|
|
with pytest.raises(UserThrownRuntimeError, match=re.escape("test this error message")):
|
|
Script({"throw_error": "{%throw('test this error message')}"}).resolve()
|
|
|
|
def test_user_assert_raises(self):
|
|
with pytest.raises(UserThrownRuntimeError, match=re.escape("test this error message")):
|
|
Script({"throw_error": "{%assert(False, 'test this error message')}"}).resolve()
|
|
|
|
def test_user_assert_passthrough(self):
|
|
output = single_variable_output("{%assert(['a'], 'test this error message')}")
|
|
assert output == ["a"]
|
|
|
|
def test_user_assert_passthrough_as_arg(self):
|
|
output = single_variable_output("{%int(%assert('123', 'test this error message'))}")
|
|
assert output == 123
|