diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/messages/test_frontend.py | 29 | ||||
-rw-r--r-- | tests/messages/test_pofile.py | 1 | ||||
-rw-r--r-- | tests/test_numbers.py | 7 |
3 files changed, 15 insertions, 22 deletions
diff --git a/tests/messages/test_frontend.py b/tests/messages/test_frontend.py index 2dc5330..ba78f50 100644 --- a/tests/messages/test_frontend.py +++ b/tests/messages/test_frontend.py @@ -11,12 +11,10 @@ # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. import shlex -from freezegun import freeze_time from datetime import datetime -from distutils.dist import Distribution -from distutils.errors import DistutilsOptionError -from distutils.log import _global_log +from freezegun import freeze_time from io import StringIO +from setuptools import Distribution import logging import os import shutil @@ -29,7 +27,7 @@ import pytest from babel import __version__ as VERSION from babel.dates import format_datetime from babel.messages import frontend, Catalog -from babel.messages.frontend import CommandLineInterface, extract_messages, update_catalog +from babel.messages.frontend import CommandLineInterface, extract_messages, update_catalog, OptionError from babel.util import LOCALTZ from babel.messages.pofile import read_po, write_po @@ -49,7 +47,6 @@ class CompileCatalogTestCase(unittest.TestCase): def setUp(self): self.olddir = os.getcwd() os.chdir(data_dir) - _global_log.threshold = 5 # shut up distutils logging self.dist = Distribution(dict( name='TestProject', @@ -65,12 +62,12 @@ class CompileCatalogTestCase(unittest.TestCase): def test_no_directory_or_output_file_specified(self): self.cmd.locale = 'en_US' self.cmd.input_file = 'dummy' - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) def test_no_directory_or_input_file_specified(self): self.cmd.locale = 'en_US' self.cmd.output_file = 'dummy' - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) class ExtractMessagesTestCase(unittest.TestCase): @@ -78,7 +75,6 @@ class ExtractMessagesTestCase(unittest.TestCase): def setUp(self): self.olddir = os.getcwd() os.chdir(data_dir) - _global_log.threshold = 5 # shut up distutils logging self.dist = Distribution(dict( name='TestProject', @@ -100,21 +96,21 @@ class ExtractMessagesTestCase(unittest.TestCase): def test_neither_default_nor_custom_keywords(self): self.cmd.output_file = 'dummy' self.cmd.no_default_keywords = True - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) def test_no_output_file_specified(self): - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) def test_both_sort_output_and_sort_by_file(self): self.cmd.output_file = 'dummy' self.cmd.sort_output = True self.cmd.sort_by_file = True - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) def test_invalid_file_or_dir_input_path(self): self.cmd.input_paths = 'nonexistent_path' self.cmd.output_file = 'dummy' - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) def test_input_paths_is_treated_as_list(self): self.cmd.input_paths = data_dir @@ -146,7 +142,7 @@ class ExtractMessagesTestCase(unittest.TestCase): self.cmd.input_dirs = this_dir self.cmd.input_paths = this_dir self.cmd.output_file = pot_file - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) @freeze_time("1994-11-11") def test_extraction_with_default_mapping(self): @@ -354,7 +350,6 @@ class InitCatalogTestCase(unittest.TestCase): def setUp(self): self.olddir = os.getcwd() os.chdir(data_dir) - _global_log.threshold = 5 # shut up distutils logging self.dist = Distribution(dict( name='TestProject', @@ -375,12 +370,12 @@ class InitCatalogTestCase(unittest.TestCase): def test_no_input_file(self): self.cmd.locale = 'en_US' self.cmd.output_file = 'dummy' - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) def test_no_locale(self): self.cmd.input_file = 'dummy' self.cmd.output_file = 'dummy' - self.assertRaises(DistutilsOptionError, self.cmd.finalize_options) + self.assertRaises(OptionError, self.cmd.finalize_options) @freeze_time("1994-11-11") def test_with_output_dir(self): diff --git a/tests/messages/test_pofile.py b/tests/messages/test_pofile.py index 7239a88..ff0295a 100644 --- a/tests/messages/test_pofile.py +++ b/tests/messages/test_pofile.py @@ -827,6 +827,7 @@ msgstr ""''', buf.getvalue().strip()) def test_no_include_lineno(self): catalog = Catalog() catalog.add(u'foo', locations=[('main.py', 1)]) + catalog.add(u'foo', locations=[('main.py', 2)]) catalog.add(u'foo', locations=[('utils.py', 3)]) buf = BytesIO() pofile.write_po(buf, catalog, omit_header=True, include_lineno=False) diff --git a/tests/test_numbers.py b/tests/test_numbers.py index 58e3919..f0d10d1 100644 --- a/tests/test_numbers.py +++ b/tests/test_numbers.py @@ -346,12 +346,9 @@ def test_decimal_precision(): assert get_decimal_precision(decimal.Decimal('10000')) == 0 -def test_format_number(): - assert numbers.format_number(1099, locale='en_US') == u'1,099' - assert numbers.format_number(1099, locale='de_DE') == u'1.099' - - def test_format_decimal(): + assert numbers.format_decimal(1099, locale='en_US') == u'1,099' + assert numbers.format_decimal(1099, locale='de_DE') == u'1.099' assert numbers.format_decimal(1.2345, locale='en_US') == u'1.234' assert numbers.format_decimal(1.2346, locale='en_US') == u'1.235' assert numbers.format_decimal(-1.2346, locale='en_US') == u'-1.235' |