我正在尝试将一个python模块移植到linux,该模块到目前为止都是严格在Windows上开发的。在运行单元测试时,我得到了以下错误:
ModuleNotFoundError: No module named 'unittest.test'
如果进入python /lib/unittest路径,unittest.test目录就不存在,这似乎很奇怪,因为它存在于中。
我尝试过从零开始在几台不同的linux机器上安装python,甚至尝试过干净的docker容器,但是这个目录总是缺失的。它存在于所有的windows安装中,我没有看到任何东西表明这是一个只使用windows的模块。
我有一个CMakeLists.txt,它在我的x64机器上工作,而不是ARM64机器。问题是这个电话:
find_library(UnitTest++ REQUIRED)
我可以在libUnitTest++.so中找到/usr/lib/aarch64-linux-gnu/,但是CMake找不到它:
CMake Error at test/CMakeLists.txt:8 (find_library):
Could not find UnitTest++ using the following names:
-- Configuring incomplete, errors occurr
我不确定为什么下面的代码不能工作。我正在使用。有人能给我解释一下吗?
我得到的错误是:
$ python test_mock.py
Calls the mock object method. not a real one. ... ERROR
======================================================================
ERROR: Calls the mock object method. not a real one.
-----------------------------------------------------
我想在Azure管道中设置我的CI来运行我的测试:
Python3.6/ Linux
Python3.7/ Linux
Python3.6/ Windows
Python3.7/ Windows
我看到,我可以通过使用matrix轻松地使用不同的Python版本进行测试,但我猜想是否有一种简单的方法来处理这些图像。我认为它可能有可能使用模板,但我想保持一切简单,并在一个单一的文件,如果这是一个选项。
到目前为止,在Linux中测试py3.6/py3.7是这样的:
- job: 'Test'
pool:
vmImage: 'Ubuntu
与其长篇大论,不如用下面的最起码的例子来说明:
$ python3
Python 3.7.6 (default, Jan 30 2020, 09:44:41)
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import unittest import sys
>>> from PyQt5.QtWi
我有一个动态库,它同时构建在Linux和Windows中。当在这两个系统下针对静态库运行单元测试时,我没有问题。当在linux中对共享库运行单元测试时,一切都很好。当在Windows中对共享库运行单元测试时,我的问题就出现了。
简而言之,我的堆栈跟踪如下:
UnitTest.exe!_free_dbg_nolock(void * pUserData, int nBlockUse) Line 1424 C++
UnitTest.exe!_free_dbg(void * pUserData, int nBlockUse) Line 1265 C++
UnitTest.exe!operat
我在我的Python和Plone项目中使用Shapely包。在鸡蛋部分下的packages.cfg文件中,我使用shapely进行下载,如下所示
[eggs]
main =
Shapely
在bin/buildout过程中,我发现shapely.vectorized中有一个问题。错误似乎是这样的
Numpy or Cython not available, shapely.vectorized submodule not being built.
我为我的python函数创建了单元测试。当我运行我的文件时,我得到了错误。错误的回溯是
Module: shapely.tests.te
在python unittest中,它指出如果mock.assert_called_once()被多次调用,它将失败。在打补丁时,我没有看到这种行为。
ugh.py
def foo(*args):
pass
def bar():
foo(1)
foo(2)
tests.py
from unittest import TestCase, main
from unittest.mock import patch
from ugh import bar
class Test(TestCase):
@patch('ugh.foo')
def
从std Python库中找不到一个模块似乎很奇怪。我可能做错了什么,但我不知道到底是什么。
shift@bt:~/experiments/$ python test/test_creation.py
'import site' failed; use -v for traceback
Traceback (most recent call last):
File "test/test_creation.py", line 1, in <module>
import unittest
ImportError: No module nam
我正在尝试执行我的以下测试套件:
import unittest
from Login_Page import LoginPageAndLogout
def test_suite():
# get all tests from classes
login_test = unittest.TestLoader().loadTestsFromTestCase(LoginPageAndLogout)
# create a test suite
all_tests = unittest.TestSuite([
login_test
])
我正在尝试执行以下测试套件:
import unittest
from Login_Page import LoginPageAndLogout
def test_suite():
# get all tests from classes
login_test = unittest.TestLoader().loadTestsFromTestCase(LoginPageAndLogout)
# create a test suite
all_tests = unittest.TestSuite([
login_test
])
有人能解释一下这个错误吗?DictTest.py的内容如下。如果我将此代码复制(%粘贴)到ipython终端,则测试将通过。如果打电话
>>> %run DictTest.py -m
测试失败
name 'keys' is not defined
它所抱怨的“键”是词条理解中的“键”部分。我在linux上使用的是3.4.1区Anaconda 2.1.0 (64位)。
#!/usr/bin/python3.4
import unittest
class DictTest(unittest.TestCase):
def test_dict_compr