From 71afc9e322a37c9a7d2868598dfe3ee04a3133c6 Mon Sep 17 00:00:00 2001 From: zpetrace Date: Tue, 3 Sep 2024 12:01:20 +0200 Subject: [PATCH] Adding a String type token --- testimony/config.py | 8 +++++++- testimony/constants.py | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/testimony/config.py b/testimony/config.py index f3234cc..fde1a4a 100644 --- a/testimony/config.py +++ b/testimony/config.py @@ -13,7 +13,8 @@ - Automated ... -Currently only supported type is 'choice', but in the future more can be added. +Currently only supported types are 'choice' and 'string' +but in the future more can be added. """ import yaml @@ -79,6 +80,9 @@ def __init__(self, name, config): self.choices = [i if self.casesensitive else i.lower() for i in config['choices']] + elif self.token_type == 'string': + pass + def update(self, new_values): """Update token configuration with dictionary of new values.""" for key, value in new_values.items(): @@ -90,4 +94,6 @@ def validate(self, what): if not self.casesensitive: what = what.lower() return what in self.choices + elif self.token_type == 'string': + return isinstance(what, str) # validate it's a string return True # assume valid for unknown types diff --git a/testimony/constants.py b/testimony/constants.py index 1cf54eb..e5d69fc 100644 --- a/testimony/constants.py +++ b/testimony/constants.py @@ -18,6 +18,7 @@ TOKEN_TYPES = [ 'choice', + 'string' ] DEFAULT_TOKENS = (