From 498092377b3ad033b29a45ba5a05609682426f2d Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 6 Jun 2019 21:04:56 -0700 Subject: [PATCH] Refs #27804 -- Used subTest() in BinaryFieldTests.test_set_and_retrieve. --- tests/model_fields/test_binaryfield.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/model_fields/test_binaryfield.py b/tests/model_fields/test_binaryfield.py index d9caf411123..7796be70a6e 100644 --- a/tests/model_fields/test_binaryfield.py +++ b/tests/model_fields/test_binaryfield.py @@ -11,16 +11,17 @@ class BinaryFieldTests(TestCase): def test_set_and_retrieve(self): data_set = (self.binary_data, bytearray(self.binary_data), memoryview(self.binary_data)) for bdata in data_set: - dm = DataModel(data=bdata) - dm.save() - dm = DataModel.objects.get(pk=dm.pk) - self.assertEqual(bytes(dm.data), bytes(bdata)) - # Resave (=update) - dm.save() - dm = DataModel.objects.get(pk=dm.pk) - self.assertEqual(bytes(dm.data), bytes(bdata)) - # Test default value - self.assertEqual(bytes(dm.short_data), b'\x08') + with self.subTest(data=repr(bdata)): + dm = DataModel(data=bdata) + dm.save() + dm = DataModel.objects.get(pk=dm.pk) + self.assertEqual(bytes(dm.data), bytes(bdata)) + # Resave (=update) + dm.save() + dm = DataModel.objects.get(pk=dm.pk) + self.assertEqual(bytes(dm.data), bytes(bdata)) + # Test default value + self.assertEqual(bytes(dm.short_data), b'\x08') def test_max_length(self): dm = DataModel(short_data=self.binary_data * 4)