From fea45177383dbdd496339154469439e8c76a7c3c Mon Sep 17 00:00:00 2001 From: debugtalk Date: Thu, 9 Aug 2018 00:54:57 +0800 Subject: [PATCH] remove get_imported_module_from_file --- httprunner/utils.py | 21 ++------------------- tests/test_utils.py | 12 ------------ 2 files changed, 2 insertions(+), 31 deletions(-) diff --git a/httprunner/utils.py b/httprunner/utils.py index ab58f65d..02a5b50f 100644 --- a/httprunner/utils.py +++ b/httprunner/utils.py @@ -3,20 +3,16 @@ import copy import hashlib import hmac -import imp -import importlib import io import itertools import json import os.path import random import string -import types from datetime import datetime -from httprunner import exceptions, logger, validator -from httprunner.compat import OrderedDict, basestring, is_py2, is_py3 -from requests.structures import CaseInsensitiveDict +from httprunner import exceptions, logger +from httprunner.compat import OrderedDict, basestring, is_py2 SECRET_KEY = "DebugTalk" @@ -147,19 +143,6 @@ def deep_update_dict(origin_dict, override_dict): return origin_dict -def get_imported_module_from_file(file_path): - """ DEPRECATED: import module from python file path and return imported module - """ - if is_py3: - imported_module = importlib.machinery.SourceFileLoader( - 'module_name', file_path).load_module() - elif is_py2: - imported_module = imp.load_source('module_name', file_path) - else: - raise RuntimeError("Neither Python 3 nor Python 2.") - - return imported_module - def lower_dict_keys(origin_dict): """ convert keys in dict to lower case e.g. diff --git a/tests/test_utils.py b/tests/test_utils.py index 03d89bc3..35059814 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -155,18 +155,6 @@ class TestUtils(ApiServerUnittest): {'a': 2, 'b': {'c': 33, 'd': 4, 'e': 5}, 'f': 6, 'g': 7, 'h': 123} ) - def test_get_imported_module_from_file(self): - imported_module = utils.get_imported_module_from_file("tests/debugtalk.py") - self.assertIn("gen_md5", dir(imported_module)) - - module_mapping = loader.load_python_module(imported_module) - functions_dict = module_mapping["functions"] - self.assertIn("gen_md5", functions_dict) - self.assertNotIn("urllib", functions_dict) - - with self.assertRaises(exceptions.FileNotFoundError): - utils.get_imported_module_from_file("tests/debugtalk2.py") - def test_handle_config_key_case(self): origin_dict = { "Name": "test",