Adapted test assertion against yaml dump

Fixes #12914 (again).
This commit is contained in:
Claude Paroz 2013-01-11 17:49:55 +01:00
parent 9f9a7f03d7
commit 2e55cf580e
1 changed files with 4 additions and 1 deletions

View File

@ -2,6 +2,7 @@ from __future__ import unicode_literals
import datetime
import os
import re
import sys
import time
import warnings
@ -504,7 +505,9 @@ class SerializationTests(TestCase):
self.assertXMLEqual(field.childNodes[0].wholeText, dt)
def assert_yaml_contains_datetime(self, yaml, dt):
self.assertIn("- fields: {dt: !!timestamp '%s'}" % dt, yaml)
# Depending on the yaml dumper, '!timestamp' might be absent
self.assertRegexpMatches(yaml,
r"- fields: {dt: !(!timestamp)? '%s'}" % re.escape(dt))
def test_naive_datetime(self):
dt = datetime.datetime(2011, 9, 1, 13, 20, 30)