fix tests

This commit is contained in:
Maximilian Hils 2016-02-15 16:34:38 +01:00
parent d7158f975e
commit b211bef9a1
3 changed files with 12 additions and 6 deletions

View File

@ -4,7 +4,8 @@ import datetime
import re
import time
import json
import importlib
import inspect
def timestamp():
"""
@ -75,8 +76,8 @@ def pretty_duration(secs):
class Data:
def __init__(self, name):
m = __import__(name)
dirname, _ = os.path.split(m.__file__)
m = importlib.import_module(name)
dirname = os.path.dirname(inspect.getsourcefile(m))
self.dirname = os.path.abspath(dirname)
def path(self, path):

View File

@ -90,6 +90,9 @@ class RaisesContext(object):
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):

View File

@ -4,6 +4,8 @@ import re
import codecs
import unicodedata
from abc import ABCMeta, abstractmethod
import importlib
import inspect
import six
@ -186,8 +188,8 @@ def pretty_size(size):
class Data(object):
def __init__(self, name):
m = __import__(name)
dirname, _ = os.path.split(m.__file__)
m = importlib.import_module(name)
dirname = os.path.dirname(inspect.getsourcefile(m))
self.dirname = os.path.abspath(dirname)
def path(self, path):
@ -197,7 +199,7 @@ class Data(object):
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):
raise ValueError("dataPath: %s does not exist." % fullpath)
return fullpath