-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
This is a comment on #416 which we contributed to, but is now closed #487
Comments
Greetings! Thank you for the report! The latest changes related to GFK are covered in the following commit (1.18.3): The mentioned patch (that simply adds a GFK to a skip list) will break a case where Would it be possible to craft a small reproducible test structure? Best, |
Hey @paulredman- ! I released 1.19.2 with a couple of patches adjusting the behaviour of GFK fields. Best, |
Hi Rust
Many thanks for this. It does indeed improve things, but still gives an error after 910 out of around 6000 tests. The stack trace is below.
I think it likely that the problem is relates_to=None where the definition of relates_to is: relates_to = GenericForeignKey('relates_to_type', 'relates_to_id')
Thanks againPaul
baker.make('comms.Message', _fill_optional=True, from_user=client.user, to_user=lawyer2.user, relates_to=None)
clients/tests/tests_client_my_messages.py:447:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../staging_env/lib/python3.10/site-packages/model_bakery/baker.py:142: in make
return baker.make(
../../staging_env/lib/python3.10/site-packages/model_bakery/baker.py:401: in make
return self._make(**params)
../../staging_env/lib/python3.10/site-packages/model_bakery/baker.py:477: in _make
instance = self.instance(
../../staging_env/lib/python3.10/site-packages/model_bakery/baker.py:530: in instance
self._handle_generic_foreign_keys(instance, generic_foreign_keys)
../../staging_env/lib/python3.10/site-packages/model_bakery/baker.py:708: in _handle_generic_foreign_keys
contenttypes_models.ContentType.objects.get_for_model(value),
../../staging_env/lib/python3.10/site-packages/django/contrib/contenttypes/models.py:41: in get_for_model
opts = self._get_opts(model, for_concrete_model)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <django.contrib.contenttypes.models.ContentTypeManager object at 0x7ef1bf739540>, model = None, for_concrete_model = True
def _get_opts(self, model, for_concrete_model):
if for_concrete_model:
model = model._meta.concrete_model
E AttributeError: 'NoneType' object has no attribute '_meta'
../../staging_env/lib/python3.10/site-packages/django/contrib/contenttypes/models.py:28: AttributeError
--------- Generated html report: file:///home/cc/staging/contractscounsel/contractscounsel/test_results/quicktest/pytest_report.html ---------
========================================================== short test summary info ===========================================================
FAILED clients/tests/tests_client_my_messages.py::ClientMyMessagesTestClass::test_with_different_link_types - AttributeError: 'NoneType' object has no attribute '_meta'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
========================================= 1 failed, 910 passed, 476 deselected in 332.50s (0:05:32) ==========================================
On Friday, 16 August 2024 at 14:56:16 BST, Rust Saiargaliev ***@***.***> wrote:
Hey @paulredman- !
I released 1.19.2 with a couple of patches adjusting the behaviour of GFK fields.
Would you be so kind to try it out?
Best,
Rust
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Many thanks for the provided stacktrace, this helps alot! I have drafted #496 to address this bug; however, it would not prevent |
Released 1.19.3 adjusting this: |
Rust
Thank you very much for this. 1.19.3 fixes our issues, and we are now back to an unpatched version!
Best wishes,Paul
On Saturday, 17 August 2024 at 14:32:36 BST, Rust Saiargaliev ***@***.***> wrote:
Released 1.19.3 adjusting this:
- https://github.com/model-bakers/model_bakery/releases/tag/1.19.3
- https://pypi.org/project/model-bakery/1.19.3/
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
@paulredman- hey Paul, Glad that it is resolved for you. |
We have a test suite of nearly 7000 tests, using model_bakery extensively.
We have a small patch for #416 which works on all versions from 1.12 -> 1.18.2 (the patch varies slightly as the code changes, but essentially looks like:
if BAKER_CONTENTTYPES:
other_fields_to_skip += [GenericForeignKey, GenericRelation]
On both 1.18.3 / 1.19.0, recently released we get early test failures (within the first 20 tests, so likely many failures)
I appreciate this bug report is not precise. It is frustrating that 1.18.3 is the first to fix our problem, but breaks other tests.
I am happy to dig deeper, if you could let me know what else changed from 1.18.2 -> 1.18.3 which might be causing problems.
Versions
The text was updated successfully, but these errors were encountered: