From ffb776ca6cf0cefefed16fb36a4e161f46a724d7 Mon Sep 17 00:00:00 2001 From: Sheng Date: Thu, 26 Apr 2018 22:38:03 +0800 Subject: [PATCH] Use absolute path for importing modules --- tests/__init__.py | 4 ---- tests/sshserver.py | 2 +- tests/test_app.py | 6 +++--- tests/test_handler.py | 2 +- tests/test_policy.py | 6 ++++-- tests/test_settings.py | 6 ++++-- webssh/handler.py | 2 +- webssh/main.py | 6 +++--- webssh/settings.py | 4 +++- 9 files changed, 20 insertions(+), 18 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 6944a8d..e69de29 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,4 +0,0 @@ -import sys - - -sys.path.insert(0, 'webssh') diff --git a/tests/sshserver.py b/tests/sshserver.py index 207ad9b..d976050 100644 --- a/tests/sshserver.py +++ b/tests/sshserver.py @@ -29,7 +29,7 @@ from paramiko.py3compat import u, decodebytes # setup logging -paramiko.util.log_to_file('sshserver.log') +paramiko.util.log_to_file('tests/sshserver.log') host_key = paramiko.RSAKey(filename='tests/test_rsa.key') # host_key = paramiko.DSSKey(filename='test_dss.key') diff --git a/tests/test_app.py b/tests/test_app.py index ffbcc55..4e9d2bc 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -1,5 +1,5 @@ import json -import handler +import webssh.handler as handler import random import threading import tornado.websocket @@ -7,8 +7,8 @@ import tornado.gen from tornado.testing import AsyncHTTPTestCase from tornado.options import options -from main import make_app, make_handlers -from settings import get_app_settings +from webssh.main import make_app, make_handlers +from webssh.settings import get_app_settings from tests.sshserver import run_ssh_server diff --git a/tests/test_handler.py b/tests/test_handler.py index 88412ba..9170a6e 100644 --- a/tests/test_handler.py +++ b/tests/test_handler.py @@ -3,7 +3,7 @@ import os.path import paramiko from tornado.httputil import HTTPServerRequest -from handler import MixinHandler, IndexHandler +from webssh.handler import MixinHandler, IndexHandler class TestMixinHandler(unittest.TestCase): diff --git a/tests/test_policy.py b/tests/test_policy.py index a4fbf9c..619acf0 100644 --- a/tests/test_policy.py +++ b/tests/test_policy.py @@ -4,8 +4,10 @@ import paramiko from shutil import copyfile from paramiko.client import RejectPolicy, WarningPolicy -from policy import (AutoAddPolicy, get_policy_dictionary, load_host_keys, - get_policy_class, check_policy_setting) +from webssh.policy import ( + AutoAddPolicy, get_policy_dictionary, load_host_keys, + get_policy_class, check_policy_setting +) class TestPolicy(unittest.TestCase): diff --git a/tests/test_settings.py b/tests/test_settings.py index ad4fe56..a2d0f43 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -3,8 +3,10 @@ import unittest import paramiko import tornado.options as options -from settings import get_host_keys_settings, get_policy_setting, base_dir -from policy import load_host_keys +from webssh.settings import ( + get_host_keys_settings, get_policy_setting, base_dir +) +from webssh.policy import load_host_keys class TestSettings(unittest.TestCase): diff --git a/webssh/handler.py b/webssh/handler.py index 1f4df72..535fb4a 100644 --- a/webssh/handler.py +++ b/webssh/handler.py @@ -8,7 +8,7 @@ import paramiko import tornado.web from tornado.ioloop import IOLoop -from worker import Worker, recycle_worker, workers +from webssh.worker import Worker, recycle_worker, workers try: from concurrent.futures import Future diff --git a/webssh/main.py b/webssh/main.py index 7179193..b86cb35 100644 --- a/webssh/main.py +++ b/webssh/main.py @@ -3,9 +3,9 @@ import tornado.web import tornado.ioloop from tornado.options import parse_command_line, options -from handler import IndexHandler, WsockHandler -from settings import (get_app_settings, get_host_keys_settings, - get_policy_setting) +from webssh.handler import IndexHandler, WsockHandler +from webssh.settings import (get_app_settings, get_host_keys_settings, + get_policy_setting) def make_handlers(loop, options): diff --git a/webssh/settings.py b/webssh/settings.py index a286c36..ed03bb3 100644 --- a/webssh/settings.py +++ b/webssh/settings.py @@ -3,7 +3,9 @@ import os.path import uuid from tornado.options import define -from policy import load_host_keys, get_policy_class, check_policy_setting +from webssh.policy import ( + load_host_keys, get_policy_class, check_policy_setting +) define('address', default='127.0.0.1', help='listen address')