[Python-modules-commits] [django-modeltranslation] 04/05: Add a patch to fix test failures due to django.contrib.auth.migrations being not writable.

Raphaël Hertzog hertzog at moszumanska.debian.org
Mon Jun 27 21:05:59 UTC 2016


This is an automated email from the git hooks/post-receive script.

hertzog pushed a commit to branch master
in repository django-modeltranslation.

commit 55392a96dbe71d04310a7546081a1932631bd629
Author: Raphaël Hertzog <hertzog at debian.org>
Date:   Mon Jun 27 22:41:52 2016 +0200

    Add a patch to fix test failures due to django.contrib.auth.migrations being not writable.
---
 debian/changelog                                   |  7 ++-
 ...res-when-django-directory-is-not-writable.patch | 67 ++++++++++++++++++++++
 debian/patches/series                              |  1 +
 3 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/debian/changelog b/debian/changelog
index 31029d7..e2a87c0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,10 @@
 django-modeltranslation (0.11-1) unstable; urgency=medium
 
-  * Initial release (Closes: #nnnn)  <nnnn is the bug number of your ITP>
+  [ Sophie Brun ]
+  * Initial release.
+
+  [ Raphaël Hertzog ]
+  * Add a patch to fix test failures due to django.contrib.auth.migrations
+    being not writable.
 
  -- Sophie Brun <sophie at freexian.com>  Mon, 27 Jun 2016 11:20:05 +0200
diff --git a/debian/patches/Fix-test-failures-when-django-directory-is-not-writable.patch b/debian/patches/Fix-test-failures-when-django-directory-is-not-writable.patch
new file mode 100644
index 0000000..f7ad344
--- /dev/null
+++ b/debian/patches/Fix-test-failures-when-django-directory-is-not-writable.patch
@@ -0,0 +1,67 @@
+From: =?utf-8?q?Rapha=C3=ABl_Hertzog?= <hertzog at debian.org>
+Date: Mon, 27 Jun 2016 22:26:30 +0200
+Subject: Fix test failures when django directory is not writable
+MIME-Version: 1.0
+Content-Type: text/plain; charset="utf-8"
+Content-Transfer-Encoding: 8bit
+
+The tests modify the Group model exported by the django.contrib.auth
+application and as such, when makemigrations is called, it wants to create
+a new file in django/contrib/auth/migrations. This fails when the
+directory is not writable, as is the case for a typical system-wide
+installation (with a Debian package in my case).
+
+To avoid this problem, we modify the test runner to set the
+MIGRATION_MODULES django setting so that the migrations for the auth
+application are looked up in the “modeltranslation.tests.auth_migrations”
+package and we initialize that package with the migrations found
+in the django directory.
+
+Fix #377.
+
+Pull request is here:
+https://github.com/deschler/django-modeltranslation/pull/378
+
+Bug: https://github.com/deschler/django-modeltranslation/issues/377
+---
+ runtests.py | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/runtests.py b/runtests.py
+index c6667e7..941d956 100755
+--- a/runtests.py
++++ b/runtests.py
+@@ -1,5 +1,6 @@
+ #!/usr/bin/env python
+ import os
++import shutil
+ import sys
+ 
+ import django
+@@ -40,6 +41,9 @@ def runtests():
+                 'django.contrib.auth',
+                 'modeltranslation',
+             ),
++            MIGRATION_MODULES={
++                'auth': 'modeltranslation.tests.auth_migrations',
++            },
+             ROOT_URLCONF=None,  # tests override urlconf, but it still needs to be defined
+             LANGUAGES=(
+                 ('en', 'English'),
+@@ -47,6 +51,16 @@ def runtests():
+             MIDDLEWARE_CLASSES=(),
+         )
+ 
++    # Copy django.contrib.auth.migrations to a writable path
++    dj_auth_migrations_dir = os.path.join(os.path.dirname(django.__file__),
++                                          'contrib', 'auth', 'migrations')
++    auth_migrations_dir = os.path.join('modeltranslation', 'tests',
++                                       'auth_migrations')
++    if os.path.exists(dj_auth_migrations_dir):
++        if os.path.isdir(auth_migrations_dir):
++            shutil.rmtree(auth_migrations_dir)
++        shutil.copytree(dj_auth_migrations_dir, auth_migrations_dir)
++
+     if django.VERSION >= (1, 7):
+         django.setup()
+     failures = call_command(
diff --git a/debian/patches/series b/debian/patches/series
new file mode 100644
index 0000000..413f9f7
--- /dev/null
+++ b/debian/patches/series
@@ -0,0 +1 @@
+Fix-test-failures-when-django-directory-is-not-writable.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-modeltranslation.git



More information about the Python-modules-commits mailing list