@@ -156,20 +156,20 @@ def test_ordinal_genders(
156156 humanize .i18n .deactivate ()
157157
158158
159- def test_default_locale_path_defined__file__ () -> None :
159+ def test_default_locale_path_defined__spec__ () -> None :
160160 i18n = importlib .import_module ("humanize.i18n" )
161161 assert i18n ._get_default_locale_path () is not None
162162
163163
164- def test_default_locale_path_null__file__ ( ) -> None :
164+ def test_default_locale_path_none__spec__ ( monkeypatch : pytest . MonkeyPatch ) -> None :
165165 i18n = importlib .import_module ("humanize.i18n" )
166- i18n . __file__ = None
166+ monkeypatch . setattr ( i18n , "__spec__" , None )
167167 assert i18n ._get_default_locale_path () is None
168168
169169
170- def test_default_locale_path_undefined__file__ () -> None :
170+ def test_default_locale_path_undefined__file__ (monkeypatch : pytest . MonkeyPatch ) -> None :
171171 i18n = importlib .import_module ("humanize.i18n" )
172- del i18n . __file__
172+ monkeypatch . delattr ( i18n , "__spec__" )
173173 assert i18n ._get_default_locale_path () is None
174174
175175
@@ -179,17 +179,21 @@ class TestActivate:
179179 " 'locale' folder. You need to pass the path explicitly."
180180 )
181181
182- def test_default_locale_path_null__file__ (self ) -> None :
182+ def test_default_locale_path_null__spec__ (
183+ self , monkeypatch : pytest .MonkeyPatch
184+ ) -> None :
183185 i18n = importlib .import_module ("humanize.i18n" )
184- i18n . __file__ = None
186+ monkeypatch . setattr ( i18n , "__spec__" , None )
185187
186188 with pytest .raises (Exception ) as excinfo :
187189 i18n .activate ("ru_RU" )
188190 assert str (excinfo .value ) == self .expected_msg
189191
190- def test_default_locale_path_undefined__file__ (self ) -> None :
192+ def test_default_locale_path_undefined__spec__ (
193+ self , monkeypatch : pytest .MonkeyPatch
194+ ) -> None :
191195 i18n = importlib .import_module ("humanize.i18n" )
192- del i18n . __file__
196+ monkeypatch . delattr ( i18n , "__spec__" )
193197
194198 with pytest .raises (Exception ) as excinfo :
195199 i18n .activate ("ru_RU" )
0 commit comments