草庐IT

TEST_RESULTS

全部标签

python - py.test 导入错误 "- ' 找不到配置。”

在尝试将py.test功能添加到FlaskAPI时,我在源目录上调用py.test时遇到了以下错误消息EImportStringError:import_string()failedfor'config'.Possiblereasonsare:EE-missing__init__.pyinapackage;E-packageormodulepathnotincludedinsys.path;E-duplicatedpackageormodulenametakingprecedenceinsys.path;E-missingmodule,class,functionorvariable;

python - 使用 py.test + gevent 确定测试覆盖率

py.test+gevent如何得到准确的测试覆盖率报告?我已经尝试过显而易见的事情,使用py.test的pytest-cov插件,但它generatesinaccuratereportswhengeventisinuse. 最佳答案 geventcoverageissue最近在coveragepy中得到修复。但是,pytest-cov无法运行coverage>=4。一个可能的修复方法是在不使用pytest-cov插件的情况下,使用较新版本的coverage.py运行py.test。首先,安装coverage>=4并卸载pytest

python - Django 单元测试 : How to test concurrent database operations?

我正在创建一个使用optimisticconcurrencycontrol的Django库以防止并发写入导致数据不一致。我希望能够为此功能编写单元测试,但我不确定如何实现。我知道Django的单元测试是单线程的,所以我可以设想测试工作的唯一方法是同时打开两个单独的数据库连接(到同一个数据库)并切换DjangoORM在执行查询时使用哪个连接,尽管我不确定在Django中是否可以进行连接切换。使用Django测试并发数据库操作有哪些技巧? 最佳答案 Whataresometechniquesfortestingconcurrentdat

python - 使用 selenium 运行 django-test 时管道错误

在使用selenium运行django测试时(没有远程,没有xvfb),我总是得到以下异常:Creatingtestdatabaseforalias'default'...Traceback(mostrecentcalllast):File"/usr/lib/python2.7/wsgiref/handlers.py",line86,inrunself.finish_response()File"/usr/lib/python2.7/wsgiref/handlers.py",line127,infinish_responseself.write(data)File"/usr/lib/p

python - setup_method 中的 py.test session 级固定装置

有没有办法在测试类的设置中以某种方式使用conftest.py中的pytestfixture?我需要在session开始时初始化一个对象,并在某些测试类的设置中使用它。是这样的:#conftest.py:importpytest@pytest.fixture(scope="session",autouse=True)defmyfixture(request):return"myfixture"#test_aaa.pyclassTestAAA(object):defsetup(self,method,myfixture):print("setupmyfixture:{}".format(

python - Django-REST 序列化程序 : Queryset does not filter PrimaryKeyRelatedField results

所以我有一个看起来像这样的序列化器classBuildingsSerializer(serializers.ModelSerializer):masterlisting_set=serializers.PrimaryKeyRelatedField(many=True,queryset=Masterlistings.objects.all())效果很好serializer=BuildingsSerializer(Buildings.objects.get(pk=1))serializer.data产生OrderedDict([("masterlistings_set",["0a06e3d

python - 喀拉斯 LSTM : a time-series multi-step multi-features forecasting - poor results

我有一个包含全年数据的时间序列数据集(日期是索引)。每15分钟(全年)测量一次数据,这导致每天有96个时间步长。数据已经标准化。变量是相关的。除VAR外的所有变量都是天气指标。VAR在一天和一周内是季节性的(因为它在周末看起来有点不同,但每个周末都差不多)。VAR值是固定的。我想预测接下来两天(提前192步)和接下来7天(提前672步)的VAR值。这是数据集的样本:DateIdxVARdewpthumpresstemp2017-04-1700:00:000.3693970.1550390.3867920.1967210.2388892017-04-1700:15:000.3632140

python doctest : expected result is the same as the "got" result but the test failed

我正处于使用python作为软件QA工具的学习阶段。我编写了下一个简单测试,以便在文本文件编号矩阵中找到字母“a”。问题是测试失败,即使期望值等于我得到的结果。这是为什么呢?你能告诉我我做错了什么吗?测试脚本:fin=open("abc.txt","r")arr_fin=[]forlineinfin:arr_fin.append(line.split())printarr_finforrowinarr_fin:arr_fin_1="".join('{0:4}'.format(ior"")foriinrow)printarr_fin_1deffind_letter(x,arr_fin_1

python 2.7 : test if characters in a string are all Chinese characters

下面的代码测试字符串中的字符是否都是汉字。它适用于Python3但不适用于Python2.7。我如何在Python2.7中执行此操作?forchinname:iford(ch)0x9fff:returnFalse 最佳答案 #bytestr(youprobablygetfromGAE)In[1]:s="""Chinese(汉语/漢語Hànyǔor中文Zhōngwén)isagroupofrelatedlanguagevarieties,severalofwhicharenotmutuallyintelligible,"""#unic

python - 蝗虫 : How to invoke the test through an API

我想通过API调用Locust负载测试,以便能够从CI工具开始测试。我没有看到很多关于这种情况的文档,locustAPI中没有“Runner”或类似的类文档。我检查了在Windows中安装后可用的“locust”命令。它是一个.exe,所以不确定它的作用以及它如何实际启动测试所以,具体的问题是,是否有一个接口(interface)可以从另一个Python程序开始测试 最佳答案 目前,除命令行界面外,没有记录在案的用于控制蝗虫的API。CLI可用于开始运行负载测试,但目前无法在没有WebUI的情况下运行分布式Locust。您也可以将W