草庐IT

test-Path

全部标签

python - 在不修改sys.path或第三方软件包的情况下,在Python软件包中导入供应商依赖性

概要我正在为Anki(开源抽认卡程序)开发一系列附加组件。Anki附加组件以Python软件包的形式提供,其基本文件夹结构如下所示:anki_addons/addon_name_1/__init__.pyaddon_name_2/__init__.py基本应用程序将anki_addons附加到sys.path,然后将其与import导入每个add_on。我一直试图解决的问题是找到一种可靠的方式来将运送的包裹及其依赖项与我的附加组件一起使用,同时又不污染全局状态或不退回对供应商包裹的手动编辑。细节具体来说,给定这样的附加结构...addon_name_1/__init__.py_vend

python - 测试 : parametrize test cases from classes

我目前正在关注这个py.test示例,当我不使用类时它会成功,但是当我将测试用例引入类时我失败了。我设法编写的最小案例如下:importunittestimportpytestclassFixtureTestCase(unittest.TestCase):@pytest.mark.parametrize("test_input,expected",[("3+5",8),("2+4",6),("6*9",42),])deftest_1(self,a,b):self.assertEqual(a,b)不幸的是当我执行py.testtest_suite.py我收到错误信息:TypeError:

python - 测试 : parametrize test cases from classes

我目前正在关注这个py.test示例,当我不使用类时它会成功,但是当我将测试用例引入类时我失败了。我设法编写的最小案例如下:importunittestimportpytestclassFixtureTestCase(unittest.TestCase):@pytest.mark.parametrize("test_input,expected",[("3+5",8),("2+4",6),("6*9",42),])deftest_1(self,a,b):self.assertEqual(a,b)不幸的是当我执行py.testtest_suite.py我收到错误信息:TypeError:

python - XGBoostLibraryNotFound : Cannot find XGBoost Library in the candidate path, 您是否安装了编译器并在根路径中运行了 build.sh?

我在移动XGBoost的python-package目录时遇到了这个问题。Traceback(mostrecentcalllast):File"setup.py",line19,inLIB_PATH=libpath'find_lib_path'File"xgboost/libpath.py",line46,infind_lib_path'Listofcandidates:\n'+('\n'.join(dll_path)))builtin.XGBoostLibraryNotFound:CannotfindXGBoostLibraryinthecandidatepath,didyouins

python - XGBoostLibraryNotFound : Cannot find XGBoost Library in the candidate path, 您是否安装了编译器并在根路径中运行了 build.sh?

我在移动XGBoost的python-package目录时遇到了这个问题。Traceback(mostrecentcalllast):File"setup.py",line19,inLIB_PATH=libpath'find_lib_path'File"xgboost/libpath.py",line46,infind_lib_path'Listofcandidates:\n'+('\n'.join(dll_path)))builtin.XGBoostLibraryNotFound:CannotfindXGBoostLibraryinthecandidatepath,didyouins

python - py.test 测试 flask 寄存器,AssertionError : Popped wrong request context

我正在使用Flask进行注册和登录:fromflask.ext.security.viewsimportregister,loginclassRegister(Resource):defpost(self):returnregister()classLogin(Resource):defpost(self):returnlogin()api.add_resource(Login,'/login')api.add_resource(Register,'/register')然后我使用py.test来测试这个类:classTestAPI:deftest_survey(self,app):c

python - py.test 测试 flask 寄存器,AssertionError : Popped wrong request context

我正在使用Flask进行注册和登录:fromflask.ext.security.viewsimportregister,loginclassRegister(Resource):defpost(self):returnregister()classLogin(Resource):defpost(self):returnlogin()api.add_resource(Login,'/login')api.add_resource(Register,'/register')然后我使用py.test来测试这个类:classTestAPI:deftest_survey(self,app):c

python - py.test SetUp/TearDown 用于整个测试套件

我有一个Python包需要访问X11。我想使用Xvfb,这样我就不必在构建机器上安装真正的X11——在本例中是Hudson。所以,我想在py.test启动时启动一个Xvfb服务器,使用该服务器进行所有测试,然后关闭它。我该怎么做?注意:我可以在每个测试类的SetUp(TearDown)中启动(停止)一个Xvfb服务器,但这有两个问题:首先,它很浪费。其次,如果我正确终止服务器,或者我挂起的Xvfb进程不会死,则它不会工作,因为奇怪的X服务器上的致命IO错误0(成功)。这是使用xvfbwrapper如果有人感兴趣。 最佳答案 你可以使

python - py.test SetUp/TearDown 用于整个测试套件

我有一个Python包需要访问X11。我想使用Xvfb,这样我就不必在构建机器上安装真正的X11——在本例中是Hudson。所以,我想在py.test启动时启动一个Xvfb服务器,使用该服务器进行所有测试,然后关闭它。我该怎么做?注意:我可以在每个测试类的SetUp(TearDown)中启动(停止)一个Xvfb服务器,但这有两个问题:首先,它很浪费。其次,如果我正确终止服务器,或者我挂起的Xvfb进程不会死,则它不会工作,因为奇怪的X服务器上的致命IO错误0(成功)。这是使用xvfbwrapper如果有人感兴趣。 最佳答案 你可以使

Python Proportion 测试类似于 R 中的 prop.test

我正在寻找执行此操作的Python测试:>survivorscolnames(survivors)rownames(survivors)survivorssurviveddiednoseatbelt1781135seatbelt144347>prop.test(survivors)2-sampletestforequalityofproportionswithcontinuitycorrectiondata:survivorsX-squared=24.3328,df=1,p-value=8.105e-07alternativehypothesis:two.sided95percentc