Skip to content

Commit 2569fbc

Browse files
committed
Use quotes in repr of TzInfo
1 parent 3414703 commit 2569fbc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/input/datetime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl TzInfo {
574574
}
575575

576576
fn __repr__(&self) -> String {
577-
format!("TzInfo({})", self.__str__())
577+
format!("TzInfo('{}')", self.__str__())
578578
}
579579

580580
fn __str__(&self) -> String {

tests/validators/test_datetime.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def test_custom_timezone_repr():
198198
assert output.tzinfo.dst(output) is None
199199
assert output.tzinfo.tzname(output) == '-12:15'
200200
assert str(output.tzinfo) == '-12:15'
201-
assert repr(output.tzinfo) == 'TzInfo(-12:15)'
201+
assert repr(output.tzinfo) == "TzInfo('-12:15')"
202202

203203

204204
def test_custom_timezone_utc_repr():
@@ -208,7 +208,7 @@ def test_custom_timezone_utc_repr():
208208
assert output.tzinfo.dst(output) is None
209209
assert output.tzinfo.tzname(output) == 'UTC'
210210
assert str(output.tzinfo) == 'UTC'
211-
assert repr(output.tzinfo) == 'TzInfo(UTC)'
211+
assert repr(output.tzinfo) == "TzInfo('UTC')"
212212

213213

214214
def test_tz_comparison():
@@ -230,16 +230,16 @@ def test_tz_comparison():
230230
def test_tz_info_deepcopy():
231231
output = SchemaValidator(cs.datetime_schema()).validate_python('2023-02-15T16:23:44.037Z')
232232
c = copy.deepcopy(output)
233-
assert repr(output.tzinfo) == 'TzInfo(UTC)'
234-
assert repr(c.tzinfo) == 'TzInfo(UTC)'
233+
assert repr(output.tzinfo) == "TzInfo('UTC')"
234+
assert repr(c.tzinfo) == "TzInfo('UTC')"
235235
assert c == output
236236

237237

238238
def test_tz_info_copy():
239239
output = SchemaValidator(cs.datetime_schema()).validate_python('2023-02-15T16:23:44.037Z')
240240
c = copy.copy(output)
241-
assert repr(output.tzinfo) == 'TzInfo(UTC)'
242-
assert repr(c.tzinfo) == 'TzInfo(UTC)'
241+
assert repr(output.tzinfo) == "TzInfo('UTC')"
242+
assert repr(c.tzinfo) == "TzInfo('UTC')"
243243
assert c == output
244244

245245

0 commit comments

Comments
 (0)