Skip to content

Commit

Permalink
test buff transform() methods, to get them to load and run (#856)
Browse files Browse the repository at this point in the history
  • Loading branch information
leondz authored Aug 28, 2024
1 parent 5a31168 commit 88e73dd
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/buffs/test_buffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import importlib

from garak import _plugins
from garak import attempt
from garak.exception import GarakException
import garak.buffs.base

BUFFS = [classname for (classname, active) in _plugins.enumerate_plugins("buffs")]

Expand All @@ -23,3 +26,16 @@ def test_buff_structure(classname):
if k not in c._supported_params:
unsupported_defaults.append(k)
assert unsupported_defaults == []


@pytest.mark.parametrize("klassname", BUFFS)
def test_buff_load_and_transform(klassname):
try:
b = _plugins.load_plugin(klassname)
except GarakException:
pytest.skip()
assert isinstance(b, garak.buffs.base.Buff)
a = attempt.Attempt()
a.prompt = "I'm just a plain and simple tailor"
buffed_a = list(b.transform(a)) # unroll the generator
assert isinstance(buffed_a, list)

0 comments on commit 88e73dd

Please sign in to comment.