This repository was archived by the owner on Nov 21, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtests.py
More file actions
40 lines (28 loc) · 1.23 KB
/
tests.py
File metadata and controls
40 lines (28 loc) · 1.23 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
import sys
import unittest
from unittest.mock import patch
from gothon import *
class TestGothon(unittest.TestCase):
maxDiff, __slots__ = None, ()
def test_GoImporter(self):
go_importer = GoImporter([])
result = go_importer.find_module("python_module")
self.assertIsInstance(result, GoImporter)
self.assertEqual(result.go_path, 'python_module.go')
self.assertEqual(result.module_names, ([], ))
self.assertTrue(callable(result.find_module))
self.assertTrue(callable(result.load_module))
go_importer.load_module("python_module")
self.assertIsInstance(result, GoImporter)
self.assertEqual(result.go_path, 'python_module.go')
self.assertEqual(result.module_names, ([], ))
self.assertTrue(callable(result.find_module))
self.assertTrue(callable(result.load_module))
def test_import_hook(self):
with patch.object(sys, 'path_hooks', []):
with patch.object(sys, 'meta_path', []):
result = import_hook()
self.assertIsInstance(result, GoImporter)
self.assertTrue(len(sys.path_hooks) == 1)
self.assertTrue(len(sys.meta_path) == 1)