Skip to content

Commit 2a4b784

Browse files
authored
Remove redundant tests for babel.support (#954)
The doctests test the exact same things.
1 parent 61be9dc commit 2a4b784

File tree

2 files changed

+9
-38
lines changed

2 files changed

+9
-38
lines changed

babel/support.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ def compact_decimal(
151151
>>> fmt = Format('en_US')
152152
>>> fmt.compact_decimal(123456789)
153153
u'123M'
154+
>>> fmt.compact_decimal(1234567, format_type='long', fraction_digits=2)
155+
'1.23 million'
154156
"""
155157
return format_compact_decimal(number, format_type=format_type,
156158
fraction_digits=fraction_digits,
@@ -170,6 +172,9 @@ def compact_currency(
170172
) -> str:
171173
"""Return a number in the given currency formatted for the locale
172174
using the compact number format.
175+
176+
>>> Format('en_US').compact_currency(1234567, "USD", format_type='short', fraction_digits=2)
177+
'$1.23M'
173178
"""
174179
return format_compact_currency(number, currency, format_type=format_type,
175180
fraction_digits=fraction_digits, locale=self.locale)

tests/test_support.py

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
# individuals. For the exact contribution history, see the revision
1111
# history and logs, available at http://babel.edgewall.org/log/.
1212

13+
import datetime
1314
import inspect
1415
import os
1516
import shutil
1617
import sys
1718
import tempfile
1819
import unittest
19-
from datetime import date, datetime, timedelta
2020
from io import BytesIO
2121

2222
import pytest
@@ -296,50 +296,16 @@ def raise_attribute_error():
296296
assert str(exception.value) == 'message'
297297

298298

299-
def test_format_date():
300-
fmt = support.Format('en_US')
301-
assert fmt.date(date(2007, 4, 1)) == 'Apr 1, 2007'
302-
299+
WHEN = datetime.datetime(2007, 4, 1, 15, 30)
303300

304301
def test_format_datetime(timezone_getter):
305302
fmt = support.Format('en_US', tzinfo=timezone_getter('US/Eastern'))
306-
when = datetime(2007, 4, 1, 15, 30)
307-
assert fmt.datetime(when) == 'Apr 1, 2007, 11:30:00\u202fAM'
303+
assert fmt.datetime(WHEN) == 'Apr 1, 2007, 11:30:00\u202fAM'
308304

309305

310306
def test_format_time(timezone_getter):
311307
fmt = support.Format('en_US', tzinfo=timezone_getter('US/Eastern'))
312-
assert fmt.time(datetime(2007, 4, 1, 15, 30)) == '11:30:00\u202fAM'
313-
314-
315-
def test_format_timedelta():
316-
fmt = support.Format('en_US')
317-
assert fmt.timedelta(timedelta(weeks=11)) == '3 months'
318-
319-
320-
def test_format_number():
321-
fmt = support.Format('en_US')
322-
assert fmt.number(1099) == '1,099'
323-
324-
325-
def test_format_decimal():
326-
fmt = support.Format('en_US')
327-
assert fmt.decimal(1.2345) == '1.234'
328-
329-
330-
def test_format_compact_decimal():
331-
fmt = support.Format('en_US')
332-
assert fmt.compact_decimal(1234567, format_type='long', fraction_digits=2) == '1.23 million'
333-
334-
335-
def test_format_compact_currency():
336-
fmt = support.Format('en_US')
337-
assert fmt.compact_currency(1234567, "USD", format_type='short', fraction_digits=2) == '$1.23M'
338-
339-
340-
def test_format_percent():
341-
fmt = support.Format('en_US')
342-
assert fmt.percent(0.34) == '34%'
308+
assert fmt.time(WHEN) == '11:30:00\u202fAM'
343309

344310

345311
def test_lazy_proxy():

0 commit comments

Comments
 (0)