草庐IT

dyld_stub_binder

全部标签

node.js - 使用 Sinon 时,如何替换 stub 实例中的 stub 函数?

如果我通过vara=sinon.createStubInstance(MyContructor)创建了一个实例。如何替换varstub=sinon.stub(object,"method",func);之类的stub函数之一;.我这样做的主要原因是想要实现多个回调解决方法,如thismentioned 最佳答案 您提到的方法(sinon.stub(object,"method",func))是版本1.x中可用的方法,并且做了根据文档:Replacesobject.methodwithafunc,wrappedinaspy.Asusu

node.js - 带有 AWS-SDK 的 Node 中的 Sinon.Stub

我正在尝试为使用aws-sdkNPM模块的应用程序编写一些测试覆盖率,该模块将事物推送到SQS队列,但我不确定如何正确地模拟事物。这是我目前的测试:varrequest=require('superagent'),expect=require('chai').expect,assert=require('chai').assert,sinon=require('sinon'),AWS=require('aws-sdk'),app=require("../../../../app");describe("Activities",function(){describe("POST/acti

javascript - 在 Node 环境中 stub jQuery.ajax (jQuery 2.x)

我正在尝试运行一些需要stubjQuery.ajax的测试。我正在使用SinonJS来做到这一点,它曾经可以在旧版本的jQuery(1.x)上正常工作var$=require('jquery');varsinon=require("sinon");sinon.stub($,"ajax");//thisworkedbecause$.ajaxisdefined但是,在升级到jQuery2.x之后,当我需要模块中的jquery才能运行时,我必须包含一个窗口环境。我正在使用jsdom来完成此操作:vardocument=require('jsdom').jsdom(),window=docum

node.js - 如何在 node.js 中 stub process.env?

我想用barstubprocess.env.FOO。varsinon=require('sinon');varstub=sinon.stub(process.env,'FOO','bar');我很困惑。我阅读了文档,但我仍然不明白。sinonjsdocssinonjs就是一个例子,不是sinonjs也可以。 最佳答案 根据我对process.env的理解,在设置其属性时,您可以像对待任何其他变量一样简单地对待它。但请记住,process.env中的每个值都必须是字符串。因此,如果您在测试中需要特定值:it('doessomethin

javascript - 使用 Sinon.js stub 类方法

我正在尝试使用sinon.js对方法进行stub,但出现以下错误:UncaughtTypeError:Attemptedtowrapundefinedpropertysample_pressureasfunction我也去了这个问题(Stubbingand/ormockingaclassinsinon.js?)并复制并粘贴了代码,但我得到了同样的错误。这是我的代码:Sensor=(function(){//AsimpleSensorclass//ConstructorfunctionSensor(pressure){this.pressure=pressure;}Sensor.prot

python - 如何在 Python 单元测试中 stub time.sleep()

我想制作一个stub来防止time.sleep(..)休眠以提高单元测试的执行时间。我拥有的是:importtimeasorgtimeclasstime(orgtime):'''Stubfortime.'''_sleep_speed_factor=1.0@staticmethoddef_set_sleep_speed_factor(sleep_speed_factor):'''Setssleepspeed.'''time._sleep_speed_factor=sleep_speed_factor@staticmethoddefsleep(duration):'''Sleepsorno

python - 打包 stub 文件

假设我有一个非常简单的包,结构如下:.├──foo│  ├──bar│  │  └──__init__.py│  └──__init__.py└──setup.py文件内容:setup.py:fromdistutils.coreimportsetupsetup(name='foobar',version='',packages=['foo','foo.bar'],url='',license='ApacheLicense2.0',author='foobar',author_email='',description='')foo/bar/__init__.py:deffoobar(x)

python - `dyld: Library not loaded` 错误阻止加载 virtualenv

当我尝试使用终端中的命令virtualenvvenv使用python创建虚拟环境时,出现以下错误:Usingbaseprefix'/Users/zacharythomas/anaconda3'Newpythonexecutablein/Users/zacharythomas/venv/bin/pythondyld:Librarynotloaded:@rpath/libpython3.6m.dylibReferencedfrom:/Users/zacharythomas/venv/bin/pythonReason:imagenotfoundERROR:Theexecutable/User

python - 如何解决 "dyld: Library not loaded: @executable_path.."错误

我试图检查我的MACOSX上的AWS-CLI版本。以下错误回击:dyld:Librarynotloaded:@executable_path/../.PythonReferencedfrom:/usr/local/aws/bin/pythonReason:imagenotfoundAborttrap:6任何有关如何解决此问题的相关意见将不胜感激。 最佳答案 这是awscli的一个错误,可能会在下一个版本中修复。这就是为什么,最佳做法是升级:brewupgradeawscli 关于pyth

c# - 在 C# 中嵌入 IronPython 时出现问题(缺少编译器所需的成员 'Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember'

我正在尝试做一个简单的helloworld来测试在C#中嵌入IronPython,但似乎无法解决这个问题..这是我的C#文件;usingSystem;usingIronPython.Hosting;usingMicrosoft.Scripting;usingMicrosoft.Scripting.Hosting;usingSystem.IO;publicclassdynamic_demo{staticvoidMain(){varipy=Python.CreateRuntime();dynamictest=ipy.UseFile(@"../../Test.py");test.Simple