mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2024-11-27 02:24:18 +00:00
fix tests
This commit is contained in:
parent
d7158f975e
commit
b211bef9a1
@ -4,7 +4,8 @@ import datetime
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
|
import importlib
|
||||||
|
import inspect
|
||||||
|
|
||||||
def timestamp():
|
def timestamp():
|
||||||
"""
|
"""
|
||||||
@ -75,8 +76,8 @@ def pretty_duration(secs):
|
|||||||
class Data:
|
class Data:
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
m = __import__(name)
|
m = importlib.import_module(name)
|
||||||
dirname, _ = os.path.split(m.__file__)
|
dirname = os.path.dirname(inspect.getsourcefile(m))
|
||||||
self.dirname = os.path.abspath(dirname)
|
self.dirname = os.path.abspath(dirname)
|
||||||
|
|
||||||
def path(self, path):
|
def path(self, path):
|
||||||
|
@ -90,6 +90,9 @@ class RaisesContext(object):
|
|||||||
|
|
||||||
|
|
||||||
test_data = utils.Data(__name__)
|
test_data = utils.Data(__name__)
|
||||||
|
# FIXME: Temporary workaround during repo merge.
|
||||||
|
import os
|
||||||
|
test_data.dirname = os.path.join(test_data.dirname,"..","..","test","netlib")
|
||||||
|
|
||||||
|
|
||||||
def treq(**kwargs):
|
def treq(**kwargs):
|
||||||
|
@ -4,6 +4,8 @@ import re
|
|||||||
import codecs
|
import codecs
|
||||||
import unicodedata
|
import unicodedata
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
import importlib
|
||||||
|
import inspect
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
@ -186,8 +188,8 @@ def pretty_size(size):
|
|||||||
class Data(object):
|
class Data(object):
|
||||||
|
|
||||||
def __init__(self, name):
|
def __init__(self, name):
|
||||||
m = __import__(name)
|
m = importlib.import_module(name)
|
||||||
dirname, _ = os.path.split(m.__file__)
|
dirname = os.path.dirname(inspect.getsourcefile(m))
|
||||||
self.dirname = os.path.abspath(dirname)
|
self.dirname = os.path.abspath(dirname)
|
||||||
|
|
||||||
def path(self, path):
|
def path(self, path):
|
||||||
@ -197,7 +199,7 @@ class Data(object):
|
|||||||
|
|
||||||
This function will raise ValueError if the path does not exist.
|
This function will raise ValueError if the path does not exist.
|
||||||
"""
|
"""
|
||||||
fullpath = os.path.join(self.dirname, '../test/', path)
|
fullpath = os.path.join(self.dirname, path)
|
||||||
if not os.path.exists(fullpath):
|
if not os.path.exists(fullpath):
|
||||||
raise ValueError("dataPath: %s does not exist." % fullpath)
|
raise ValueError("dataPath: %s does not exist." % fullpath)
|
||||||
return fullpath
|
return fullpath
|
||||||
|
Loading…
Reference in New Issue
Block a user