Skip to content

Commit 6e974c5

Browse files
author
Anton Prokhorov
committed
Add support of django 1.7 and python2 in admin tests
1 parent 91b5785 commit 6e974c5

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

polymorphic_tree/tests/test_admin.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
from unittest import TestCase
2-
from unittest.mock import MagicMock
2+
3+
import sys
34

45
from django.contrib.admin import AdminSite
56

67
from polymorphic_tree.tests.admin import TreeNodeParentAdmin
78
from polymorphic_tree.tests.models import ModelWithCustomParentName
89

10+
if sys.version_info[0] == 3:
11+
from unittest.mock import MagicMock
12+
else:
13+
from mock import MagicMock
14+
915

1016
class PolymorphicAdminTests(TestCase):
1117
"""Tests for admin"""
@@ -33,5 +39,7 @@ def test_make_child2_child_child1(self):
3339
'position': 'inside'
3440
}
3541
self.parent_admin.api_node_moved_view(request)
36-
self.child2.refresh_from_db()
42+
# Analog of self.child2.refresh_from_db()
43+
# This hack used for django 1.7 support
44+
self.child2 = ModelWithCustomParentName.objects.get(pk=self.child2.pk)
3745
self.assertEqual(self.child2.chief, self.child1)

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ deps =
2121
django19: django-mptt >= 0.8.0
2222
django110: Django >= 1.10, < 1.11
2323
django110: django-mptt >= 0.8.6
24+
py26: mock
25+
py27: mock
2426
django-dev: https://github.com/django/django/tarball/master
2527
commands=
2628
python runtests.py

0 commit comments

Comments
 (0)