devscope.io

Unit tests are failing when wagtail >= 2.12

wagtail/wagtail-factories

Issue

Some of the unit tests are failing when a wagtail version of >=2.12 is installed. The failing tests are test_custom_page_streamfield_data_complex, test_custom_page_streamfield_default_blocks, test_custom_page_streamfield and test_custom_page_streamfield_data. I've tried running the tests against Wagtail 2.9.3 and 2.11.7 and they pass. The issue seems to be that an id attribute has been added to the block in Wagtail >= 2.12. For example the data returned by the MyTestPageWithStreaFieldFactory call, with Wagtail >= 2.12 looks like this (page.body.streamdata):

[('char_array', ['foo', 'bar'], '35741861-c5ea-45a9-a8f5-8f5de95fe6d8'), ('struct', StructValue([('title', 'My Title'), ('item', StructValue([('label', 'my-label'), ('value', 100)])), ('items', []), ('image', None)]), 'a99daf3d-9055-45f3-a0f2-3b61fd45f58a'), ('int_array', [100], 'b7b60e57-5df2-4996-9916-d8f132ba57be'), ('image', <Image: Blub>, '4138701b-c8fe-45b9-91f9-6e0cdbcce520')]

Note the additional guids which are not expected in the test data.

I will try to fix this issue, but I'm looking for some advise on the best way to proceed. Can we simply drop support for older versions of wagtail and modify the unit tests to expect the additional guids? Or do we need to maintain support for older versions of Wagtail and modify the tests to take account of different versions (EG check the Wagtail version)? Or some other option which I have not thought of?

2021-04-27 15:31:16


Add a Comment


Top 2 Comments

  marteinn answered on 2021-05-14 08:29:16

0 positive reactions.
  marteinn answered on 2021-05-14 07:08:28

Hi @ColinBeeby-Developer and thank you for raising this issue!

This error is because of a larger streamfield refactoring that has been done in Wagtail 2.12 and 2.13, where the tests itself are relying on a deprecated property for comparison (stream_data), we should instead compare block_type and value directly on the streamfield property (page.body[0].block_type == "image" / page.body[0].value == [100]).

As to you questions, we need to keep supporting older Wagtail versions, but only those who are officially supported, those are 2.11 and 2.13 (according to https://github.com/wagtail/wagtail/wiki/Release-schedule).

I'm did not see a PR from you so I'm taking the initiative for a PR so we can get this solved as quick as possible.

0 positive reactions.

Quick Hint

Do wagtails use feeders?

Grey Wagtails won't eat peanuts or sunflower seeds from garden bird feeders since they are not a part of their natural diet, however they may eat dried mealworms scattered across the lawn or from a ground bird feeder.

Repo Information


Age 5yrs
Vendor wagtail
Repo Name wagtail-factories
Primary Language Python
Default Branch main
Last Update 4 months ago

Wagtail's Code Library

Similar Issues

πŸ’Ύ wagtail Add ActivityPub support πŸ’¬ 5 closed πŸ—“οΈ 5 days ago
πŸ’Ύ wagtail Page jumps to top on "save draft" πŸ’¬ 3 open πŸ—“οΈ 1 week ago
πŸ’Ύ wagtail Eslint cleanup no plusplus rule πŸ’¬ 5 closed πŸ—“οΈ 1 week ago
πŸ’Ύ wagtail.org Performance: Enable text compression πŸ’¬ 3 closed πŸ—“οΈ 2 weeks ago
πŸ’Ύ wagtail.org Performance: serve images in next-gen formats πŸ’¬ 4 closed πŸ—“οΈ 2 weeks ago
πŸ’Ύ wagtail Local setup Error for Safari Browser πŸ’¬ 3 open πŸ—“οΈ 2 weeks ago
πŸ’Ύ wagtail Clean up eslint usage `no-prototype-builtins` πŸ’¬ 7 closed πŸ—“οΈ 3 weeks ago