设计用例测试下面的python程序def do_Python单元测试框架之pytest-如何执行测试用例...

sources = """

eNrsve2S3EiSIDa3+jhtnvZ293Ra6SSdCZMUF0AzK1nk9OzM1nV2L4dNznKnm6TxY6dX1XVJVAJV

halMIAkgWVU3O2d6Ar3CPYQeQn/1QjKTf8UnAplZ7O6ZPTNxpiszgQiPCA8PD3cPD/f/449+9/5H

yds/W99M58v6fDqfl1XZzefv/9nbvxuPxxE8Oy+r8+jRy2dREq+bOt8siqaNo6zKo3hRV+1mRb/h

a1UsuiKPPpRZdFncXNVN3qYRABmN3v/R23+OLbRd/v6/ePOf/tmPflSu1nXTRe1NOxotllnbRq+7

PKlPfwMw0qNR

……

"""

import sys

import base64

import zlib

class DictImporter(object):

def __init__(self, sources):

self.sources = sources

def find_module(self, fullname, path=None):

if fullname == "argparse" and sys.version_info >= (2,7):

# we were generated with

# but we are running now on a stdlib which has it, so use that.

return None

if fullname in self.sources:

return self

if fullname + '.__init__' in self.sources:

return self

return None

def load_module(self, fullname):

# print "load_module:",  fullname

from types import ModuleType

try:

s = self.sources[fullname]

is_pkg = False

except KeyError:

s = self.sources[fullname + '.__init__']

is_pkg = True

co = compile(s, fullname, 'exec')

module = sys.modules.setdefault(fullname, ModuleType(fullname))

module.__file__ = "%s/%s" % (__file__, fullname)

module.__loader__ = self

if is_pkg:

module.__path__ = [fullname]

do_exec(co, module.__dict__) # noqa

return sys.modules[fullname]

def get_source(self, name):

res = self.sources.get(name)

if res is None:

res = self.sources.get(name + '.__init__')

return res

if __name__ == "__main__":

if sys.version_info >= (3, 0):

exec("def do_exec(co, loc): exec(co, loc)\n")

import pickle

sources = sources.encode("ascii") # ensure bytes

sources = pickle.loads(zlib.decompress(base64.decodebytes(sources)))

else:

import cPickle as pickle

exec("def do_exec(co, loc): exec co in loc\n")

sources = pickle.loads(zlib.decompress(base64.decodestring(sources)))

importer = DictImporter(sources)

sys.meta_path.insert(0, importer)

entry = "import pytest; raise SystemExit(pytest.cmdline.main())"

do_exec(entry, locals()) # noqa

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值