Change examples to be doctests
See original GitHub issueRight 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:
- Created 5 years ago
- Reactions:1
- Comments:17 (11 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

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.
@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).