Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
info = get_info_from_module(Module('module2', samples_dir))
self.assertEqual(info, {'summary': 'Docstring formatted like this.',
'version': '7.0'}
)
info = get_info_from_module(Module('package1', samples_dir))
self.assertEqual(info, {'summary': 'A sample package',
'version': '0.1'}
)
info = get_info_from_module(Module('moduleunimportable', samples_dir))
self.assertEqual(info, {'summary': 'A sample unimportable module',
'version': '0.1'}
)
info = get_info_from_module(Module('modulewithconstructedversion', samples_dir))
self.assertEqual(info, {'summary': 'This module has a __version__ that requires runtime interpretation',
'version': '1.2.3'}
)
with self.assertRaises(InvalidVersion):
get_info_from_module(Module('invalid_version1', samples_dir))
info = get_info_from_module(Module('module1', samples_dir))
self.assertEqual(info, {'summary': 'Example module',
'version': '0.1'}
)
info = get_info_from_module(Module('module2', samples_dir))
self.assertEqual(info, {'summary': 'Docstring formatted like this.',
'version': '7.0'}
)
info = get_info_from_module(Module('package1', samples_dir))
self.assertEqual(info, {'summary': 'A sample package',
'version': '0.1'}
)
info = get_info_from_module(Module('moduleunimportable', samples_dir))
self.assertEqual(info, {'summary': 'A sample unimportable module',
'version': '0.1'}
)
info = get_info_from_module(Module('modulewithconstructedversion', samples_dir))
self.assertEqual(info, {'summary': 'This module has a __version__ that requires runtime interpretation',
'version': '1.2.3'}
)
with self.assertRaises(InvalidVersion):
get_info_from_module(Module('invalid_version1', samples_dir))
def test_package_importable(self):
i = Module('package1', samples_dir)
assert i.path == samples_dir / 'package1'
assert i.file == samples_dir / 'package1' / '__init__.py'
assert i.is_package
def test_get_info_from_module(self):
info = get_info_from_module(Module('module1', samples_dir))
self.assertEqual(info, {'summary': 'Example module',
'version': '0.1'}
)
info = get_info_from_module(Module('module2', samples_dir))
self.assertEqual(info, {'summary': 'Docstring formatted like this.',
'version': '7.0'}
)
info = get_info_from_module(Module('package1', samples_dir))
self.assertEqual(info, {'summary': 'A sample package',
'version': '0.1'}
)
info = get_info_from_module(Module('moduleunimportable', samples_dir))
self.assertEqual(info, {'summary': 'A sample unimportable module',
'version': '0.1'}
)
info = get_info_from_module(Module('modulewithconstructedversion', samples_dir))
self.assertEqual(info, {'summary': 'This module has a __version__ that requires runtime interpretation',
def test_module_importable(self):
i = Module('module1', samples_dir)
assert i.path == samples_dir / 'module1.py'
assert not i.is_package
self.assertEqual(info, {'summary': 'A sample package',
'version': '0.1'}
)
info = get_info_from_module(Module('moduleunimportable', samples_dir))
self.assertEqual(info, {'summary': 'A sample unimportable module',
'version': '0.1'}
)
info = get_info_from_module(Module('modulewithconstructedversion', samples_dir))
self.assertEqual(info, {'summary': 'This module has a __version__ that requires runtime interpretation',
'version': '1.2.3'}
)
with self.assertRaises(InvalidVersion):
get_info_from_module(Module('invalid_version1', samples_dir))
def test_get_info_from_module(self):
info = get_info_from_module(Module('module1', samples_dir))
self.assertEqual(info, {'summary': 'Example module',
'version': '0.1'}
)
info = get_info_from_module(Module('module2', samples_dir))
self.assertEqual(info, {'summary': 'Docstring formatted like this.',
'version': '7.0'}
)
info = get_info_from_module(Module('package1', samples_dir))
self.assertEqual(info, {'summary': 'A sample package',
'version': '0.1'}
)
info = get_info_from_module(Module('moduleunimportable', samples_dir))
self.assertEqual(info, {'summary': 'A sample unimportable module',
def test_missing_name(self):
with self.assertRaises(ValueError):
i = Module('doesnt_exist', samples_dir)
def test_get_info_from_module(self):
info = get_info_from_module(Module('module1', samples_dir))
self.assertEqual(info, {'summary': 'Example module',
'version': '0.1'}
)
info = get_info_from_module(Module('module2', samples_dir))
self.assertEqual(info, {'summary': 'Docstring formatted like this.',
'version': '7.0'}
)
info = get_info_from_module(Module('package1', samples_dir))
self.assertEqual(info, {'summary': 'A sample package',
'version': '0.1'}
)
info = get_info_from_module(Module('moduleunimportable', samples_dir))
self.assertEqual(info, {'summary': 'A sample unimportable module',
'version': '0.1'}
)
info = get_info_from_module(Module('modulewithconstructedversion', samples_dir))
self.assertEqual(info, {'summary': 'This module has a __version__ that requires runtime interpretation',
'version': '1.2.3'}
)
with self.assertRaises(InvalidVersion):
get_info_from_module(Module('invalid_version1', samples_dir))