question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Change examples to be doctests

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
valerievichcommented, 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.

1reaction
lk-geimfaricommented, Mar 8, 2019

@ceccoemi We used to try to resolve this issue. I remember that this is problematic because of possible updates of files (JSON files where we store data for each provider).

Read more comments on GitHub >

github_iconTop Results From Across the Web

doctest — Test interactive Python examples — Python 3.11.1 ...
The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they...
Read more >
How To Write Doctests in Python - DigitalOcean
The doctest module programmatically searches Python code for pieces… ... Then you can copy, paste, or edit the examples by adding them after ......
Read more >
doctest – Testing through documentation - PyMOTW
doctest lets you test your code by running examples embedded in the documentation and verifying that they produce the expected results.
Read more >
Python's doctest: Document and Test Your Code at Once
In this tutorial, you'll learn how to add usage examples to your code's documentation and docstrings and how to use these examples to...
Read more >
How to move Python doctest examples into another unit test ...
... so that you have a one-to-one conversion and can iron out any bugs with minimal changes. You may choose to leave the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found