Coverage for tests/test_000_emcd_projects/test_000_package.py: 100%

26 statements  

« prev     ^ index     » next       coverage.py v7.6.12, created at 2025-02-24 01:25 +0000

1# vim: set filetype=python fileencoding=utf-8: 

2# -*- coding: utf-8 -*- 

3 

4#============================================================================# 

5# # 

6# Licensed under the Apache License, Version 2.0 (the "License"); # 

7# you may not use this file except in compliance with the License. # 

8# You may obtain a copy of the License at # 

9# # 

10# http://www.apache.org/licenses/LICENSE-2.0 # 

11# # 

12# Unless required by applicable law or agreed to in writing, software # 

13# distributed under the License is distributed on an "AS IS" BASIS, # 

14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # 

15# See the License for the specific language governing permissions and # 

16# limitations under the License. # 

17# # 

18#============================================================================# 

19 

20 

21''' Assert basic characteristics of package and modules thereof. ''' 

22 

23 

24import pytest 

25 

26from . import ( 

27 MODULES_NAMES_BY_MODULE_QNAME, 

28 MODULES_QNAMES, 

29 PACKAGES_NAMES, 

30 PACKAGES_NAMES_BY_MODULE_QNAME, 

31 cache_import_module, 

32) 

33 

34 

35@pytest.mark.parametrize( 'package_name', PACKAGES_NAMES ) 

36def test_000_sanity( package_name ): 

37 ''' Package is sane. ''' 

38 package = cache_import_module( package_name ) 

39 assert package.__package__ == package_name 

40 assert package.__name__ == package_name 

41 

42 

43@pytest.mark.parametrize( 'module_qname', MODULES_QNAMES ) 

44def test_010_attribute_module_existence( module_qname ): 

45 ''' Package module is attribute of package. ''' 

46 package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ] 

47 package = cache_import_module( package_name ) 

48 module_name = MODULES_NAMES_BY_MODULE_QNAME[ module_qname ] 

49 assert module_name in package.__dict__ 

50 

51 

52@pytest.mark.parametrize( 'module_qname', MODULES_QNAMES ) 

53def test_011_attribute_module_classification( module_qname ): 

54 ''' Package attribute is module. ''' 

55 from inspect import ismodule 

56 package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ] 

57 package = cache_import_module( package_name ) 

58 module_name = MODULES_NAMES_BY_MODULE_QNAME[ module_qname ] 

59 assert ismodule( getattr( package, module_name ) ) 

60 

61 

62@pytest.mark.parametrize( 'module_qname', MODULES_QNAMES ) 

63def test_100_sanity( module_qname ): 

64 ''' Package module is sane. ''' 

65 package_name = PACKAGES_NAMES_BY_MODULE_QNAME[ module_qname ] 

66 module = cache_import_module( module_qname ) 

67 assert module.__package__ == package_name 

68 assert module.__name__ == module_qname