2014-10-29 62 views
0

我在新機器(Windows 10)上設置Python(CPython 3.4,64位)。我安裝numpy的&鼻子,跑通過翻譯提示numpy.test(),以確保一切都按預期工作:Python測試在cmd上傳遞,在VS2012上失敗

Running unit tests for numpy 
NumPy version 1.9.0 
NumPy is installed in C:\Python34\lib\site-packages\numpy 
Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] 
nose version 1.3.4 

---------------------------------------------------------------------- 
Ran 5162 tests in 36.783s 

OK (KNOWNFAIL=10, SKIP=20) 

到目前爲止好,但是當我通過PTVS在VS2012(做同樣的事情我團隊使用TFS源控制),有錯誤以及測試失敗(如下圖):

Running unit tests for numpy 
NumPy version 1.9.0 
NumPy is installed in C:\Python34\lib\site-packages\numpy 
Python version 3.4.2 (v3.4.2:ab2c023a9432, Oct 6 2014, 22:16:31) [MSC v.1600 64 bit (AMD64)] 
nose version 1.3.4 

====================================================================== 
ERROR: test_basic (test_multiarray.TestResize) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_multiarray.py", line 2850, in test_basic 
    x.resize((5, 5)) 
ValueError: cannot resize an array that references or is referenced 
by another array in this way. Use the resize function 

====================================================================== 
ERROR: test_freeform_shape (test_multiarray.TestResize) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_multiarray.py", line 2880, in test_freeform_shape 
    x.resize(3, 2, 1) 
ValueError: cannot resize an array that references or is referenced 
by another array in this way. Use the resize function 

====================================================================== 
ERROR: test_int_shape (test_multiarray.TestResize) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_multiarray.py", line 2862, in test_int_shape 
    x.resize(3) 
ValueError: cannot resize an array that references or is referenced 
by another array in this way. Use the resize function 

====================================================================== 
ERROR: test_obj_obj (test_multiarray.TestResize) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_multiarray.py", line 2892, in test_obj_obj 
    a.resize(15,) 
ValueError: cannot resize an array that references or is referenced 
by another array in this way. Use the resize function 

====================================================================== 
ERROR: test_zeros_appended (test_multiarray.TestResize) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_multiarray.py", line 2885, in test_zeros_appended 
    x.resize(2, 3, 3) 
ValueError: cannot resize an array that references or is referenced 
by another array in this way. Use the resize function 

====================================================================== 
ERROR: Ticket #950 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_regression.py", line 1272, in test_blasdot_uninitialized_memory 
    x.resize((m, 0)) 
ValueError: cannot resize an array that references or is referenced 
by another array in this way. Use the resize function 

====================================================================== 
FAIL: test_blasdot.test_dot_3args 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\nose\case.py", line 198, in runTest 
    self.test(*self.arg) 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_blasdot.py", line 54, in test_dot_3args 
    assert_equal(sys.getrefcount(r), 2) 
    File "C:\Python34\lib\site-packages\numpy\testing\utils.py", line 334, in assert_equal 
    raise AssertionError(msg) 
AssertionError: 
Items are not equal: 
ACTUAL: 3 
DESIRED: 2 

====================================================================== 
FAIL: test_1d (test_indexing.TestMultiIndexingAutomated) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_indexing.py", line 940, in test_1d 
    self._check_single_index(a, index) 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_indexing.py", line 859, in _check_single_index 
    self._compare_index_result(arr, index, mimic_get, no_copy) 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_indexing.py", line 875, in _compare_index_result 
    assert_equal(sys.getrefcount(arr), 3) 
    File "C:\Python34\lib\site-packages\numpy\testing\utils.py", line 334, in assert_equal 
    raise AssertionError(msg) 
AssertionError: 
Items are not equal: 
ACTUAL: 4 
DESIRED: 3 

====================================================================== 
FAIL: test_multidim (test_indexing.TestMultiIndexingAutomated) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_indexing.py", line 922, in test_multidim 
    self._check_multi_index(self.a, index) 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_indexing.py", line 836, in _check_multi_index 
    self._compare_index_result(arr, index, mimic_get, no_copy) 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_indexing.py", line 875, in _compare_index_result 
    assert_equal(sys.getrefcount(arr), 3) 
    File "C:\Python34\lib\site-packages\numpy\testing\utils.py", line 334, in assert_equal 
    raise AssertionError(msg) 
AssertionError: 
Items are not equal: 
ACTUAL: 4 
DESIRED: 3 

====================================================================== 
FAIL: test_dot_3args (test_multiarray.TestDot) 
---------------------------------------------------------------------- 
Traceback (most recent call last): 
    File "C:\Python34\lib\site-packages\numpy\core\tests\test_multiarray.py", line 3285, in test_dot_3args 
    assert_equal(sys.getrefcount(r), 2) 
    File "C:\Python34\lib\site-packages\numpy\testing\utils.py", line 334, in assert_equal 
    raise AssertionError(msg) 
AssertionError: 
Items are not equal: 
ACTUAL: 3 
DESIRED: 2 

---------------------------------------------------------------------- 
Ran 5162 tests in 181.506s 

FAILED (KNOWNFAIL=10, SKIP=20, errors=6, failures=4) 
Press any key to continue . . . 

我跑,我在VS通過命令行寫劇本,結果是一樣的,通過運行測試直接解釋器,所以我相信在我的VS/Python設置中有些問題而不是腳本本身。問題是什麼?

回答

1

你的設置沒有任何不妥之處。這就是說,numpy測試似乎是脆弱的,因爲它們不允許調試器。我不確定那裏發生了什麼,但似乎涉及sys.getrefcount的測試以及依賴它的語義是特定的(通常只是對數組進行單個引用)是失敗的。 >開始不調試 -

import sys 
def trace_func(f, e, a): 
    return trace_func 
sys.settrace(trace_func) 

import numpy 
numpy.test() 

請注意,您可以運行VS腳本,而不通過調試調試它:

sys.settrace註冊您自己的跟蹤功能,直接運行解釋時,如你可以攝製此。這會給你的結果直接運行解釋器。

相關問題