Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.10/site-packages/astroid/brain/brain_unittest.py: 89%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

9 statements  

1# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html 

2# For details: https://github.com/pylint-dev/astroid/blob/main/LICENSE 

3# Copyright (c) https://github.com/pylint-dev/astroid/blob/main/CONTRIBUTORS.txt 

4 

5"""Astroid hooks for unittest module.""" 

6from astroid import nodes 

7from astroid.brain.helpers import register_module_extender 

8from astroid.builder import parse 

9from astroid.manager import AstroidManager 

10 

11 

12def IsolatedAsyncioTestCaseImport() -> nodes.Module: 

13 """ 

14 In the unittest package, the IsolatedAsyncioTestCase class is imported lazily. 

15 

16 I.E. only when the ``__getattr__`` method of the unittest module is called with 

17 'IsolatedAsyncioTestCase' as argument. Thus the IsolatedAsyncioTestCase 

18 is not imported statically (during import time). 

19 This function mocks a classical static import of the IsolatedAsyncioTestCase. 

20 

21 (see https://github.com/pylint-dev/pylint/issues/4060) 

22 """ 

23 return parse( 

24 """ 

25 from .async_case import IsolatedAsyncioTestCase 

26 """ 

27 ) 

28 

29 

30def register(manager: AstroidManager) -> None: 

31 register_module_extender(manager, "unittest", IsolatedAsyncioTestCaseImport)