Changeset - d8df34ebaf6f
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-05-28 13:03:23
brettcsmith@brettcsmith.org
reports: Balance.format() accepts None as a format.
2 files changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/reports/core.py
Show inline comments
...
 
@@ -115,3 +115,3 @@ class Balance(Mapping[str, data.Amount]):
 
    def format(self,
 
               fmt: str='#,#00.00 ¤¤',
 
               fmt: Optional[str]='#,#00.00 ¤¤',
 
               sep: str=', ',
...
 
@@ -124,2 +124,5 @@ class Balance(Mapping[str, data.Amount]):
 
        ``sep``.
 

	
 
        If you set ``fmt`` to None, amounts will be formatted according to the
 
        user's locale. The default format is Beancount's input format.
 
        """
tests/test_reports_balance.py
Show inline comments
...
 
@@ -24,2 +24,4 @@ from . import testutil
 

	
 
import babel.numbers
 

	
 
from conservancy_beancount.reports import core
...
 
@@ -193,2 +195,8 @@ def test_format_sep(sep):
 

	
 
def test_format_none():
 
    amounts = testutil.balance_map(BRL=65000)
 
    balance = core.Balance(amounts)
 
    expected = babel.numbers.format_currency(65000, 'BRL')
 
    assert balance.format(None) == expected
 

	
 
@pytest.mark.parametrize('empty', [
0 comments (0 inline, 0 general)