mirror of https://github.com/streamlink/streamlink
parent
0acbca3af1
commit
eb901bbc9e
|
@ -279,6 +279,12 @@ class Arguments:
|
|||
# iterate in reverse order due to add() being called by multiple pluginargument decorators in reverse order
|
||||
return reversed(self.arguments.values())
|
||||
|
||||
def __hash__(self):
|
||||
return hash(tuple(self.arguments.items()))
|
||||
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, self.__class__) and hash(self) == hash(other)
|
||||
|
||||
def add(self, argument: Argument) -> None:
|
||||
self.arguments[argument.name] = argument
|
||||
|
||||
|
|
|
@ -213,8 +213,11 @@ class TestArgument:
|
|||
sensitive=False,
|
||||
argument_name="custom-name",
|
||||
)
|
||||
a3 = Argument("foo")
|
||||
assert a1 is not a2
|
||||
assert a1 == a2
|
||||
assert a1 != a3
|
||||
assert a2 != a3
|
||||
|
||||
|
||||
class TestArguments:
|
||||
|
@ -246,6 +249,16 @@ class TestArguments:
|
|||
args.add(test3)
|
||||
assert list(iter(args)) == [test3, test1, test2]
|
||||
|
||||
def test_equality(self):
|
||||
test1 = Arguments()
|
||||
test1.add(Argument("testA"))
|
||||
test1.add(Argument("testB"))
|
||||
test2 = Arguments(Argument("testB"), Argument("testA"))
|
||||
test3 = Arguments(Argument("testA"), Argument("testB"))
|
||||
assert test1 == test2
|
||||
assert test1 != test3
|
||||
assert test2 != test3
|
||||
|
||||
def test_requires(self):
|
||||
test1 = Argument("test1", requires="test2")
|
||||
test2 = Argument("test2", requires="test3")
|
||||
|
|
Loading…
Reference in New Issue