File: test_import_finder.py

package info (click to toggle)
importlab 0.8.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 292 kB
  • sloc: python: 1,761; sh: 14; makefile: 6
file content (25 lines) | stat: -rw-r--r-- 771 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Tests for import_finder.py."""

import sys
import unittest

from importlab import import_finder


class TestImportFinder(unittest.TestCase):
    """Tests for import_finder."""

    def test_find_submodule(self):
        # networkx should always be findable because importlab uses it.
        name = 'networkx.algorithms.cluster'
        self.assertIsNotNone(import_finder.resolve_import(name, True, False))

    @unittest.skipIf(sys.version_info[0] == 2, 'py2 uses imp, not importlib')
    def test_importlib_exception(self):
        from unittest import mock
        with mock.patch('importlib.util.find_spec', side_effect=AssertionError):
            self.assertIsNone(import_finder.resolve_import('', False, False))


if __name__ == '__main__':
    unittest.main()