Skip to content

0.6.0: pytest is failing #117

Open
Open

Description

@kloczek

I'm trying to package your module as rpm packag. So I'm using typical in such case build, install and test cycle used on building package from non-root account:

  • "setup.py build"
  • "setup.py install --root </install/prefix>"
  • "pytest with PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>

May I ask for help because few units are failing:

+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-multipledispatch-0.6.0-2.fc35.x86_64/usr/lib64/python3.8/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-multipledispatch-0.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages
+ /usr/bin/pytest -ra
=========================================================================== test session starts ============================================================================
platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
Using --randomly-seed=1915887508
rootdir: /home/tkloczko/rpmbuild/BUILD/multipledispatch-0.6.0
plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0, asyncio-0.15.1, trio-0.7.0, httpbin-1.0.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0
collected 63 items

multipledispatch/tests/test_dispatcher_3only.py ......                                                                                                               [  9%]
multipledispatch/tests/test_variadic.py ...                                                                                                                          [ 14%]
multipledispatch/tests/test_dispatcher.py ...........................                                                                                                [ 57%]
. .                                                                                                                                                                  [ 58%]
bench/test_simple.py .                                                                                                                                               [ 60%]
multipledispatch/tests/test_benchmark.py ....                                                                                                                        [ 66%]
multipledispatch/tests/test_core.py ......F.....                                                                                                                     [ 85%]
multipledispatch/tests/test_conflict.py .........                                                                                                                    [100%]

================================================================================= FAILURES =================================================================================
__________________________________________________________________ test_inheritance_and_multiple_dispatch __________________________________________________________________

    def test_inheritance_and_multiple_dispatch():
        @dispatch(A, A)
        def f(x, y):
            return type(x), type(y)

        @dispatch(A, B)
        def f(x, y):
            return 0

        assert f(A(), A()) == (A, A)
>       assert f(A(), C()) == (A, C)
E       AssertionError: assert 2 == (<class 'test_core.A'>, <class 'test_core.C'>)
E        +  where 2 = <dispatched f>(<test_core.A object at 0x7facfa290d90>, <test_core.C object at 0x7facfa290f10>)
E        +    where <test_core.A object at 0x7facfa290d90> = A()
E        +    and   <test_core.C object at 0x7facfa290f10> = C()

multipledispatch/tests/test_core.py:75: AssertionError
============================================================================= warnings summary =============================================================================
multipledispatch/tests/test_core.py::test_multipledispatch
  multipledispatch/tests/test_core.py:31: PytestBenchmarkWarning: Benchmark fixture was not used at all in this test!
    def test_multipledispatch(benchmark):

-- Docs: https://docs.pytest.org/en/stable/warnings.html

---------------------------------------------------------------------------------------------------------------- benchmark: 4 tests ----------------------------------------------------------------------------------------------------------------
Name (time in ns)                                        Min                       Max                    Mean                 StdDev                  Median                    IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_benchmark_call_single_dispatch[a]              814.8296 (1.0)        102,342.3392 (16.94)        858.7401 (1.0)         259.4712 (2.58)         837.3366 (1.0)          30.6754 (1.09)   1150;13768    1,164.4966 (1.0)      177934           6
test_benchmark_call_single_dispatch[1]              832.2531 (1.02)         6,042.7701 (1.0)          878.3960 (1.02)        100.4279 (1.0)          869.7389 (1.04)         28.2598 (1.0)      545;6426    1,138.4387 (0.98)      98348           4
test_benchmark_call_multiple_dispatch[val0]       1,088.0176 (1.34)        17,664.0460 (2.92)       1,263.0155 (1.47)        678.5140 (6.76)       1,157.9832 (1.38)         35.9723 (1.27)    1040;3729      791.7559 (0.68)      43186           1
test_benchmark_add_and_use_instance             246,200.0120 (302.15)   2,871,196.0185 (475.15)   263,512.1736 (306.86)   64,891.5833 (646.15)   256,208.0044 (305.98)   12,248.9291 (433.44)      27;81        3.7949 (0.00)       1829           1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
========================================================================= short test summary info ==========================================================================
FAILED multipledispatch/tests/test_core.py::test_inheritance_and_multiple_dispatch - AssertionError: assert 2 == (<class 'test_core.A'>, <class 'test_core.C'>)
================================================================= 1 failed, 62 passed, 1 warning in 12.08s =================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.

Activity

  1. kloczek commented on Aug 22, 2021

    @kloczek
    Author

    Strange after deselecting that failing unit another one popped out

    + /usr/bin/pytest -ra --deselect multipledispatch/tests/test_core.py::test_inheritance_and_multiple_dispatch
    =========================================================================== test session starts ============================================================================
    platform linux -- Python 3.8.11, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
    benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
    Using --randomly-seed=1389073897
    rootdir: /home/tkloczko/rpmbuild/BUILD/multipledispatch-0.6.0
    plugins: forked-1.3.0, shutil-1.7.0, virtualenv-1.7.0, expect-1.1.0, flake8-1.0.7, timeout-1.4.2, betamax-0.8.1, freezegun-0.4.2, aspectlib-1.5.2, toolbox-0.5, rerunfailures-9.1.1, requests-mock-1.9.3, cov-2.12.1, pyfakefs-4.5.0, flaky-3.7.0, benchmark-3.4.1, xdist-2.3.0, pylama-7.7.1, datadir-1.3.1, regressions-2.2.0, cases-3.6.3, xprocess-0.18.1, black-0.3.12, checkdocs-2.7.1, anyio-3.3.0, Faker-8.11.0, asyncio-0.15.1, trio-0.7.0, httpbin-1.0.0, subtests-0.5.0, isort-2.0.0, hypothesis-6.14.6, mock-3.6.1, profiling-1.7.0, randomly-3.8.0
    collected 63 items / 1 deselected / 62 selected
    
    multipledispatch/tests/test_variadic.py ...                                                                                                                          [  4%]
    multipledispatch/tests/test_benchmark.py ....                                                                                                                        [ 11%]
    multipledispatch/tests/test_dispatcher_3only.py ......                                                                                                               [ 20%]
    multipledispatch/tests/test_dispatcher.py ...........................                                                                                                [ 64%]
    multipledispatch/tests/test_core.py ....F......                                                                                                                      [ 82%]
    bench/test_simple.py .                                                                                                                                               [ 83%]
    . .                                                                                                                                                                  [ 85%]
    multipledispatch/tests/test_conflict.py .........                                                                                                                    [100%]
    
    ================================================================================= FAILURES =================================================================================
    _____________________________________________________________________________ test_inheritance _____________________________________________________________________________
    
        def test_inheritance():
            @dispatch(A)
            def f(x):
                return 'a'
    
            @dispatch(B)
            def f(x):
                return 'b'
    
            assert f(A()) == 'a'
            assert f(B()) == 'b'
    >       assert f(C()) == 'a'
    E       AssertionError: assert 2 == 'a'
    E        +  where 2 = <dispatched f>(<test_core.C object at 0x7fad4b71f400>)
    E        +    where <test_core.C object at 0x7fad4b71f400> = C()
    
    multipledispatch/tests/test_core.py:62: AssertionError
    ============================================================================= warnings summary =============================================================================
    multipledispatch/tests/test_core.py::test_multipledispatch
      multipledispatch/tests/test_core.py:31: PytestBenchmarkWarning: Benchmark fixture was not used at all in this test!
        def test_multipledispatch(benchmark):
    
    multipledispatch/tests/test_core.py::test_methods_multiple_dispatch
      /home/tkloczko/rpmbuild/BUILDROOT/python-multipledispatch-0.6.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/multipledispatch/dispatcher.py:27: AmbiguityWarning:
      Ambiguities exist in dispatched function f
    
      The following signatures may result in ambiguous behavior:
            [C, A], [A, C]
    
    
      Consider making the following additions:
    
      @dispatch(C, C)
      def f(...)
        warn(warning_text(dispatcher.name, ambiguities), AmbiguityWarning)
    
    -- Docs: https://docs.pytest.org/en/stable/warnings.html
    
    ---------------------------------------------------------------------------------------------------------------- benchmark: 4 tests ----------------------------------------------------------------------------------------------------------------
    Name (time in ns)                                        Min                       Max                    Mean                 StdDev                  Median                    IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    test_benchmark_call_single_dispatch[1]              966.9457 (1.0)         22,409.0181 (1.30)       1,038.7095 (1.0)         195.7208 (1.0)        1,027.9473 (1.0)          33.9933 (1.0)       66;2208      962.7331 (1.0)       49883           1
    test_benchmark_call_single_dispatch[a]            1,017.0043 (1.05)        17,218.9903 (1.0)        1,069.9012 (1.03)        209.9899 (1.07)       1,052.0453 (1.02)         37.0201 (1.09)       20;781      934.6657 (0.97)      11848           1
    test_benchmark_call_multiple_dispatch[val0]       1,073.0000 (1.11)       195,748.9876 (11.37)      1,179.8810 (1.14)        705.6635 (3.61)       1,160.0787 (1.13)         36.0887 (1.06)     120;8039      847.5431 (0.88)      86566           1
    test_benchmark_add_and_use_instance             246,718.0602 (255.15)   1,762,717.0309 (102.37)   262,397.7649 (252.62)   51,314.3285 (262.18)   254,286.9188 (247.37)   16,070.1165 (472.74)      30;48        3.8110 (0.00)       2613           1
    ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Legend:
      Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
      OPS: Operations Per Second, computed as 1 / Mean
    ========================================================================= short test summary info ==========================================================================
    FAILED multipledispatch/tests/test_core.py::test_inheritance - AssertionError: assert 2 == 'a'
    ========================================================= 1 failed, 61 passed, 1 deselected, 2 warnings in 10.23s ==========================================================
    pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
  2. kloczek commented on Aug 22, 2021

    @kloczek
    Author

    No this is completly different issue.
    I have installed pytest-randomly and this extension executes pytest units in random order.
    Adfter add -p no:randomly to pytest parameters everything is file.
    Still it is some test suite issue because looks like there are some dependencies betweeen units.
    Those issueas can be resolved using https://github.com/mrbean-bremen/pytest-find-dependencies/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions