Skip to content

Commit

Permalink
Unify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
aaltat committed Oct 20, 2023
1 parent e7f124a commit 8ff4955
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions atest/TestLibrary.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Optional, Any, Callable
from typing import Optional, Any

from robot.api.deco import keyword
from robotlibcore import DynamicCore
Expand All @@ -15,11 +15,11 @@ class LibFormatter(Formatter):
def __init__(self):
self.keyword_formatters = {}

def set_formatter(self, keyword: Callable, *formatter: str):
def set_formatter(self, keyword: str, *formatter: str):
formatter = self.formatters_to_method(list(formatter))
self.keyword_formatters[keyword] = list(formatter)
self.keyword_formatters[keyword] = formatter

def get_formatter(self, keyword: Callable):
def get_formatter(self, keyword: str):
LOG.info(self.keyword_formatters.get(keyword))
return self.keyword_formatters.get(keyword)

Expand All @@ -40,7 +40,7 @@ def is_equal(
assertion_expected: Any = None,
message: str = None,
):
formatter = self.lib_formatter.get_formatter(self.is_equal)
formatter = self.lib_formatter.get_formatter(self.is_equal.__name__)
LOG.info(formatter)
return verify_assertion(
value,
Expand All @@ -60,7 +60,7 @@ def is_equal_as_number(
message: str = None,
):
LOG.info(f"integer: '{integer}' and type: {type(integer)}")
formatter = self.lib_formatter.get_formatter(self.is_equal_as_number)
formatter = self.lib_formatter.get_formatter(self.is_equal_as_number.__name__)
return verify_assertion(
integer,
assertion_operator,
Expand All @@ -77,5 +77,5 @@ def get_keyword_formatters(self) -> dict:

@keyword
def set_assertion_formatter(self, keyword: str, *formatters: str):
kw_method = self.keywords.get(self.lib_formatter.normalize_keyword(keyword))
self.lib_formatter.set_formatter(kw_method, *formatters)
kw_str = self.lib_formatter.normalize_keyword(keyword)
self.lib_formatter.set_formatter(kw_str, *formatters)
2 changes: 1 addition & 1 deletion atest/TestLibraryWithScopes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from enum import Enum, auto
from typing import Optional, Any, Callable
from typing import Optional, Any

from robot.api.deco import keyword
from robotlibcore import DynamicCore
Expand Down

0 comments on commit 8ff4955

Please sign in to comment.