Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mfogel committed Feb 9, 2022
1 parent c9402a6 commit f2faad2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 9 additions & 6 deletions tests/test_deconstruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,16 @@ def test_specifying_defaults_not_frozen():
],
)
def test_deconstruct_when_using_choices(choices, use_pytz):
field = TimeZoneField(choices=choices)
_name, _path, args, kwargs = field.deconstruct()
field = TimeZoneField(choices=choices, use_pytz=use_pytz)
_name, _path, _args, kwargs = field.deconstruct()
assert kwargs == {
"choices": [
("US/Pacific", "US/Pacific"),
("US/Eastern", "US/Eastern"),
]
**{
"choices": [
("US/Pacific", "US/Pacific"),
("US/Eastern", "US/Eastern"),
]
},
**({"use_pytz": use_pytz} if use_pytz is not None else {}),
}


Expand Down
2 changes: 1 addition & 1 deletion timezone_field/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def __init__(self, *args, **kwargs):
# https://github.com/django/django/blob/1.11.11/django/db/models/fields/__init__.py#L145
if len(args) > 3:
raise ValueError("Cannot specify max_length by positional arg")
kwargs.setdefault("max_length", self.default_max_length)

self.max_length = kwargs.pop("max_length", self.default_max_length)
self.use_pytz_explicit = kwargs.pop("use_pytz", None)
self.use_pytz = self.use_pytz_explicit if self.use_pytz_explicit is not None else use_pytz_default()
self.default_tzs = self.default_pytz_tzs if self.use_pytz else self.default_zoneinfo_tzs
Expand Down

0 comments on commit f2faad2

Please sign in to comment.