Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mitogen
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
mitogen
Commits
ced6d8e4
Commit
ced6d8e4
authored
Sep 25, 2017
by
David Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix up importer_test.
parent
c810f66b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
tests/importer_test.py
tests/importer_test.py
+16
-16
No files found.
tests/importer_test.py
View file @
ced6d8e4
...
...
@@ -12,13 +12,13 @@ import mitogen.core
import
testlib
class
ImporterMixin
(
object
):
class
ImporterMixin
(
testlib
.
RouterMixin
):
modname
=
None
def
setUp
(
self
):
super
(
ImporterMixin
,
self
).
setUp
()
self
.
context
=
mock
.
Mock
()
self
.
importer
=
mitogen
.
core
.
Importer
(
self
.
context
)
self
.
importer
=
mitogen
.
core
.
Importer
(
self
.
router
,
self
.
context
,
''
)
def
tearDown
(
self
):
sys
.
modules
.
pop
(
self
.
modname
,
None
)
...
...
@@ -32,28 +32,28 @@ class LoadModuleTest(ImporterMixin, unittest.TestCase):
response
=
(
None
,
path
,
data
)
def
test_no_such_module
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
None
self
.
context
.
send_await
.
return_value
=
None
self
.
assertRaises
(
ImportError
,
lambda
:
self
.
importer
.
load_module
(
self
.
modname
))
def
test_module_added_to_sys_modules
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertTrue
(
sys
.
modules
[
self
.
modname
]
is
mod
)
self
.
assertTrue
(
isinstance
(
mod
,
types
.
ModuleType
))
def
test_module_file_set
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertEquals
(
mod
.
__file__
,
'master:'
+
self
.
path
)
def
test_module_loader_set
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertTrue
(
mod
.
__loader__
is
self
.
importer
)
def
test_module_package_unset
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertTrue
(
mod
.
__package__
is
None
)
...
...
@@ -65,7 +65,7 @@ class LoadSubmoduleTest(ImporterMixin, unittest.TestCase):
response
=
(
None
,
path
,
data
)
def
test_module_package_unset
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertEquals
(
mod
.
__package__
,
'mypkg'
)
...
...
@@ -77,45 +77,45 @@ class LoadModulePackageTest(ImporterMixin, unittest.TestCase):
response
=
([],
path
,
data
)
def
test_module_file_set
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertEquals
(
mod
.
__file__
,
'master:'
+
self
.
path
)
def
test_get_filename
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
filename
=
mod
.
__loader__
.
get_filename
(
self
.
modname
)
self
.
assertEquals
(
'master:fake_pkg/__init__.py'
,
filename
)
def
test_get_source
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
source
=
mod
.
__loader__
.
get_source
(
self
.
modname
)
self
.
assertEquals
(
source
,
zlib
.
decompress
(
self
.
data
))
def
test_module_loader_set
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertTrue
(
mod
.
__loader__
is
self
.
importer
)
def
test_module_path_present
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertEquals
(
mod
.
__path__
,
[])
def
test_module_package_set
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertEquals
(
mod
.
__package__
,
self
.
modname
)
def
test_module_data
(
self
):
self
.
context
.
enqueue_await_reply
.
return_value
=
self
.
response
self
.
context
.
send_await
.
return_value
=
self
.
response
mod
=
self
.
importer
.
load_module
(
self
.
modname
)
self
.
assertTrue
(
isinstance
(
mod
.
func
,
types
.
FunctionType
))
self
.
assertEquals
(
mod
.
func
.
__module__
,
self
.
modname
)
class
EmailParseAddrSysTest
(
testlib
.
Brok
erMixin
,
unittest
.
TestCase
):
class
EmailParseAddrSysTest
(
testlib
.
Rout
erMixin
,
unittest
.
TestCase
):
@
pytest
.
fixture
(
autouse
=
True
)
def
initdir
(
self
,
caplog
):
self
.
caplog
=
caplog
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment