Remove unused module imports

pull/921/head
Alex Willmer 3 years ago
parent 566d75d82f
commit 18c89de5a9

@ -7,7 +7,6 @@ import signal
import sys import sys
import ci_lib import ci_lib
from ci_lib import run
TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible')
@ -40,10 +39,10 @@ with ci_lib.Fold('job_setup'):
os.chdir(TESTS_DIR) os.chdir(TESTS_DIR)
os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7)) os.chmod('../data/docker/mitogen__has_sudo_pubkey.key', int('0600', 7))
run("mkdir %s", HOSTS_DIR) ci_lib.run("mkdir %s", HOSTS_DIR)
for path in glob.glob(TESTS_DIR + '/hosts/*'): for path in glob.glob(TESTS_DIR + '/hosts/*'):
if not path.endswith('default.hosts'): if not path.endswith('default.hosts'):
run("ln -s %s %s", path, HOSTS_DIR) ci_lib.run("ln -s %s %s", path, HOSTS_DIR)
inventory_path = os.path.join(HOSTS_DIR, 'target') inventory_path = os.path.join(HOSTS_DIR, 'target')
with open(inventory_path, 'w') as fp: with open(inventory_path, 'w') as fp:
@ -63,14 +62,14 @@ with ci_lib.Fold('job_setup'):
ci_lib.dump_file(inventory_path) ci_lib.dump_file(inventory_path)
if not ci_lib.exists_in_path('sshpass'): if not ci_lib.exists_in_path('sshpass'):
run("sudo apt-get update") ci_lib.run("sudo apt-get update")
run("sudo apt-get install -y sshpass") ci_lib.run("sudo apt-get install -y sshpass")
with ci_lib.Fold('ansible'): with ci_lib.Fold('ansible'):
playbook = os.environ.get('PLAYBOOK', 'all.yml') playbook = os.environ.get('PLAYBOOK', 'all.yml')
try: try:
run('./run_ansible_playbook.py %s -i "%s" %s', ci_lib.run('./run_ansible_playbook.py %s -i "%s" %s',
playbook, HOSTS_DIR, ' '.join(sys.argv[1:])) playbook, HOSTS_DIR, ' '.join(sys.argv[1:]))
except: except:
pause_if_interactive() pause_if_interactive()

@ -1,4 +1,3 @@
from __future__ import absolute_import from __future__ import absolute_import
from __future__ import print_function from __future__ import print_function

@ -6,7 +6,6 @@ import subprocess
import sys import sys
import ci_lib import ci_lib
from ci_lib import run
TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible') TESTS_DIR = os.path.join(ci_lib.GIT_ROOT, 'tests/ansible')
@ -52,11 +51,11 @@ with ci_lib.Fold('machine_prep'):
if os.path.expanduser('~mitogen__user1') == '~mitogen__user1': if os.path.expanduser('~mitogen__user1') == '~mitogen__user1':
os.chdir(IMAGE_PREP_DIR) os.chdir(IMAGE_PREP_DIR)
run("ansible-playbook -c local -i localhost, _user_accounts.yml") ci_lib.run("ansible-playbook -c local -i localhost, _user_accounts.yml")
with ci_lib.Fold('ansible'): with ci_lib.Fold('ansible'):
os.chdir(TESTS_DIR) os.chdir(TESTS_DIR)
playbook = os.environ.get('PLAYBOOK', 'all.yml') playbook = os.environ.get('PLAYBOOK', 'all.yml')
run('./run_ansible_playbook.py %s -l target %s', ci_lib.run('./run_ansible_playbook.py %s -l target %s',
playbook, ' '.join(sys.argv[1:])) playbook, ' '.join(sys.argv[1:]))

@ -40,10 +40,8 @@ import time
import ansible.constants as C import ansible.constants as C
import ansible.errors import ansible.errors
import ansible.plugins.connection import ansible.plugins.connection
import ansible.utils.shlex
import mitogen.core import mitogen.core
import mitogen.fork
import mitogen.utils import mitogen.utils
import ansible_mitogen.mixins import ansible_mitogen.mixins

