使用 mpmath.runtests() 测试失败

时间:2021-03-15 11:40:54

标签: python anaconda spyder anaconda3

我在 Spyder IDE (Python 3.8) 中运行以下代码:

import mpmath
mpmath.runtests()

我认为大部分测试都通过了,但我得到“测试失败”。 附上部分输出:

test_pickle
    pickle                    ok        0.0648950 s
test_power
    fractional_pow            ok        0.0007822 s
    pow_epsilon_rounding      ok        0.0103981 s
    pow_integer_direction     ok        0.0193535 s
test_quad
    basic_integrals           ok        1.1562272 s
    complex_integration       ok        0.0056852 s
    double_1                  ok        0.3558573 s
    double_2                  ok        0.4513715 s
    double_3                  ok        0.6033714 s
    double_4                  ok        0.1894437 s
    double_5                  ok        0.1238344 s
    double_6                  ok        0.7316320 s
    double_7                  ok        5.4023527 s
    double_trivial            ok        0.0566362 s
    expmath_fail              
TEST FAILED!

ok        0.0425350 s
    expmath_integrals         Traceback (most recent call last):
  File "C:\Users\elii\Anaconda3\envs\mpmath_gmpy2_env\lib\site-packages\mpmath\tests\runtests.py", line 118, in testit
    module.__dict__[f]()
  File "C:\Users\elii\Anaconda3\envs\mpmath_gmpy2_env\lib\site-packages\mpmath\tests\test_quad.py", line 88, in test_expmath_fail
    assert ae(quadts(lambda x: sqrt(tan(x)), [0, pi/2]),          pi*sqrt(2)/2)
AssertionError
ok        0.8399490 s
    quad_infinite_mirror      ok        0.0250090 s
    quad_symmetry             ok        0.0008955 s
    quadgl_linear             ok        0.0001940 s
    quadosc                   ok        0.2904317 s
test_rootfinding
    anewton                   ok        0.0040029 s
    bisection                 ok        0.0002888 s
    findroot                  ok        0.0401497 s
    mnewton                   ok        0.0014225 s
    muller                    ok        0.0079640 s
    multidimensional          ok        0.0322137 s
    multiplicity              ok        0.0027796 s
    trivial                   ok        0.0001189 s
test_special
    convert_special           ok        0.0013397 s
    div_bug                   ok        0.0000584 s
    functions_special         ok        0.0002212 s
    special                   ok        0.0005193 s
    special_powers            ok        0.0000920 s
test_str
    nstr                      ok        0.0011065 s
test_summation
    fprod                     ok        0.0000991 s
    fsum                      ok        0.0009620 s
    nprod                     ok        0.0187528 s
    nsum                      ok        0.1046476 s
    sumem                     ok        0.0756396 s
test_trig
    trig_misc_hard            ok        0.0016346 s
    trig_near_n_pi            ok        0.0031282 s
    trig_near_zero            ok        0.0006552 s
test_visualization
    axes                      
Skipping test (pylab not available or too old version)

ok        0.0048888 s

finished tests in 132.72 seconds

我尝试在互联网上搜索可能是什么问题,但不幸的是我没有找到。有谁知道测试失败的原因是什么,可以做些什么来解决这个问题?

注意:我在 Anaconda 环境中工作。

谢谢!

1 个答案:

答案 0 :(得分:1)

@pytest.mark.xfail 修饰的测试预计会失败 (see documentation),this particular test 就是这种情况。作者可以使用它来记录已知的限制/错误,然后用于测试修复。