diff --git a/tests/db_functions/test_cast.py b/tests/db_functions/test_cast.py
index 70de20e5eb..1e0e89521a 100644
a
|
b
|
|
| 1 | from unittest import mock |
| 2 | |
1 | 3 | from django.db import models |
2 | 4 | from django.db.models.expressions import Value |
3 | 5 | from django.db.models.functions import Cast |
… |
… |
class CastTests(TestCase):
|
19 | 21 | numbers = Author.objects.annotate(cast_string=Cast('age', models.CharField(max_length=255)),) |
20 | 22 | self.assertEqual(numbers.get().cast_string, '1') |
21 | 23 | |
| 24 | @mock.patch('sys.stderr') |
| 25 | def test_cast_to_char_field_with_max_length(self, mocked_stdout): |
| 26 | names = Author.objects.annotate(cast_string=Cast('name', models.CharField(max_length=1))) |
| 27 | self.assertEqual(names.get().cast_string, 'B') |
| 28 | |
22 | 29 | def test_cast_to_integer(self): |
23 | 30 | for field_class in ( |
24 | 31 | models.IntegerField, |