robotframework-faker
robotframework-faker copied to clipboard
Adding a custom provider fails with error: "set_formatter() takes exactly 3 arguments (2 given)"
When I run the following code, I'm facing some difficulty. Calling the Add Provider
keyword requires two arguments, instead of the expected 1: name of the module. This seems to me to be correct.
Assuming it might be the FakerLibrary I retrieved it's library instance and provided it to the keyword. Sadly this doesn't provide me with the desired end result but instead generates the error: "FAIL : TypeError: set_formatter() takes exactly 3 arguments (2 given)
".
The Robot Script for this example.
*** Settings ***
Library FakerLibrary
*** Test Cases ***
Faker Custom Provider Generate Data
${fakerLib} Get Library Instance FakerLibrary
Add Provider ${fakerLib} OceanProvider
The custom provider Python code:
from faker.providers import BaseProvider
class OceanProvider(BaseProvider):
__provider__ = "ocean"
__lang__ = "en_US"
oceans = [
u'Atlantic', u'Pacific', u'Indian', u'Arctic', u'Southern',
]
@classmethod
def ocean(cls):
return cls.random_element(cls.oceans)