storage_tests: Fix assertion output
This fails in debian bullseye for some reasons.
Reading the storage interface for that method, there is no order guarantee in the output either.
In the chroot, here is the details of the issue without the current proposed fix:
$ python3 -m pytest -vv --log-level=DEBUG -s swh/storage/tests/storage_tests.py -k test_content_missing_
============================================================================================================= test session starts =============================================================================================================
platform linux -- Python 3.11.5, pytest-7.4.2, pluggy-1.3.0 -- /usr/bin/python3
cachedir: .pytest_cache
hypothesis profile 'fast' -> max_examples=5, deadline=timedelta(milliseconds=5000), database=DirectoryBasedExampleDatabase('/build/swh-storage-nnIJ6g/swh-storage-1.18.0/.hypothesis/examples')
rootdir: /build/swh-storage-nnIJ6g/swh-storage-1.18.0
configfile: pytest.ini
plugins: swh.journal-1.3.6, redis-2.0.0, hypothesis-6.84.3, postgresql-3.1.3, swh.core-2.24.0, mock-3.11.1
collected 228 items / 225 deselected / 3 selected
swh/storage/tests/storage_tests.py::TestStorage::test_content_missing_unknown_algo create_plpgsql_language
----------------------------
language already installed
(1 row)
psql:/usr/lib/python3/dist-packages/swh/core/db/sql/36-dbmodule.sql:12: NOTICE: relation "dbmodule" already exists, skipping
PASSED
swh/storage/tests/storage_tests.py::TestStorage::test_content_missing_per_sha1 FAILED
swh/storage/tests/storage_tests.py::TestStorage::test_content_missing_per_sha1_git PASSED
================================================================================================================== FAILURES ===================================================================================================================
__________________________________________________________________________________________________ TestStorage.test_content_missing_per_sha1 __________________________________________________________________________________________________
self = <swh.storage.tests.storage_tests.TestStorage object at 0x7fdb171e9710>, swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7fdb17259410>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7fdb17259110>
def test_content_missing_per_sha1(self, swh_storage, sample_data):
# given
cont = sample_data.content
cont2 = sample_data.content2
missing_cont = sample_data.skipped_content
missing_cont2 = sample_data.skipped_content2
swh_storage.content_add([cont, cont2])
# when
gen = swh_storage.content_missing_per_sha1(
[cont.sha1, missing_cont.sha1, cont2.sha1, missing_cont2.sha1]
)
# then
> assert list(gen) == [missing_cont.sha1, missing_cont2.sha1]
E AssertionError: assert [b'T\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ', b'C\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 '] == [b'C\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ', b'T\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ']
E At index 0 diff: b'T\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ' != b'C\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 '
E Full diff:
E [
E + b'T\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ',
E b'C\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ',
E - b'T\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ',
E ]
swh/storage/tests/storage_tests.py:778: AssertionError
============================================================================================================== warnings summary ===============================================================================================================
../../../usr/lib/python3/dist-packages/swh/core/db/pytest_plugin.py:42
/usr/lib/python3/dist-packages/swh/core/db/pytest_plugin.py:42: DeprecationWarning: This pytest plugin is deprecated, it should not be used any more.
warnings.warn(
../../../usr/lib/python3/dist-packages/_pytest/config/__init__.py:1373
/usr/lib/python3/dist-packages/_pytest/config/__init__.py:1373: PytestConfigWarning: Unknown config option: asyncio_mode
self._warn_or_fail_if_strict(f"Unknown config option: {key}\n")
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================================================================================================== short test summary info ===========================================================================================================
FAILED swh/storage/tests/storage_tests.py::TestStorage::test_content_missing_per_sha1 - AssertionError: assert [b'T\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 ', b'C\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x16\xfd\x89 '] == [b'C\xe4]V\xf8\x89\x93\xaa\xe6\xa0\x19\x80\x13\xef\xa8\x07\x1...
Edited by Antoine R. Dumont