@ -32,6 +32,8 @@ Stable names for PluginLoader instances across Ansible versions.
from __future__ import absolute_import from __future__ import absolute_import
import ansible.errors
import ansible_mitogen.utils import ansible_mitogen.utils
__all__ = [ __all__ = [

@ -36,8 +36,8 @@ import mitogen.utils
try: try:
from __main__ import display from __main__ import display
except ImportError: except ImportError:
from ansible.utils.display import Display import ansible.utils.display
display = Display() display = ansible.utils.display.Display()
#: The process name set via :func:`set_process_name`. #: The process name set via :func:`set_process_name`.

@ -43,11 +43,10 @@ import os
import random import random
import re import re
from ansible.executor import module_common import ansible.collections.list
from ansible.collections.list import list_collection_dirs
import ansible.errors import ansible.errors
import ansible.module_utils import ansible.executor.module_common
import ansible.release
import mitogen.core import mitogen.core
import mitogen.select import mitogen.select
@ -192,7 +191,7 @@ class BinaryPlanner(Planner):
@classmethod @classmethod
def detect(cls, path, source): def detect(cls, path, source):
return module_common._is_binary(source) return ansible.executor.module_common._is_binary(source)
def get_push_files(self): def get_push_files(self):
return [mitogen.core.to_text(self._inv.module_path)] return [mitogen.core.to_text(self._inv.module_path)]
@ -269,7 +268,7 @@ class JsonArgsPlanner(ScriptPlanner):
@classmethod @classmethod
def detect(cls, path, source): def detect(cls, path, source):
return module_common.REPLACER_JSONARGS in source return ansible.executor.module_common.REPLACER_JSONARGS in source
class WantJsonPlanner(ScriptPlanner): class WantJsonPlanner(ScriptPlanner):
@ -362,7 +361,7 @@ class NewStylePlanner(ScriptPlanner):
module_name='ansible_module_%s' % (self._inv.module_name,), module_name='ansible_module_%s' % (self._inv.module_name,),
module_path=self._inv.module_path, module_path=self._inv.module_path,
search_path=self.get_search_path(), search_path=self.get_search_path(),
builtin_path=module_common._MODULE_UTILS_PATH, builtin_path=ansible.executor.module_common._MODULE_UTILS_PATH,
context=self._inv.connection.context, context=self._inv.connection.context,
) )
return self._module_map return self._module_map
@ -405,7 +404,7 @@ class ReplacerPlanner(NewStylePlanner):
@classmethod @classmethod
def detect(cls, path, source): def detect(cls, path, source):
return module_common.REPLACER in source return ansible.executor.module_common.REPLACER in source
class OldStylePlanner(ScriptPlanner): class OldStylePlanner(ScriptPlanner):
@ -427,12 +426,6 @@ _planners = [
] ]
try:
_get_ansible_module_fqn = module_common._get_ansible_module_fqn
except AttributeError:
_get_ansible_module_fqn = None
def py_modname_from_path(name, path): def py_modname_from_path(name, path):
""" """
Fetch the logical name of a new-style module as it might appear in Fetch the logical name of a new-style module as it might appear in
@ -442,9 +435,10 @@ def py_modname_from_path(name, path):
package hierarchy approximated on the target, enabling relative imports package hierarchy approximated on the target, enabling relative imports
to function correctly. For example, "ansible.modules.system.setup". to function correctly. For example, "ansible.modules.system.setup".
""" """
if _get_ansible_module_fqn:
try: try:
return _get_ansible_module_fqn(path) return ansible.executor.module_common._get_ansible_module_fqn(path)
except AttributeError:
pass
except ValueError: except ValueError:
pass pass
@ -564,7 +558,7 @@ def _load_collections(invocation):
Goes through all collection path possibilities and stores paths to installed collections Goes through all collection path possibilities and stores paths to installed collections
Stores them on the current invocation to later be passed to the master service Stores them on the current invocation to later be passed to the master service
""" """
for collection_path in list_collection_dirs(): for collection_path in ansible.collections.list.list_collection_dirs():
invocation._extra_sys_paths.add(collection_path.decode('utf-8')) invocation._extra_sys_paths.add(collection_path.decode('utf-8'))

@ -31,8 +31,7 @@ from __future__ import absolute_import
import os.path import os.path
import sys import sys
from ansible.errors import AnsibleConnectionFailure import ansible.errors
from ansible.module_utils.six import iteritems
try: try:
import ansible_mitogen import ansible_mitogen
@ -61,7 +60,7 @@ class Connection(ansible_mitogen.connection.Connection):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
if not _get_result: if not _get_result:
raise AnsibleConnectionFailure(self.not_supported_msg) raise ansible.errors.AnsibleConnectionFailure(self.not_supported_msg)
super(Connection, self).__init__(*args, **kwargs) super(Connection, self).__init__(*args, **kwargs)
def get_extra_args(self): def get_extra_args(self):
@ -72,8 +71,10 @@ class Connection(ansible_mitogen.connection.Connection):
# Ansible >= 2.10, _get_result is a get_with_context_result # Ansible >= 2.10, _get_result is a get_with_context_result
connection_options = _get_result.object.connection_options connection_options = _get_result.object.connection_options
parameters = [] parameters = []
for key, option in iteritems(connection_options): for key in connection_options:
if self.get_task_var('ansible_' + key) is not None: task_var_name = 'ansible_%s' % key
parameters += [ option, self.get_task_var('ansible_' + key) ] task_var = self.get_task_var(task_var_name)
if task_var is not None:
parameters += [connection_options[key], task_var]
return parameters return parameters

@ -44,13 +44,12 @@ from __future__ import unicode_literals
import logging import logging
import os import os
import os.path
import sys import sys
import threading import threading
import ansible.constants import ansible.constants
import mitogen import mitogen.core
import mitogen.service import mitogen.service
import mitogen.utils import mitogen.utils
import ansible_mitogen.loaders import ansible_mitogen.loaders

@ -43,7 +43,7 @@ import ansible_mitogen.mixins
import ansible_mitogen.process import ansible_mitogen.process
import ansible.executor.process.worker import ansible.executor.process.worker
from ansible.utils.sentinel import Sentinel import ansible.utils.sentinel
def _patch_awx_callback(): def _patch_awx_callback():
@ -54,12 +54,11 @@ def _patch_awx_callback():
# AWX uses sitecustomize.py to force-load this package. If it exists, we're # AWX uses sitecustomize.py to force-load this package. If it exists, we're
# running under AWX. # running under AWX.
try: try:
from awx_display_callback.events import EventContext import awx_display_callback.events
from awx_display_callback.events import event_context
except ImportError: except ImportError:
return return
if hasattr(EventContext(), '_local'): if hasattr(awx_display_callback.events.EventContext(), '_local'):
# Patched version. # Patched version.
return return
@ -68,8 +67,8 @@ def _patch_awx_callback():
ctx = tls.setdefault('_ctx', {}) ctx = tls.setdefault('_ctx', {})
ctx.update(kwargs) ctx.update(kwargs)
EventContext._local = threading.local() awx_display_callback.events.EventContext._local = threading.local()
EventContext.add_local = patch_add_local awx_display_callback.events.EventContext.add_local = patch_add_local
_patch_awx_callback() _patch_awx_callback()
@ -279,7 +278,7 @@ class StrategyMixin(object):
name=task.action, name=task.action,
class_only=True, class_only=True,
) )
if play_context.connection is not Sentinel: if play_context.connection is not ansible.utils.sentinel.Sentinel:
# 2.8 appears to defer computing this until inside the worker. # 2.8 appears to defer computing this until inside the worker.
# TODO: figure out where it has moved. # TODO: figure out where it has moved.
ansible_mitogen.loaders.connection_loader.get( ansible_mitogen.loaders.connection_loader.get(

@ -51,7 +51,6 @@ import types
logging = __import__('logging') logging = __import__('logging')
import mitogen.core import mitogen.core
import mitogen.fork
import mitogen.parent import mitogen.parent
import mitogen.service import mitogen.service
from mitogen.core import b from mitogen.core import b

@ -30,7 +30,6 @@
import logging import logging
import mitogen.core
import mitogen.parent import mitogen.parent

@ -103,7 +103,6 @@ import tempfile
import threading import threading
import mitogen.core import mitogen.core
import mitogen.master
import mitogen.parent import mitogen.parent
from mitogen.core import LOG, IOLOG from mitogen.core import LOG, IOLOG

@ -28,7 +28,6 @@
# !mitogen: minify_safe # !mitogen: minify_safe
import mitogen.core
import mitogen.parent import mitogen.parent

@ -28,7 +28,6 @@
# !mitogen: minify_safe # !mitogen: minify_safe
import mitogen.core
import mitogen.parent import mitogen.parent

@ -28,7 +28,6 @@
# !mitogen: minify_safe # !mitogen: minify_safe
import mitogen.core
import mitogen.parent import mitogen.parent

@ -31,7 +31,6 @@
import logging import logging
import mitogen.core
import mitogen.parent import mitogen.parent

@ -31,7 +31,6 @@
import grp import grp
import logging import logging
import os import os
import os.path
import pprint import pprint
import pwd import pwd
import stat import stat

@ -33,10 +33,8 @@ import logging
import os import os
import sys import sys
import mitogen
import mitogen.core import mitogen.core
import mitogen.master import mitogen.master
import mitogen.parent
iteritems = getattr(dict, 'iteritems', dict.items) iteritems = getattr(dict, 'iteritems', dict.items)

@ -1,3 +1,2 @@
def path(): def path():
return "integration/module_utils/roles/modrole/module_utils/external2.py" return "integration/module_utils/roles/modrole/module_utils/external2.py"

@ -1,11 +1,11 @@
#!/usr/bin/python #!/usr/bin/python
import json import json
from ansible.module_utils.basic import path import ansible.module_utils.basic
def main(): def main():
print(json.dumps({ print(json.dumps({
'path': path() 'path': ansible.module_utils.basic.path()
})) }))
if __name__ == '__main__': if __name__ == '__main__':

@ -17,7 +17,7 @@
- custom_python_run_script: - custom_python_run_script:
script: | script: |
import atexit, shutil import atexit, os, shutil
path = '{{path}}' path = '{{path}}'
os.mkdir(path, int('777', 8)) os.mkdir(path, int('777', 8))
atexit.register(shutil.rmtree, path) atexit.register(shutil.rmtree, path)

@ -1,8 +1,5 @@
import traceback import traceback
import sys
from ansible.plugins.strategy import StrategyBase
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase

@ -1,8 +1,5 @@
import traceback import traceback
import sys
from ansible.plugins.strategy import StrategyBase
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase

@ -1,4 +1,3 @@
import sys import sys
from ansible.plugins.strategy import StrategyBase from ansible.plugins.strategy import StrategyBase

@ -5,9 +5,7 @@ required for reliable LRU tests.
import ansible_mitogen.connection import ansible_mitogen.connection
import ansible_mitogen.services import ansible_mitogen.services
import mitogen.service
from ansible.plugins.strategy import StrategyBase
from ansible.plugins.action import ActionBase from ansible.plugins.action import ActionBase

@ -1,4 +1,3 @@
# Monkey-patch os.fork() to produce a latency histogram on run completion. # Monkey-patch os.fork() to produce a latency histogram on run completion.
# Requires 'hdrhsitograms' PyPI module. # Requires 'hdrhsitograms' PyPI module.

@ -1,7 +1,6 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import io import io
import os import os
import sys
from ansible import constants as C from ansible import constants as C
from ansible.module_utils import six from ansible.module_utils import six

@ -1,4 +1,3 @@
from ansible.module_utils._text import to_text from ansible.module_utils._text import to_text

@ -1,3 +1,2 @@
def path(): def path():
return "ansible/lib/module_utils/external2.py" return "ansible/lib/module_utils/external2.py"

@ -1,3 +1,2 @@
def path(): def path():
return 'ansible/lib/module_utils/externalpkg/extmod.py' return 'ansible/lib/module_utils/externalpkg/extmod.py'

@ -4,7 +4,6 @@
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import get_module_path from ansible.module_utils.basic import get_module_path
from ansible.module_utils import six
import os import os
import pwd import pwd

@ -1,8 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
# I am an Ansible Python JSONARGS module. I should receive an encoding string. # I am an Ansible Python JSONARGS module. I should receive an encoding string.
import sys
json_arguments = """<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>""" json_arguments = """<<INCLUDE_ANSIBLE_MODULE_JSON_ARGS>>"""
print("{") print("{")

@ -5,9 +5,6 @@
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
import os import os
import pwd
import socket
import sys
def main(): def main():

@ -2,13 +2,6 @@
# issue #555: I'm a module that cutpastes an old hack. # issue #555: I'm a module that cutpastes an old hack.
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import get_module_path
from ansible.module_utils import six
import os
import pwd
import socket
import sys
import sys import sys
reload(sys) reload(sys)

@ -3,12 +3,7 @@
# parameter. # parameter.
from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import get_module_path
from ansible.module_utils import six
import os
import pwd
import socket
import sys import sys

@ -1,4 +1,3 @@
import multiprocessing import multiprocessing
import os import os
import sys import sys

@ -1,17 +1,12 @@
from __future__ import absolute_import from __future__ import absolute_import
import os import os
import os.path
import subprocess
import tempfile import tempfile
import time
import mock import mock
import ansible.errors import ansible.errors
import ansible.playbook.play_context import ansible.playbook.play_context
import mitogen.core import mitogen.core
import mitogen.utils
import ansible_mitogen.connection import ansible_mitogen.connection
import ansible_mitogen.plugins.connection.mitogen_local import ansible_mitogen.plugins.connection.mitogen_local
@ -25,7 +20,6 @@ class MuxProcessMixin(object):
@classmethod @classmethod
def setUpClass(cls): def setUpClass(cls):
#mitogen.utils.log_to_file()
cls.model = ansible_mitogen.process.get_classic_worker_model( cls.model = ansible_mitogen.process.get_classic_worker_model(
_init_logging=False _init_logging=False
) )

@ -1,5 +1,4 @@
import os import os
import sys
import tempfile import tempfile
import testlib import testlib

@ -1,4 +1,3 @@
from __future__ import absolute_import from __future__ import absolute_import
import os.path import os.path
import subprocess import subprocess

@ -1,10 +1,5 @@
# Verify _receive_one() quadratic behaviour fixed. # Verify _receive_one() quadratic behaviour fixed.
import subprocess
import time
import socket
import mitogen import mitogen
import mitogen.core import mitogen.core

@ -3,9 +3,7 @@ Measure latency of IPC between two local threads.
""" """
import threading import threading
import time
import mitogen
import mitogen.core import mitogen.core
import mitogen.utils import mitogen.utils
import ansible_mitogen.affinity import ansible_mitogen.affinity

@ -2,8 +2,6 @@
Measure latency of .local() setup. Measure latency of .local() setup.
""" """
import time
import mitogen import mitogen
import mitogen.core import mitogen.core
import mitogen.utils import mitogen.utils

@ -2,7 +2,6 @@
import sys import sys
import os import os
import time
import mitogen.core import mitogen.core

@ -2,9 +2,6 @@
Measure latency of local RPC. Measure latency of local RPC.
""" """
import time
import mitogen
import mitogen.core import mitogen.core
import mitogen.utils import mitogen.utils
import ansible_mitogen.affinity import ansible_mitogen.affinity

@ -1,9 +1,6 @@
""" """
Measure latency of local service RPC. Measure latency of local service RPC.
""" """
import time
import mitogen import mitogen
import mitogen.core import mitogen.core
import mitogen.service import mitogen.service

@ -3,9 +3,7 @@ Measure latency of SSH RPC.
""" """
import sys import sys
import time
import mitogen
import mitogen.core import mitogen.core
import mitogen.utils import mitogen.utils
import ansible_mitogen.affinity import ansible_mitogen.affinity

@ -1,11 +1,7 @@
# Verify throughput over sudo and SSH at various compression levels. # Verify throughput over sudo and SSH at various compression levels.
import os import os
import random
import socket
import subprocess
import tempfile import tempfile
import time
import mitogen import mitogen
import mitogen.core import mitogen.core

@ -1,7 +1,5 @@
import os import os
import mitogen
import testlib import testlib

@ -1,9 +1,7 @@
import logging
import time import time
import mitogen.core import mitogen.core
import mitogen.parent import mitogen.parent
import mitogen.master
from mitogen.core import str_partition from mitogen.core import str_partition
import testlib import testlib

@ -1,4 +1,3 @@
import os import os
import signal import signal
import sys import sys

@ -1,4 +1,3 @@
import pickle import pickle
import mitogen.core import mitogen.core

@ -1,9 +1,7 @@
import fcntl import fcntl
import os import os
import stat import stat
import sys import sys
import time
import tempfile import tempfile
import mitogen.core import mitogen.core

@ -1,6 +1,2 @@
import sys
def say_hi(): def say_hi():
print('hi') print('hi')

@ -1,3 +1,2 @@
from __future__ import absolute_import from __future__ import absolute_import
from module_finder_testmod.regular_mod import say_hi from module_finder_testmod.regular_mod import say_hi

@ -1,2 +1 @@
from regular_mod import say_hi from regular_mod import say_hi

@ -1,4 +1,3 @@
# coding=utf-8 # coding=utf-8
import sys import sys

@ -1,4 +1,3 @@
import simple_pkg.b import simple_pkg.b

@ -1,3 +1,2 @@
def subtract_one(n): def subtract_one(n):
return n - 1 return n - 1

@ -1,5 +1,3 @@
def ping(*args): def ping(*args):
return args return args

@ -1,4 +1,3 @@
import os import os
import sys import sys

@ -1,4 +1,3 @@
import logging import logging
import mitogen.master import mitogen.master

@ -2,7 +2,6 @@
import json import json
import os import os
import subprocess
import sys import sys
os.environ['ORIGINAL_ARGV'] = json.dumps(sys.argv) os.environ['ORIGINAL_ARGV'] = json.dumps(sys.argv)

@ -2,7 +2,6 @@
import json import json
import os import os
import subprocess
import sys import sys
import time import time

@ -1,9 +1,7 @@
import os import os
import mitogen import mitogen.core
import mitogen.doas import mitogen.doas
import mitogen.parent
import testlib import testlib

@ -1,7 +1,5 @@
import os import os
import mitogen
import testlib import testlib

@ -1,4 +1,3 @@
import os import os
import shutil import shutil
import unittest import unittest

@ -1,4 +1,3 @@
import sys import sys
import mitogen.service import mitogen.service

@ -1,4 +1,3 @@
import subprocess import subprocess
import mitogen.parent import mitogen.parent

@ -1,7 +1,5 @@
import os import os
import random import random
import struct
import sys import sys
import unittest import unittest

@ -1,4 +1,3 @@
import sys import sys
import threading import threading
import types import types

@ -1,4 +1,3 @@
import errno import errno
import select import select

@ -1,12 +1,7 @@
import unittest import unittest
import mock
import mitogen.core import mitogen.core
import testlib
try: try:
next next
except NameError: except NameError:

@ -1,9 +1,5 @@
import os import os
import mitogen
import mitogen.parent
import testlib import testlib

@ -1,9 +1,5 @@
import os import os
import mitogen
import mitogen.parent
import testlib import testlib

@ -1,4 +1,3 @@
import sys import sys
import threading import threading

@ -1,9 +1,6 @@
import os import os
import sys import sys
import mitogen
import testlib import testlib

@ -1,4 +1,3 @@
import logging import logging
import mock import mock
import sys import sys

@ -1,7 +1,7 @@
import os import os
import mitogen
import mitogen.lxc import mitogen.lxc
import mitogen.parent
try: try:
any any

@ -1,6 +1,5 @@
import os import os
import mitogen
import mitogen.lxd import mitogen.lxd
import mitogen.parent import mitogen.parent

@ -1,5 +1,4 @@
import inspect import inspect
import unittest
import testlib import testlib
import mitogen.master import mitogen.master
@ -15,7 +14,6 @@ class ScanCodeImportsTest(testlib.TestCase):
SIMPLE_EXPECT = [ SIMPLE_EXPECT = [
(level, 'inspect', ()), (level, 'inspect', ()),
(level, 'unittest', ()),
(level, 'testlib', ()), (level, 'testlib', ()),
(level, 'mitogen.master', ()), (level, 'mitogen.master', ()),
] ]

@ -1,4 +1,3 @@
import sys import sys
import struct import struct
import unittest import unittest

@ -1,4 +1,3 @@
import mock import mock
import mitogen.core import mitogen.core

@ -7,7 +7,6 @@ import mitogen.master
from mitogen.core import b from mitogen.core import b
import testlib import testlib
from testlib import MODS_DIR
class ConstructorTest(testlib.TestCase): class ConstructorTest(testlib.TestCase):
@ -87,14 +86,14 @@ class PkgutilMethodTest(testlib.TestCase):
def test_empty_source_pkg(self): def test_empty_source_pkg(self):
path, src, is_pkg = self.call('module_finder_testmod') path, src, is_pkg = self.call('module_finder_testmod')
self.assertEqual(path, self.assertEqual(path,
os.path.join(MODS_DIR, 'module_finder_testmod/__init__.py')) os.path.join(testlib.MODS_DIR, 'module_finder_testmod/__init__.py'))
self.assertEqual(mitogen.core.b(''), src) self.assertEqual(mitogen.core.b(''), src)
self.assertTrue(is_pkg) self.assertTrue(is_pkg)
def test_empty_source_module(self): def test_empty_source_module(self):
path, src, is_pkg = self.call('module_finder_testmod.empty_mod') path, src, is_pkg = self.call('module_finder_testmod.empty_mod')
self.assertEqual(path, self.assertEqual(path,
os.path.join(MODS_DIR, 'module_finder_testmod/empty_mod.py')) os.path.join(testlib.MODS_DIR, 'module_finder_testmod/empty_mod.py'))
self.assertEqual(mitogen.core.b(''), src) self.assertEqual(mitogen.core.b(''), src)
self.assertFalse(is_pkg) self.assertFalse(is_pkg)
@ -102,7 +101,7 @@ class PkgutilMethodTest(testlib.TestCase):
from module_finder_testmod import regular_mod from module_finder_testmod import regular_mod
path, src, is_pkg = self.call('module_finder_testmod.regular_mod') path, src, is_pkg = self.call('module_finder_testmod.regular_mod')
self.assertEqual(path, self.assertEqual(path,
os.path.join(MODS_DIR, 'module_finder_testmod/regular_mod.py')) os.path.join(testlib.MODS_DIR, 'module_finder_testmod/regular_mod.py'))
self.assertEqual(mitogen.core.to_text(src), self.assertEqual(mitogen.core.to_text(src),
inspect.getsource(regular_mod)) inspect.getsource(regular_mod))
self.assertFalse(is_pkg) self.assertFalse(is_pkg)
@ -165,7 +164,7 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
# plumbum has been eating too many rainbow-colored pills # plumbum has been eating too many rainbow-colored pills
import pkg_like_plumbum.colors import pkg_like_plumbum.colors
path, src, is_pkg = self.call('pkg_like_plumbum.colors') path, src, is_pkg = self.call('pkg_like_plumbum.colors')
modpath = os.path.join(MODS_DIR, 'pkg_like_plumbum/colors.py') modpath = os.path.join(testlib.MODS_DIR, 'pkg_like_plumbum/colors.py')
self.assertEqual(path, modpath) self.assertEqual(path, modpath)
with open(modpath, 'rb') as f: with open(modpath, 'rb') as f:
@ -183,7 +182,7 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
# ensure we can resolve the subpackage. # ensure we can resolve the subpackage.
path, src, is_pkg = self.call('pkg_like_ansible.module_utils.distro') path, src, is_pkg = self.call('pkg_like_ansible.module_utils.distro')
modpath = os.path.join(MODS_DIR, modpath = os.path.join(testlib.MODS_DIR,
'pkg_like_ansible/module_utils/distro/__init__.py') 'pkg_like_ansible/module_utils/distro/__init__.py')
self.assertEqual(path, modpath) self.assertEqual(path, modpath)
with open(modpath, 'rb') as f: with open(modpath, 'rb') as f:
@ -194,7 +193,7 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
path, src, is_pkg = self.call( path, src, is_pkg = self.call(
'pkg_like_ansible.module_utils.distro._distro' 'pkg_like_ansible.module_utils.distro._distro'
) )
modpath = os.path.join(MODS_DIR, modpath = os.path.join(testlib.MODS_DIR,
'pkg_like_ansible/module_utils/distro/_distro.py') 'pkg_like_ansible/module_utils/distro/_distro.py')
self.assertEqual(path, modpath) self.assertEqual(path, modpath)
with open(modpath, 'rb') as f: with open(modpath, 'rb') as f:
@ -213,7 +212,7 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
# ensure we can resolve the subpackage. # ensure we can resolve the subpackage.
path, src, is_pkg = self.call('pkg_like_ansible.module_utils.sys_distro') path, src, is_pkg = self.call('pkg_like_ansible.module_utils.sys_distro')
modpath = os.path.join(MODS_DIR, modpath = os.path.join(testlib.MODS_DIR,
'pkg_like_ansible/module_utils/sys_distro/__init__.py') 'pkg_like_ansible/module_utils/sys_distro/__init__.py')
self.assertEqual(path, modpath) self.assertEqual(path, modpath)
with open(modpath, 'rb') as f: with open(modpath, 'rb') as f:
@ -224,7 +223,7 @@ class GetModuleViaParentEnumerationTest(testlib.TestCase):
path, src, is_pkg = self.call( path, src, is_pkg = self.call(
'pkg_like_ansible.module_utils.sys_distro._distro' 'pkg_like_ansible.module_utils.sys_distro._distro'
) )
modpath = os.path.join(MODS_DIR, modpath = os.path.join(testlib.MODS_DIR,
'pkg_like_ansible/module_utils/sys_distro/_distro.py') 'pkg_like_ansible/module_utils/sys_distro/_distro.py')
self.assertEqual(path, modpath) self.assertEqual(path, modpath)
with open(modpath, 'rb') as f: with open(modpath, 'rb') as f:
@ -268,7 +267,6 @@ class FakeSshTest(testlib.TestCase):
self.assertEqual(related, [ self.assertEqual(related, [
'mitogen', 'mitogen',
'mitogen.core', 'mitogen.core',
'mitogen.master',
'mitogen.parent', 'mitogen.parent',
]) ])
@ -282,8 +280,6 @@ class FindRelatedTest(testlib.TestCase):
SIMPLE_EXPECT = set([ SIMPLE_EXPECT = set([
u'mitogen', u'mitogen',
u'mitogen.core', u'mitogen.core',
u'mitogen.master',
u'mitogen.minify',
u'mitogen.parent', u'mitogen.parent',
]) ])
@ -302,7 +298,7 @@ class FindRelatedTest(testlib.TestCase):
if sys.version_info > (2, 6): if sys.version_info > (2, 6):
class DjangoMixin(object): class DjangoMixin(object):
WEBPROJECT_PATH = os.path.join(MODS_DIR, 'webproject') WEBPROJECT_PATH = os.path.join(testlib.MODS_DIR, 'webproject')
# TODO: rip out Django and replace with a static tree of weird imports # TODO: rip out Django and replace with a static tree of weird imports
# that don't depend on .. Django! The hack below is because the version # that don't depend on .. Django! The hack below is because the version

@ -1,7 +1,5 @@
import os import os
import mitogen
import testlib import testlib

@ -1,4 +1,3 @@
import errno import errno
import os import os
import select import select

@ -1,4 +1,3 @@
import testlib import testlib
import mitogen.core import mitogen.core

@ -1,5 +1,3 @@
import os
import tempfile import tempfile
import mitogen.core import mitogen.core

@ -1,4 +1,3 @@
import signal import signal
import testlib import testlib

@ -1,4 +1,3 @@
import sys import sys
import threading import threading
import unittest import unittest

@ -1,4 +1,3 @@
import mock import mock
import textwrap import textwrap
import subprocess import subprocess

@ -1,7 +1,6 @@
import errno import errno
import os import os
import sys import sys
import time
import zlib import zlib
import testlib import testlib

@ -1,3 +1,4 @@
import mitogen.core
import mitogen.select import mitogen.select
import testlib import testlib

@ -1,11 +1,8 @@
import os
import socket import socket
import sys import sys
import unittest import unittest
import mitogen import mitogen.core
import mitogen.parent
import testlib import testlib

@ -1,4 +1,3 @@
import testlib import testlib
import mitogen.core import mitogen.core

@ -7,7 +7,6 @@ weirdness. Useful for exposing otherwise difficult to hit races in the library.
import ctypes import ctypes
import multiprocessing import multiprocessing
import os import os
import time
LIBC = ctypes.CDLL('libc.so.6') LIBC = ctypes.CDLL('libc.so.6')
sched_yield = LIBC.sched_yield sched_yield = LIBC.sched_yield

@ -1,8 +1,6 @@
import os import os
import sys
import tempfile import tempfile
import mitogen
import mitogen.ssh import mitogen.ssh
import mitogen.utils import mitogen.utils

@ -1,7 +1,6 @@
import os import os
import mitogen import mitogen.core
import mitogen.su import mitogen.su
import testlib import testlib

@ -1,9 +1,5 @@
import os import os
import mitogen
import mitogen.sudo
import testlib import testlib

@ -1,4 +1,3 @@
import errno import errno
import logging import logging
import os import os

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save