From 34c56687ae4df2cff632447eddd7ef255ee74726 Mon Sep 17 00:00:00 2001 From: Jarek Glowacki Date: Thu, 10 Mar 2016 14:09:44 +1100 Subject: [PATCH] Fixed #26342 -- Prevented unpacking when repr a NodeNotFoundError --- django/db/migrations/exceptions.py | 2 +- tests/migrations/test_exceptions.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 tests/migrations/test_exceptions.py diff --git a/django/db/migrations/exceptions.py b/django/db/migrations/exceptions.py index 1e8549a504e..dd3f1be2a6a 100644 --- a/django/db/migrations/exceptions.py +++ b/django/db/migrations/exceptions.py @@ -53,7 +53,7 @@ class NodeNotFoundError(LookupError): return self.message def __repr__(self): - return "NodeNotFoundError(%r)" % self.node + return "NodeNotFoundError(%r)" % (self.node, ) class MigrationSchemaMissing(DatabaseError): diff --git a/tests/migrations/test_exceptions.py b/tests/migrations/test_exceptions.py new file mode 100644 index 00000000000..3d839471f9e --- /dev/null +++ b/tests/migrations/test_exceptions.py @@ -0,0 +1,12 @@ +from django.db.migrations.exceptions import NodeNotFoundError +from django.test import SimpleTestCase + + +class ExceptionTests(SimpleTestCase): + def test_node_not_found_error_repr(self): + node = ('some_app_label', 'some_migration_label') + error_repr = repr(NodeNotFoundError('some message', node)) + self.assertEqual( + error_repr, + "NodeNotFoundError(('some_app_label', 'some_migration_label'))" + )