summaryrefslogtreecommitdiff
path: root/tests/test_config/test_i18n.py
diff options
context:
space:
mode:
authorMichael Merickel <michael@merickel.org>2018-10-15 01:55:54 -0500
committerMichael Merickel <michael@merickel.org>2018-10-15 09:24:07 -0500
commit0c29cf2df41600d3906d521c72991c7686018b71 (patch)
treeff907f90ec9467e12874c9b2c961549d0e7caf74 /tests/test_config/test_i18n.py
parent851c368e3c158e264358de10446f5b5de240e534 (diff)
downloadpyramid-0c29cf2df41600d3906d521c72991c7686018b71.tar.gz
pyramid-0c29cf2df41600d3906d521c72991c7686018b71.tar.bz2
pyramid-0c29cf2df41600d3906d521c72991c7686018b71.zip
format source using black
Diffstat (limited to 'tests/test_config/test_i18n.py')
-rw-r--r--tests/test_config/test_i18n.py129
1 files changed, 85 insertions, 44 deletions
diff --git a/tests/test_config/test_i18n.py b/tests/test_config/test_i18n.py
index 87805f671..5961e9ff2 100644
--- a/tests/test_config/test_i18n.py
+++ b/tests/test_config/test_i18n.py
@@ -5,56 +5,73 @@ from . import dummyfactory
here = os.path.dirname(__file__)
locale = os.path.abspath(
- os.path.join(here, '..', 'pkgs', 'localeapp', 'locale'))
+ os.path.join(here, '..', 'pkgs', 'localeapp', 'locale')
+)
locale2 = os.path.abspath(
- os.path.join(here, '..', 'pkgs', 'localeapp', 'locale2'))
+ os.path.join(here, '..', 'pkgs', 'localeapp', 'locale2')
+)
locale3 = os.path.abspath(
- os.path.join(here, '..', 'pkgs', 'localeapp', 'locale3'))
+ os.path.join(here, '..', 'pkgs', 'localeapp', 'locale3')
+)
+
class TestI18NConfiguratorMixin(unittest.TestCase):
def _makeOne(self, *arg, **kw):
from pyramid.config import Configurator
+
config = Configurator(*arg, **kw)
return config
def test_set_locale_negotiator(self):
from pyramid.interfaces import ILocaleNegotiator
+
config = self._makeOne(autocommit=True)
- def negotiator(request): pass
+
+ def negotiator(request):
+ pass
+
config.set_locale_negotiator(negotiator)
- self.assertEqual(config.registry.getUtility(ILocaleNegotiator),
- negotiator)
+ self.assertEqual(
+ config.registry.getUtility(ILocaleNegotiator), negotiator
+ )
def test_set_locale_negotiator_dottedname(self):
from pyramid.interfaces import ILocaleNegotiator
+
config = self._makeOne(autocommit=True)
- config.set_locale_negotiator(
- 'tests.test_config.dummyfactory')
- self.assertEqual(config.registry.getUtility(ILocaleNegotiator),
- dummyfactory)
+ config.set_locale_negotiator('tests.test_config.dummyfactory')
+ self.assertEqual(
+ config.registry.getUtility(ILocaleNegotiator), dummyfactory
+ )
def test_add_translation_dirs_missing_dir(self):
from pyramid.exceptions import ConfigurationError
+
config = self._makeOne()
config.add_translation_dirs('/wont/exist/on/my/system')
self.assertRaises(ConfigurationError, config.commit)
def test_add_translation_dirs_no_specs(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne()
config.add_translation_dirs()
- self.assertEqual(config.registry.queryUtility(ITranslationDirectories),
- None)
+ self.assertEqual(
+ config.registry.queryUtility(ITranslationDirectories), None
+ )
def test_add_translation_dirs_asset_spec(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
config.add_translation_dirs('tests.pkgs.localeapp:locale')
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale])
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories), [locale]
+ )
def test_add_translation_dirs_asset_spec_existing_translation_dirs(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
directories = ['abc']
config.registry.registerUtility(directories, ITranslationDirectories)
@@ -64,69 +81,93 @@ class TestI18NConfiguratorMixin(unittest.TestCase):
def test_add_translation_dirs_multiple_specs(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('tests.pkgs.localeapp:locale',
- 'tests.pkgs.localeapp:locale2')
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale, locale2])
+ config.add_translation_dirs(
+ 'tests.pkgs.localeapp:locale', 'tests.pkgs.localeapp:locale2'
+ )
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories),
+ [locale, locale2],
+ )
def test_add_translation_dirs_multiple_specs_multiple_calls(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('tests.pkgs.localeapp:locale',
- 'tests.pkgs.localeapp:locale2')
+ config.add_translation_dirs(
+ 'tests.pkgs.localeapp:locale', 'tests.pkgs.localeapp:locale2'
+ )
config.add_translation_dirs('tests.pkgs.localeapp:locale3')
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale3, locale, locale2])
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories),
+ [locale3, locale, locale2],
+ )
def test_add_translation_dirs_override_multiple_specs_multiple_calls(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
- config.add_translation_dirs('tests.pkgs.localeapp:locale',
- 'tests.pkgs.localeapp:locale2')
- config.add_translation_dirs('tests.pkgs.localeapp:locale3',
- override=True)
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale, locale2, locale3])
+ config.add_translation_dirs(
+ 'tests.pkgs.localeapp:locale', 'tests.pkgs.localeapp:locale2'
+ )
+ config.add_translation_dirs(
+ 'tests.pkgs.localeapp:locale3', override=True
+ )
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories),
+ [locale, locale2, locale3],
+ )
def test_add_translation_dirs_invalid_kwargs(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
with self.assertRaises(TypeError):
- config.add_translation_dirs('tests.pkgs.localeapp:locale',
- foo=1)
+ config.add_translation_dirs('tests.pkgs.localeapp:locale', foo=1)
def test_add_translation_dirs_abspath(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
config.add_translation_dirs(locale)
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale])
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories), [locale]
+ )
def test_add_translation_dirs_uses_override_out_of_order(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne()
config.add_translation_dirs('tests.pkgs.localeapp:locale')
- config.override_asset('tests.pkgs.localeapp:locale/',
- 'tests.pkgs.localeapp:locale2/')
+ config.override_asset(
+ 'tests.pkgs.localeapp:locale/', 'tests.pkgs.localeapp:locale2/'
+ )
config.commit()
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale2])
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories), [locale2]
+ )
def test_add_translation_dirs_doesnt_use_override_w_autocommit(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
config.add_translation_dirs('tests.pkgs.localeapp:locale')
- config.override_asset('tests.pkgs.localeapp:locale/',
- 'tests.pkgs.localeapp:locale2/')
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale])
+ config.override_asset(
+ 'tests.pkgs.localeapp:locale/', 'tests.pkgs.localeapp:locale2/'
+ )
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories), [locale]
+ )
def test_add_translation_dirs_uses_override_w_autocommit(self):
from pyramid.interfaces import ITranslationDirectories
+
config = self._makeOne(autocommit=True)
- config.override_asset('tests.pkgs.localeapp:locale/',
- 'tests.pkgs.localeapp:locale2/')
+ config.override_asset(
+ 'tests.pkgs.localeapp:locale/', 'tests.pkgs.localeapp:locale2/'
+ )
config.add_translation_dirs('tests.pkgs.localeapp:locale')
- self.assertEqual(config.registry.getUtility(ITranslationDirectories),
- [locale2])
+ self.assertEqual(
+ config.registry.getUtility(ITranslationDirectories), [locale2]
+ )