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

Change examples to be doctests #436

Open
sobolevn opened this Issue Apr 3, 2018 · 11 comments

Comments

Projects
None yet
3 participants
@sobolevn
Collaborator

sobolevn commented Apr 3, 2018

Right now we use something like:

    def price_in_btc(self, minimum: float = 0, maximum: float = 2) -> str:
        """Generate random price in BTC.

        :param minimum: Minimum value of price
        :param maximum: Maximum value of price.
        :return: Price in BTC.

        :Example:
            0.5885238 BTC
        """

I suggest to change it to:

    def price_in_btc(self, minimum: float = 0, maximum: float = 2) -> str:
        """Generate random price in BTC.

        :param minimum: Minimum value of price
        :param maximum: Maximum value of price.
        :return: Price in BTC.

       >>> from mimesis import Business
       >>> provider  = Business()
       >>> provider.price_in_btc()
       0.5885238 BTC
        """

https://docs.python.org/3/library/doctest.html

But we need to freeze random here.
So, it possible to use something like https://docs.pytest.org/en/latest/doctest.html#the-doctest-namespace-fixture

@lk-geimfari

This comment has been minimized.

Owner

lk-geimfari commented Apr 3, 2018

@sobolevn I'm all for it.

@Valerievich

This comment has been minimized.

Contributor

Valerievich commented Oct 3, 2018

@sobolevn Hello! Can you please clarify where exactly we want to see this action? after make test command ?

@sobolevn

This comment has been minimized.

Collaborator

sobolevn commented Oct 3, 2018

I want to write doctests instead of static examples. They will be executed with pytest --doctest-modules

@Valerievich

This comment has been minimized.

Contributor

Valerievich commented Oct 4, 2018

One more question! Why it's necessary to freeze random? I think it's more useful to see that function provides different numbers as it was conceived.

@sobolevn

This comment has been minimized.

Collaborator

sobolevn commented Oct 4, 2018

@Valerievich we do not need to freeze it, just seed is enough.

@Valerievich

This comment has been minimized.

Contributor

Valerievich commented Oct 10, 2018

This issue can be closed. We've done with PR.

@sobolevn

This comment has been minimized.

Collaborator

sobolevn commented Oct 10, 2018

@Valerievich but you have changed only a single example.

My original idea was to change all examples to the doctests. In all project.

@lk-geimfari

This comment has been minimized.

Owner

lk-geimfari commented Oct 10, 2018

@Valerievich Yeah, I don't understand why we need to close this too.

@Valerievich

This comment has been minimized.

Contributor

Valerievich commented Oct 11, 2018

Ok. Now I understand the whole idea of this issue. I am going to continue to work on this. It makes sense to create PR's which consist of changes only for one provider I think. It would be easier to approve.

@sobolevn

This comment has been minimized.

Collaborator

sobolevn commented Oct 11, 2018

@Valerievich agreed.

@Valerievich

This comment has been minimized.

Contributor

Valerievich commented Oct 26, 2018

I see that my changes in Business provider doctest was removed in this commit. I understand that doctest might be useless.
Does it mean that issue isn't relevant anymore?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment