-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
82 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
import unittest | ||
import sys | ||
|
||
import stdlib_list | ||
|
||
|
||
class CurrentVersionBase(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.list = stdlib_list.stdlib_list(sys.version[:3]) | ||
|
||
|
||
class TestCurrentVersion(CurrentVersionBase): | ||
|
||
def test_string(self): | ||
self.assertIn('string', self.list) | ||
|
||
def test_list_is_sorted(self): | ||
self.assertEqual(sorted(self.list), self.list) | ||
|
||
def test_builtin_modules(self): | ||
"""Check all top level stdlib packages are recognised.""" | ||
unknown_builtins = set() | ||
for module_name in sys.builtin_module_names: | ||
if module_name not in self.list: | ||
unknown_builtins.add(module_name) | ||
|
||
self.assertFalse(sorted(unknown_builtins)) | ||
|
||
|
||
class TestSysModules(CurrentVersionBase): | ||
|
||
# This relies on invocation in a clean python environment using unittest | ||
# not using pytest. | ||
|
||
ignore_list = [ | ||
'stdlib_list', 'functools32', | ||
] | ||
|
||
def setUp(self): | ||
super(TestSysModules, self).setUp() | ||
self.maxDiff = None | ||
|
||
def test_preloaded_packages(self): | ||
"""Check all top level stdlib packages are recognised.""" | ||
not_stdlib = set() | ||
for module_name in sys.modules: | ||
pkg, _, module = module_name.partition('.') | ||
if pkg in self.ignore_list: | ||
continue | ||
|
||
# Avoid duplicating errors covered by other tests | ||
if pkg in sys.builtin_module_names: | ||
continue | ||
|
||
if pkg not in self.list: | ||
not_stdlib.add(pkg) | ||
|
||
self.assertFalse(sorted(not_stdlib)) | ||
|
||
def test_preloaded_modules(self): | ||
"""Check all stdlib modules are recognised.""" | ||
not_stdlib = set() | ||
for module_name in sys.modules: | ||
pkg, _, module = module_name.partition('.') | ||
if pkg in self.ignore_list: | ||
continue | ||
|
||
# Avoid duplicating errors covered by other tests | ||
if module_name in sys.builtin_module_names: | ||
continue | ||
|
||
if module_name not in self.list: | ||
not_stdlib.add(module_name) | ||
|
||
self.assertFalse(sorted(not_stdlib)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |