export class Foo {
public static bar() {
doSomething();
}
constructor(paramA, paramB) {
}
}
Run Code Online (Sandbox Code Playgroud)
对于类中的方法,我们可以
jest.spyOn(Foo, 'bar')
用来监视该方法。构造函数呢?我们如何监视对象的实例化?
如果您没有使用 virtualenv,则 cv2 模块已成功导入
nano@nano:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.3.1'
>>>
Run Code Online (Sandbox Code Playgroud)
但是,如果创建虚拟环境,则找不到cv2
(env) nano@nano:~$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'cv2'
Run Code Online (Sandbox Code Playgroud) 我正在使用 API 调用request_spot_instances
来创建现货实例,而不指定任何可用区域。通常,API 会随机选择一个可用区。现货请求有时会返回无容量状态,而我可以通过另一个可用区的 AWS 控制台成功请求现货实例。在调用 request_spot_instance 之前检查特定实例类型的 Spot 实例的可用性的正确方法是什么?