Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Travis CI AttributeError:对象没有属性';assertCountEqual';_Python_Unit Testing_Code Coverage_Travis Ci - Fatal编程技术网

Python Travis CI AttributeError:对象没有属性';assertCountEqual';

Python Travis CI AttributeError:对象没有属性';assertCountEqual';,python,unit-testing,code-coverage,travis-ci,Python,Unit Testing,Code Coverage,Travis Ci,在使用python内置的unittest模块中的assertCountEqual时,我在远程构建环境中遇到了一个问题 在Travis中,CI在执行覆盖率运行-m unittest discover-v时抛出此错误 但是,我能够在本地环境——Python 3.8.5 Ubuntu 20.04上执行该命令 我尝试从测试数据中删除keysdictionary属性,但即使如此,也会在远程环境中删除,并在本地环境中执行 test_bfs.py和test_dfs.py是生成失败的文件,这是错误的 这是我的本

在使用python内置的
unittest
模块中的
assertCountEqual
时,我在远程构建环境中遇到了一个问题

在Travis中,CI在执行
覆盖率运行-m unittest discover-v
时抛出此错误

但是,我能够在本地环境——Python 3.8.5 Ubuntu 20.04上执行该命令

我尝试从测试数据中删除
keys
dictionary属性,但即使如此,也会在远程环境中删除,并在本地环境中执行

test_bfs.py
test_dfs.py
是生成失败的文件,这是错误的

这是我的本地环境的输出:

test_loop (tests.unit.test_bfs.TestBreadthFirstSearch)
Ensure no vertex points to itself. ... ok
test_number_of_vertices (tests.unit.test_bfs.TestBreadthFirstSearch)
Ensure that number of vertices is greater than 2. ... ok
test_valid_path_exists (tests.unit.test_bfs.TestBreadthFirstSearch)
Ensure a valid path exists for valid data, irrespective of order. ... ok
test_valid_path_not_none (tests.unit.test_bfs.TestBreadthFirstSearch)
Ensure valid path is returned for valid data. ... ok
test_loop (tests.unit.test_dfs.TestDepthFirstSearch)
Ensure no vertex points to itself. ... ok
test_number_of_vertices (tests.unit.test_dfs.TestDepthFirstSearch)
Ensure that number of vertices is greater than 2. ... ok
test_valid_path_exists (tests.unit.test_dfs.TestDepthFirstSearch)
Ensure a valid path exists for valid data, irrespective of order. ... ok
test_valid_path_not_none (tests.unit.test_dfs.TestDepthFirstSearch)
Ensure valid path is returned for valid data. ... ok
test_sequence (tests.unit.test_inorder_traversal.TestInOrderTraversal)
Compare expected output with tree structure. ... ok
test_common_ancestor (tests.unit.test_lowest_common_ancestor.TestLowestCommonAncestor)
Check whether node 2 is the ancestor of node 1. ... ok
test_different_branch_ancestor (tests.unit.test_lowest_common_ancestor.TestLowestCommonAncestor)
Verify ancestor when both nodes belong to different subtrees. ... ok
test_same_branch_ancestor (tests.unit.test_lowest_common_ancestor.TestLowestCommonAncestor)
Verify ancestor when both nodes belong to the same subtree. ... ok
test_sequence (tests.unit.test_postorder_traversal.TestPostOrderTraversal)
Compare expected output with tree structure. ... ok
test_sequence (tests.unit.test_preorder_traversal.TestPreOrderTraversal)
Compare expected output with tree structure. ... ok

----------------------------------------------------------------------
Ran 14 tests in 0.002s

OK

有人能告诉我如何在Travis上修复此错误吗?

pip输出中有一个提示:

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.

  warnings.warn(warning, RequestsDependencyWarning)

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
这实际上运行的是python2.7,其中不存在
assertCountEqual


我建议使用
python-mpip…
来安装东西——这将确保您使用的是您期望的python版本

/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.

  warnings.warn(warning, RequestsDependencyWarning)

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
这实际上运行的是python2.7,其中不存在
assertCountEqual


我建议使用
python-mpip…
来安装东西——这将确保您使用的是预期的python版本

,但在执行测试用例之前,有
python--version
,它输出
python 3.8.0
。这还不够吗?
python
pip
不是同一个可执行文件,因此它们可能来自不同的安装谢谢!我正在等待构建完成。:)我在项目根目录中有一个名为
queue
(其中还有一个类
queue
),我认为这可能是导致问题的原因。我在这里看到了这一点,我将研究这两个方面,然后进行确认。但是在执行测试用例之前,有一个
python--version
,它输出
python3.8.0
。这还不够吗?
python
pip
不是同一个可执行文件,因此它们可能来自不同的安装谢谢!我正在等待构建完成。:)我在项目根目录中有一个名为
queue
(其中还有一个类
queue
),我认为这可能是导致问题的原因。我在这里看到了这一点,我将研究这两个方面,然后确认。