Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a custom provider fails with error: "set_formatter() takes exactly 3 arguments (2 given)" #25

Open
kootstra opened this issue Nov 2, 2017 · 0 comments

Comments

@kootstra
Copy link

kootstra commented Nov 2, 2017

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant