File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,9 @@ def get_cacheable_component(component):
6161 raise UnicornCacheError (
6262 "Cannot cache component because it is not picklable."
6363 ) from e
64+ except NotImplementedError as e :
65+ raise UnicornCacheError (
66+ "Cannot cache component because it is not picklable."
67+ ) from e
6468
6569 return component
Original file line number Diff line number Diff line change 33from django_unicorn .components import UnicornView
44from django_unicorn .db import DbModel
55from django_unicorn .decorators import db_model
6+ from django_unicorn .errors import UnicornCacheError
7+ from django_unicorn .utils import get_cacheable_component
68from example .coffee .models import Flavor
79
810
@@ -78,3 +80,12 @@ class Meta:
7880
7981 with pytest .raises (AssertionError ):
8082 component .get_pk ({"name" : "flavor" , "pk" : - 99 })
83+
84+
85+ @pytest .mark .django_db
86+ def test_component_db_model_not_pickleable (component ):
87+ """
88+ This is not ideal and should hopefully be fixable by providing a `__reduce_ex__` method.
89+ """
90+ with pytest .raises (UnicornCacheError ):
91+ get_cacheable_component (component )
You can’t perform that action at this time.
0 commit comments