collerek/ormar

Failing test: test_weakref_init

Closed this issue · 1 comments

When I run the test suite one of the tests fails.

$ python3 -mpytest -k test_weakref_init
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.11.5, pytest-7.4.0, pluggy-1.3.0
benchmark: 3.2.2 (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)
rootdir: /home/edward/src/2023/vendor/ormar
plugins: benchmark-3.2.2, astropy-header-0.2.2, anyio-3.7.0, flaky-3.7.0, forked-1.6.0, socket-0.5.1, lazy-fixture-0.6.3, openfiles-0.5.0, twisted-1.13.2, arraydiff-0.5.0, kgb-7.1.1, asyncio-0.20.3, doctestplus-1.0.0, repeat-0.9.1, xdist-3.3.1, remotedata-0.4.0, django-4.5.2, timeout-2.1.0, httpx-0.21.3, filter-subpackage-0.1.2, astropy-0.10.0, cov-4.1.0, xprocess-0.22.2, hypothesis-6.82.7, tornasync-0.6.0.post2, trio-0.8.0, requests-mock-1.9.3, mock-3.11.1, pylama-8.4.1
asyncio: mode=Mode.STRICT
collecting ... USED DB: sqlite:///test.db
collected 531 items / 530 deselected / 1 selected                                                                                                                                           

tests/test_relations/test_weakref_checking.py F                                                                                                                                       [100%]

========================================================================================= FAILURES ==========================================================================================
_____________________________________________________________________________________ test_weakref_init _____________________________________________________________________________________

    def test_weakref_init():
        band = Band(name="Band")
        artist1 = Artist(name="Artist 1", band=band)
        artist2 = Artist(name="Artist 2", band=band)
        artist3 = Artist(name="Artist 3", band=band)
    
        del artist1
        Artist(
            name="Artist 2", band=band
        )  # Force it to check for weakly-referenced objects
        del artist3
    
        band.artists  # Force it to clean
    
>       assert len(band.artists) == 1
E       AssertionError: assert 3 == 1
E        +  where 3 = len([<weakproxy at 0x7f3d34e40130 to Artist at 0x7f3d34e45fd0>, <weakproxy at 0x7f3d34e9fbf0 to Artist at 0x7f3d34e46190>, <weakproxy at 0x7f3d34ee18f0 to Artist at 0x7f3d34e45ef0>])
E        +    where [<weakproxy at 0x7f3d34e40130 to Artist at 0x7f3d34e45fd0>, <weakproxy at 0x7f3d34e9fbf0 to Artist at 0x7f3d34e46190>, <weakproxy at 0x7f3d34ee18f0 to Artist at 0x7f3d34e45ef0>] = Band({'id': None, 'name': 'Band', 'artists': [<weakproxy at 0x7f3d34e40130 to Artist at 0x7f3d34e45fd0>, <weakproxy at 0x7f3d34e9fbf0 to Artist at 0x7f3d34e46190>, <weakproxy at 0x7f3d34ee18f0 to Artist at 0x7f3d34e45ef0>]}).artists

tests/test_relations/test_weakref_checking.py:51: AssertionError
===================================================================================== warnings summary ======================================================================================
ormar/fields/base.py:51
ormar/fields/base.py:51
  /home/edward/src/2023/vendor/ormar/ormar/fields/base.py:51: DeprecationWarning: Parameter `pydantic_only` is deprecated and will be removed in one of the next releases.
   You can declare pydantic fields in a normal way. 
   Check documentation: https://collerek.github.io/ormar/fields/pydantic-fields
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================================================================================== short test summary info ==================================================================================
FAILED tests/test_relations/test_weakref_checking.py::test_weakref_init - AssertionError: assert 3 == 1
======================================================================= 1 failed, 530 deselected, 2 warnings in 1.32s =======================================================================
$

Versions

  • Python 3.11.5
  • ormar 0.12.2
  • pydantic 1.10.4

should be fixed on master