Skip to content

Commit

Permalink
model.datatypes: add test to copy and deepcopy a date
Browse files Browse the repository at this point in the history
  • Loading branch information
JGrothoff committed Sep 16, 2024
1 parent 208e6f9 commit 5777e22
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/model/test_datatypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import datetime
import math
import unittest
import copy

import dateutil

Expand Down Expand Up @@ -177,6 +178,13 @@ def test_parse_partial_dates(self) -> None:
model.datatypes.from_xsd("10-10", model.datatypes.GYearMonth)
self.assertEqual("Value is not a valid XSD GYearMonth string", str(cm.exception))

def test_copy_date(self) -> None:
date = model.datatypes.Date(2020, 1, 24)
date_copy_shallow = copy.copy(date)
self.assertEqual(date, date_copy_shallow)
date_copy_deep = copy.deepcopy(date)
self.assertEqual(date, date_copy_deep)

def test_serialize_partial_dates(self) -> None:
self.assertEqual("2019", model.datatypes.xsd_repr(model.datatypes.GYear(2019)))
self.assertEqual("2019Z", model.datatypes.xsd_repr(model.datatypes.GYear(2019, datetime.timezone.utc)))
Expand Down

0 comments on commit 5777e22

Please sign in to comment.