mirror of
https://github.com/certbot/certbot.git
synced 2026-08-01 19:02:52 +02:00
Remove broken test for typing import failure (#8692)
* remove broken test * fix coverage * don't worry about getattr test
This commit is contained in:
@@ -1,16 +1,14 @@
|
|||||||
"""Shim class to not have to depend on typing module in prod."""
|
"""Simple shim around the typing module.
|
||||||
import sys
|
|
||||||
|
This was useful when this code supported Python 2 and typing wasn't always
|
||||||
|
available. This code is being kept for now for backwards compatibility.
|
||||||
|
|
||||||
|
"""
|
||||||
|
from typing import * # pylint: disable=wildcard-import, unused-wildcard-import
|
||||||
|
from typing import Collection, IO # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class TypingClass:
|
class TypingClass:
|
||||||
"""Ignore import errors by getting anything"""
|
"""Ignore import errors by getting anything"""
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
return None
|
return None # pragma: no cover
|
||||||
|
|
||||||
try:
|
|
||||||
# mypy doesn't respect modifying sys.modules
|
|
||||||
from typing import * # pylint: disable=wildcard-import, unused-wildcard-import
|
|
||||||
from typing import Collection, IO # type: ignore
|
|
||||||
except ImportError:
|
|
||||||
# mypy complains because TypingClass is not a module
|
|
||||||
sys.modules[__name__] = TypingClass() # type: ignore
|
|
||||||
|
|||||||
@@ -22,19 +22,6 @@ class MagicTypingTest(unittest.TestCase):
|
|||||||
del sys.modules['acme.magic_typing']
|
del sys.modules['acme.magic_typing']
|
||||||
sys.modules['typing'] = temp_typing
|
sys.modules['typing'] = temp_typing
|
||||||
|
|
||||||
def test_import_failure(self):
|
|
||||||
try:
|
|
||||||
import typing as temp_typing
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
temp_typing = None # pragma: no cover
|
|
||||||
sys.modules['typing'] = None
|
|
||||||
if 'acme.magic_typing' in sys.modules:
|
|
||||||
del sys.modules['acme.magic_typing'] # pragma: no cover
|
|
||||||
from acme.magic_typing import Text
|
|
||||||
self.assertTrue(Text is None)
|
|
||||||
del sys.modules['acme.magic_typing']
|
|
||||||
sys.modules['typing'] = temp_typing
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main() # pragma: no cover
|
unittest.main() # pragma: no cover
|
||||||
|
|||||||
Reference in New Issue
Block a user