Skip to content

Commit

Permalink
lint.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Nov 6, 2024
1 parent 6571e17 commit e96652d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 24 deletions.
6 changes: 3 additions & 3 deletions src/nti/i18n/locales/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
"""

from __future__ import print_function, absolute_import, division
__docformat__ = "restructuredtext en"

# pylint:disable=no-method-argument,no-self-argument

from zope.interface import Interface

try:
from plone.i18n.locales.interfaces import ICountryAvailability as _ICountryAvailability
except ImportError:
except ModuleNotFoundError:
# Not on Py3
_ICountryAvailability = Interface

Expand Down Expand Up @@ -40,7 +40,7 @@ def getCountryListing():

try:
from plone.i18n.locales.interfaces import ICcTLDInformation as _ICcTLDInformation
except ImportError:
except ModuleNotFoundError:
# Not on Py3
_ICcTLDInformation = Interface

Expand Down
4 changes: 2 additions & 2 deletions src/nti/i18n/locales/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

def skipIfNoPlone(func):
try:
import plone.i18n
import plone.i18n # pylint:disable=unused-import
return func
except ImportError:
except ModuleNotFoundError:
return unittest.skip("plone.i18n not available")(func)
12 changes: 3 additions & 9 deletions src/nti/i18n/locales/tests/test_cctld.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"""
Tests for locale data.
"""

from __future__ import print_function, absolute_import, division
__docformat__ = "restructuredtext en"

import unittest
Expand All @@ -17,11 +15,6 @@

from . import skipIfNoPlone

try:
unicode
except NameError:
unicode = str

class TestConfiguredTLDUtility(unittest.TestCase):

layer = ZCMLFileLayer(nti.i18n, zcml_file='configure.zcml')
Expand All @@ -33,14 +26,15 @@ def test_full_domain_list(self):
for cc in available:
self.assertIn(cc, with_lang)

self.assertEqual([u"en"], info.getLanguagesForTLD('us'))
self.assertIsInstance(info.getLanguagesForTLD('us')[0], unicode)
self.assertEqual(["en"], info.getLanguagesForTLD('us'))
self.assertIsInstance(info.getLanguagesForTLD('us')[0], str)

# Bad tlds
self.assertRaises(KeyError, info.getLanguagesForTLD, __name__)

@skipIfNoPlone
def test_lookup_utility_with_plone_iface(self):
# pylint:disable=import-error
from plone.i18n.locales.interfaces import ICcTLDInformation as IPlone
from nti.i18n.locales.cctld import CcTLDInformation
utility = component.getUtility(IPlone)
Expand Down
16 changes: 6 additions & 10 deletions src/nti/i18n/locales/tests/test_countries.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
Tests for locale data.
"""

from __future__ import print_function, absolute_import, division
__docformat__ = "restructuredtext en"

import unittest
Expand All @@ -17,27 +16,24 @@

from . import skipIfNoPlone

try:
unicode
except NameError:
unicode = str

class TestConfiguredCountryUtility(unittest.TestCase):

layer = ZCMLFileLayer(nti.i18n.locales, zcml_file='configure.zcml')

def test_country_availability(self):
availability = component.getUtility(ICountryAvailability)
self.assertIn(u'us', availability.getAvailableCountries())
self.assertIn(u"us", availability.getCountries())
self.assertIn(u'us', [x[0] for x in availability.getCountryListing()] )
self.assertIn('us', availability.getAvailableCountries())
self.assertIn("us", availability.getCountries())
self.assertIn('us', [x[0] for x in availability.getCountryListing()] )

self.assertIsInstance(
availability.getCountries()[u'us'][u'name'],
unicode)
availability.getCountries()['us']['name'],
str)

@skipIfNoPlone
def test_lookup_utility_with_plone_iface(self):
# pylint:disable=import-error
from plone.i18n.locales.interfaces import ICountryAvailability as IPlone
from nti.i18n.locales.countries import CountryAvailability
utility = component.getUtility(IPlone)
Expand Down

0 comments on commit e96652d

Please sign in to comment.