-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: Try using localized_cached_property for cache_name
- Loading branch information
1 parent
2ad3072
commit c55404b
Showing
4 changed files
with
49 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from modeltranslation.utils import localized_cached_property, get_language | ||
from django.utils.translation import override | ||
|
||
|
||
def test_localized_cached_property(): | ||
class Foo: | ||
@localized_cached_property | ||
def bar(self): | ||
return get_language() | ||
|
||
instance = Foo() | ||
|
||
for lang in ["en", "de"]: | ||
with override(lang): | ||
assert instance.bar == lang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters