From 794b7d803359c7d510910361f4d92429b43d0e79 Mon Sep 17 00:00:00 2001 From: Keda87 Date: Tue, 29 Nov 2016 12:54:17 +0700 Subject: [PATCH] Refs #27546 -- Tested some __repr__() methods. --- AUTHORS | 1 + tests/i18n/test_management.py | 13 +++++++++++++ tests/raw_query/tests.py | 6 ++++++ tests/serializers/test_deserializedobject.py | 12 ++++++++++++ tests/utils_tests/test_baseconv.py | 4 ++++ 5 files changed, 36 insertions(+) create mode 100644 tests/i18n/test_management.py create mode 100644 tests/serializers/test_deserializedobject.py diff --git a/AUTHORS b/AUTHORS index 4e475a4b25..58759fd83f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,6 +11,7 @@ answer newbie questions, and generally made Django that much better: Adam Johnson Adam Malinowski Adam Vandenberg + Adiyat Mubarak Adrian Holovaty Adrien Lemaire Afonso Fernández Nogueira diff --git a/tests/i18n/test_management.py b/tests/i18n/test_management.py new file mode 100644 index 0000000000..e661daabe5 --- /dev/null +++ b/tests/i18n/test_management.py @@ -0,0 +1,13 @@ +import os + +from django.core.management.commands.makemessages import TranslatableFile +from django.test import SimpleTestCase + + +class TranslatableFileTests(SimpleTestCase): + + def test_repr(self): + dirpath = 'dir' + file_name = 'example' + trans_file = TranslatableFile(dirpath=dirpath, file_name=file_name, locale_dir=None) + self.assertEqual(repr(trans_file), '' % os.path.join(dirpath, file_name)) diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py index 3388765a98..360dd31d5f 100644 --- a/tests/raw_query/tests.py +++ b/tests/raw_query/tests.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals from datetime import date from decimal import Decimal +from django.db.models.query import RawQuerySet from django.db.models.query_utils import InvalidQuery from django.test import TestCase, skipUnlessDBFeature @@ -90,6 +91,11 @@ class RawQueryTests(TestCase): self.assertTrue(hasattr(result, annotation)) self.assertEqual(getattr(result, annotation), value) + def test_rawqueryset_repr(self): + queryset = RawQuerySet(raw_query='SELECT * FROM raw_query_author') + self.assertEqual(repr(queryset), '') + self.assertEqual(repr(queryset.query), '') + def test_simple_raw_query(self): """ Basic test of raw query with a simple database query diff --git a/tests/serializers/test_deserializedobject.py b/tests/serializers/test_deserializedobject.py new file mode 100644 index 0000000000..d9c313b78d --- /dev/null +++ b/tests/serializers/test_deserializedobject.py @@ -0,0 +1,12 @@ +from django.core.serializers.base import DeserializedObject +from django.test import SimpleTestCase + +from .models import Author + + +class TestDeserializedObjectTests(SimpleTestCase): + + def test_repr(self): + author = Author(name='John', pk=1) + deserial_obj = DeserializedObject(obj=author) + self.assertEqual(repr(deserial_obj), '') diff --git a/tests/utils_tests/test_baseconv.py b/tests/utils_tests/test_baseconv.py index bffaac87b4..538189bbe6 100644 --- a/tests/utils_tests/test_baseconv.py +++ b/tests/utils_tests/test_baseconv.py @@ -45,3 +45,7 @@ class TestBaseConv(TestCase): with self.assertRaises(ValueError): BaseConverter('abc', sign='a') self.assertIsInstance(BaseConverter('abc', sign='d'), BaseConverter) + + def test_repr(self): + base7 = BaseConverter('cjdhel3', sign='g') + self.assertEqual(repr(base7), '')