Skip to content

Use quotes in repr of TzInfo #1701

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/input/datetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ impl TzInfo {
}

fn __repr__(&self) -> String {
format!("TzInfo({})", self.__str__())
format!("TzInfo('{}')", self.__str__())
}

fn __str__(&self) -> String {
Expand Down
12 changes: 6 additions & 6 deletions tests/validators/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def test_custom_timezone_repr():
assert output.tzinfo.dst(output) is None
assert output.tzinfo.tzname(output) == '-12:15'
assert str(output.tzinfo) == '-12:15'
assert repr(output.tzinfo) == 'TzInfo(-12:15)'
assert repr(output.tzinfo) == "TzInfo('-12:15')"


def test_custom_timezone_utc_repr():
Expand All @@ -208,7 +208,7 @@ def test_custom_timezone_utc_repr():
assert output.tzinfo.dst(output) is None
assert output.tzinfo.tzname(output) == 'UTC'
assert str(output.tzinfo) == 'UTC'
assert repr(output.tzinfo) == 'TzInfo(UTC)'
assert repr(output.tzinfo) == "TzInfo('UTC')"


def test_tz_comparison():
Expand All @@ -230,16 +230,16 @@ def test_tz_comparison():
def test_tz_info_deepcopy():
output = SchemaValidator(cs.datetime_schema()).validate_python('2023-02-15T16:23:44.037Z')
c = copy.deepcopy(output)
assert repr(output.tzinfo) == 'TzInfo(UTC)'
assert repr(c.tzinfo) == 'TzInfo(UTC)'
assert repr(output.tzinfo) == "TzInfo('UTC')"
assert repr(c.tzinfo) == "TzInfo('UTC')"
assert c == output


def test_tz_info_copy():
output = SchemaValidator(cs.datetime_schema()).validate_python('2023-02-15T16:23:44.037Z')
c = copy.copy(output)
assert repr(output.tzinfo) == 'TzInfo(UTC)'
assert repr(c.tzinfo) == 'TzInfo(UTC)'
assert repr(output.tzinfo) == "TzInfo('UTC')"
assert repr(c.tzinfo) == "TzInfo('UTC')"
assert c == output


Expand Down
Loading