Commits

Gustavo Picon committed 39084b3

xfailing deletion tests on mysql+django1.3+proxy models

  • Participants
  • Parent commits 270c02a

Comments (0)

Files changed (2)

treebeard/tests/models.py

-from django.db import models
+from django.db import models, connection
 from django.contrib.auth.models import User
 
 from treebeard.mp_tree import MP_Node
 MP_SHORTPATH_MODELS = MP_TestNodeShortPath, MP_TestSortedNodeShortPath
 
 
-def empty_base_tables():
-    for model in BASE_MODELS:
+def empty_models_tables(models):
+    for model in models:
         model.objects.all().delete()
-
-
-def empty_deps_tables():
-    for model in DEP_MODELS:
-        model.objects.all().delete()

treebeard/tests/test_treebeard.py

 import os
 import sys
 
+from django import VERSION as DJANGO_VERSION
 from django.contrib.admin.options import ModelAdmin
 from django.contrib.admin.sites import AdminSite
 from django.test import TestCase
 @pytest.fixture(scope='function',
                 params=models.BASE_MODELS + models.PROXY_MODELS)
 def model(request):
+    test_model = request.param
+    if (
+        test_model in models.PROXY_MODELS and
+        DJANGO_VERSION[:2] == (1, 3) and
+        request.cls == TestDelete and
+        test_model.get_database_vendor('write') == 'mysql'
+    ):
+        pytest.xfail("https://bitbucket.org/tabo/django-treebeard/issue/44")
     return _prepare_db_test(request)
 
 
 
     @classmethod
     def teardown_class(cls):
-        models.empty_base_tables()
+        models.empty_models_tables(models.BASE_MODELS)
 
 
 class TestClassMethods(TestNonEmptyTree):
 
     @classmethod
     def teardown_class(cls):
-        models.empty_deps_tables()
-        TestNonEmptyTree.teardown_class()
+        models.empty_models_tables(models.DEP_MODELS + models.BASE_MODELS)
 
     def test_delete_leaf(self, model):
         model.objects.get(desc='231').delete()
 
     @classmethod
     def teardown_class(cls):
-        models.empty_base_tables()
+        models.empty_models_tables(models.BASE_MODELS)
 
     def test_descendants_group_count_root(self, model):
         expected = [(o.desc, o.get_descendant_count())