MCPcopy Create free account
hub / github.com/bleachbit/bleachbit / test_assertIsLanguageCode_live

Method test_assertIsLanguageCode_live

tests/TestCommon.py:78–105  ·  view source on GitHub ↗

Test assertIsLanguageCode() using live data

(self)

Source from the content-addressed store, hash-verified

76 self.assertIsLanguageCode(code)
77
78 def test_assertIsLanguageCode_live(self):
79 """Test assertIsLanguageCode() using live data"""
80 from bleachbit import locale_dir
81 locale_dirs = list(set([locale_dir, '/usr/share/locale']))
82 lang_codes = []
83 # Skip directories that are not valid language codes
84 skip_dirs = {'l10n'}
85 for locale_dir in locale_dirs:
86 if not os.path.isdir(locale_dir):
87 continue
88 for lang_code in os.listdir(locale_dir):
89 if not os.path.isdir(os.path.join(locale_dir, lang_code)):
90 continue
91 if lang_code in skip_dirs:
92 continue
93 lang_codes.append(lang_code)
94 if os.path.exists('/etc/locale.alias'):
95 with open('/etc/locale.alias', 'r') as f:
96 for line in f:
97 line = line.strip()
98 if not line.startswith('#'):
99 parts = line.split()
100 if len(parts) > 1:
101 lang_codes.append(parts[1])
102 for lang_code in lang_codes:
103 if lang_code in common.SKIP_ALIAS_CODES:
104 continue
105 self.assertIsLanguageCode(lang_code)
106
107 def test_environment(self):
108 """Test for important environment variables"""

Callers

nothing calls this directly

Calls 2

joinMethod · 0.80
assertIsLanguageCodeMethod · 0.80

Tested by

no test coverage detected