From 49412f55a5de7c3fa773e8a911439beb1568b901 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Thu, 15 Sep 2016 12:12:26 -0400 Subject: [PATCH] Refs #27025 -- Fixed a test for the new re.RegexFlag in Python 3.6. http://bugs.python.org/issue28082 --- tests/migrations/test_writer.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py index 8febf40f03..ad77b51ae7 100644 --- a/tests/migrations/test_writer.py +++ b/tests/migrations/test_writer.py @@ -7,6 +7,7 @@ import functools import math import os import re +import sys import tokenize import unittest @@ -35,6 +36,8 @@ try: except ImportError: enum = None +PY36 = sys.version_info >= (3, 6) + class Money(decimal.Decimal): def deconstruct(self): @@ -412,7 +415,10 @@ class WriterTests(SimpleTestCase): # Test a string regex with flag validator = RegexValidator(r'^[0-9]+$', flags=re.U) string = MigrationWriter.serialize(validator)[0] - self.assertEqual(string, "django.core.validators.RegexValidator('^[0-9]+$', flags=32)") + if PY36: + self.assertEqual(string, "django.core.validators.RegexValidator('^[0-9]+$', flags=re.RegexFlag(32))") + else: + self.assertEqual(string, "django.core.validators.RegexValidator('^[0-9]+$', flags=32)") self.serialize_round_trip(validator) # Test message and code