1717import tempfile
1818import unittest
1919import pytest
20+ import sys
2021from datetime import date , datetime , timedelta
2122
2223from babel import support
2627
2728get_arg_spec = (inspect .getargspec if PY2 else inspect .getfullargspec )
2829
30+ SKIP_LGETTEXT = sys .version_info >= (3 , 8 )
2931
3032@pytest .mark .usefixtures ("os_environ" )
3133class TranslationsTestCase (unittest .TestCase ):
@@ -76,6 +78,7 @@ def test_upgettext(self):
7678 self .assertEqualTypeToo (u'VohCTX' , self .translations .upgettext ('foo' ,
7779 'foo' ))
7880
81+ @pytest .mark .skipif (SKIP_LGETTEXT , reason = "lgettext is deprecated" )
7982 def test_lpgettext (self ):
8083 self .assertEqualTypeToo (b'Voh' , self .translations .lgettext ('foo' ))
8184 self .assertEqualTypeToo (b'VohCTX' , self .translations .lpgettext ('foo' ,
@@ -105,6 +108,7 @@ def test_unpgettext(self):
105108 self .translations .unpgettext ('foo' , 'foo1' ,
106109 'foos1' , 2 ))
107110
111+ @pytest .mark .skipif (SKIP_LGETTEXT , reason = "lgettext is deprecated" )
108112 def test_lnpgettext (self ):
109113 self .assertEqualTypeToo (b'Voh1' ,
110114 self .translations .lngettext ('foo1' , 'foos1' , 1 ))
@@ -129,6 +133,7 @@ def test_dupgettext(self):
129133 self .assertEqualTypeToo (
130134 u'VohCTXD' , self .translations .dupgettext ('messages1' , 'foo' , 'foo' ))
131135
136+ @pytest .mark .skipif (SKIP_LGETTEXT , reason = "lgettext is deprecated" )
132137 def test_ldpgettext (self ):
133138 self .assertEqualTypeToo (
134139 b'VohD' , self .translations .ldgettext ('messages1' , 'foo' ))
@@ -159,6 +164,7 @@ def test_dunpgettext(self):
159164 u'VohsCTXD1' , self .translations .dunpgettext ('messages1' , 'foo' , 'foo1' ,
160165 'foos1' , 2 ))
161166
167+ @pytest .mark .skipif (SKIP_LGETTEXT , reason = "lgettext is deprecated" )
162168 def test_ldnpgettext (self ):
163169 self .assertEqualTypeToo (
164170 b'VohD1' , self .translations .ldngettext ('messages1' , 'foo1' , 'foos1' , 1 ))
@@ -197,7 +203,11 @@ def setUp(self):
197203 self .null_translations = support .NullTranslations (fp = fp )
198204
199205 def method_names (self ):
200- return [name for name in dir (self .translations ) if 'gettext' in name ]
206+ names = [name for name in dir (self .translations ) if 'gettext' in name ]
207+ if SKIP_LGETTEXT :
208+ # Remove deprecated l*gettext functions
209+ names = [name for name in names if not name .startswith ('l' )]
210+ return names
201211
202212 def test_same_methods (self ):
203213 for name in self .method_names ():
0 commit comments