Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

Commit

Permalink
Refs #27546 -- Tested some __repr__() methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Keda87 authored and timgraham committed Dec 1, 2016
1 parent 7850010 commit 794b7d8
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ answer newbie questions, and generally made Django that much better:
Adam Johnson <https://github.com/adamchainz>
Adam Malinowski <http://adammalinowski.co.uk>
Adam Vandenberg
Adiyat Mubarak <[email protected]>
Adrian Holovaty <[email protected]>
Adrien Lemaire <[email protected]>
Afonso Fernández Nogueira <[email protected]>
Expand Down
13 changes: 13 additions & 0 deletions tests/i18n/test_management.py
Original file line number Diff line number Diff line change
@@ -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), '<TranslatableFile: %s>' % os.path.join(dirpath, file_name))
6 changes: 6 additions & 0 deletions tests/raw_query/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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

Expand Down Expand Up @@ -90,6 +91,11 @@ def assertAnnotations(self, results, expected_annotations):
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), '<RawQuerySet: SELECT * FROM raw_query_author>')
self.assertEqual(repr(queryset.query), '<RawQuery: SELECT * FROM raw_query_author>')

def test_simple_raw_query(self):
"""
Basic test of raw query with a simple database query
Expand Down
12 changes: 12 additions & 0 deletions tests/serializers/test_deserializedobject.py
Original file line number Diff line number Diff line change
@@ -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), '<DeserializedObject: serializers.Author(pk=1)>')
4 changes: 4 additions & 0 deletions tests/utils_tests/test_baseconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ def test_exception(self):
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), '<BaseConverter: base7 (cjdhel3)>')

0 comments on commit 794b7d8

Please sign in to comment.