]> git.ozlabs.org Git - patchwork/commitdiff
tests: Remove old-style test runner module
authorJeremy Kerr <jk@ozlabs.org>
Thu, 28 May 2015 05:44:14 +0000 (13:44 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 28 May 2015 05:59:36 +0000 (13:59 +0800)
We get the following warning on django 1.7:

System check identified some issues:

WARNINGS:
?: (1_6.W001) Some project unittests may not execute as expected.
HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information.

This change removes the unneeded base test module, and moves the
patchparser doctests into a proper test module.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
patchwork/bin/parsemail.py
patchwork/settings/base.py
patchwork/settings/dev.py
patchwork/tests/__init__.py
patchwork/tests/test_patchparser.py

index 19e6e57d5214fa309f5f27068df726c6f3696dfa..5cb0b505250eb5ea92fce5b1791c635c05d8d0e6 100755 (executable)
@@ -267,23 +267,8 @@ def find_patch_for_comment(project, mail):
 split_re = re.compile('[,\s]+')
 
 def split_prefixes(prefix):
-    """ Turn a prefix string into a list of prefix tokens
-
-    >>> split_prefixes('PATCH')
-    ['PATCH']
-    >>> split_prefixes('PATCH,RFC')
-    ['PATCH', 'RFC']
-    >>> split_prefixes('')
-    []
-    >>> split_prefixes('PATCH,')
-    ['PATCH']
-    >>> split_prefixes('PATCH ')
-    ['PATCH']
-    >>> split_prefixes('PATCH,RFC')
-    ['PATCH', 'RFC']
-    >>> split_prefixes('PATCH 1/2')
-    ['PATCH', '1/2']
-    """
+    """ Turn a prefix string into a list of prefix tokens """
+
     matches = split_re.split(prefix)
     return [ s for s in matches if s != '' ]
 
@@ -296,39 +281,8 @@ def clean_subject(subject, drop_prefixes = None):
     Removes Re: and Fwd: strings, as well as [PATCH]-style prefixes. By
     default, only [PATCH] is removed, and we keep any other bracketed data
     in the subject. If drop_prefixes is provided, remove those too,
-    comparing case-insensitively.
-
-    >>> clean_subject('meep')
-    'meep'
-    >>> clean_subject('Re: meep')
-    'meep'
-    >>> clean_subject('[PATCH] meep')
-    'meep'
-    >>> clean_subject('[PATCH] meep \\n meep')
-    'meep meep'
-    >>> clean_subject('[PATCH RFC] meep')
-    '[RFC] meep'
-    >>> clean_subject('[PATCH,RFC] meep')
-    '[RFC] meep'
-    >>> clean_subject('[PATCH,1/2] meep')
-    '[1/2] meep'
-    >>> clean_subject('[PATCH RFC 1/2] meep')
-    '[RFC,1/2] meep'
-    >>> clean_subject('[PATCH] [RFC] meep')
-    '[RFC] meep'
-    >>> clean_subject('[PATCH] [RFC,1/2] meep')
-    '[RFC,1/2] meep'
-    >>> clean_subject('[PATCH] [RFC] [1/2] meep')
-    '[RFC,1/2] meep'
-    >>> clean_subject('[PATCH] rewrite [a-z] regexes')
-    'rewrite [a-z] regexes'
-    >>> clean_subject('[PATCH] [RFC] rewrite [a-z] regexes')
-    '[RFC] rewrite [a-z] regexes'
-    >>> clean_subject('[foo] [bar] meep', ['foo'])
-    '[bar] meep'
-    >>> clean_subject('[FOO] [bar] meep', ['foo'])
-    '[bar] meep'
-    """
+    comparing case-insensitively."""
+
 
     subject = clean_header(subject)
 
index 9b52989da8bfabd04107fb655fe111140df57857..5b40bcba67709cc9fe33c7e3ddf368fc76489915 100644 (file)
@@ -113,3 +113,5 @@ COMPAT_REDIR = True
 # the scheme based on current access. This is useful if SSL protocol
 # is terminated upstream of the server (e.g. at the load balancer)
 FORCE_HTTPS_LINKS = False
+
+TEST_RUNNER = 'django.test.runner.DiscoverRunner'
index 6e373cc74a29b55cce86ad16e9ca84d6dde94bf2..3f2355d0b2d7a7d8e465a36f872f13e03176f643 100644 (file)
@@ -42,9 +42,6 @@ DATABASES = {
     },
 }
 
-if django.VERSION >= (1, 7):
-    TEST_RUNNER = 'django.test.runner.DiscoverRunner'
-
 #
 # Patchwork settings
 #
index 662386a62944dde8d3516fd4c0b6bf4f57c6d91e..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,35 +0,0 @@
-# Patchwork - automated patch tracking system
-# Copyright (C) 2008 Jeremy Kerr <jk@ozlabs.org>
-#
-# This file is part of the Patchwork package.
-#
-# Patchwork is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# Patchwork is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Patchwork; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-from patchwork.tests.test_patchparser import *
-from patchwork.tests.test_tags import *
-from patchwork.tests.test_encodings import *
-from patchwork.tests.test_bundles import *
-from patchwork.tests.test_mboxviews import *
-from patchwork.tests.test_updates import *
-from patchwork.tests.test_filters import *
-from patchwork.tests.test_confirm import *
-from patchwork.tests.test_registration import *
-from patchwork.tests.test_user import *
-from patchwork.tests.test_mail_settings import *
-from patchwork.tests.test_notifications import *
-from patchwork.tests.test_list import *
-from patchwork.tests.test_person import *
-from patchwork.tests.test_expiry import *
-from patchwork.tests.test_xmlrpc import *
index 5eefeb5092572bc8cc348695f53c4c7b282a1354..da2b07a96c8a38b156ab0f467f9e93368c65bd26 100644 (file)
@@ -37,7 +37,7 @@ class PatchTest(TestCase):
     project = defaults.project
 
 from patchwork.bin.parsemail import find_content, find_author, find_project, \
-                                    parse_mail
+                                    parse_mail, split_prefixes, clean_subject
 
 class InlinePatchTest(PatchTest):
     patch_filename = '0001-add-line.patch'
@@ -579,3 +579,41 @@ class ParseInitialTagsTest(PatchTest):
                             tag__name='Reviewed-by').count, 1)
         self.assertEquals(patch.patchtag_set.get(
                             tag__name='Tested-by').count, 1)
+
+class PrefixTest(TestCase):
+
+    def testSplitPrefixes(self):
+        self.assertEquals(split_prefixes('PATCH'), ['PATCH'])
+        self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+        self.assertEquals(split_prefixes(''), [])
+        self.assertEquals(split_prefixes('PATCH,'), ['PATCH'])
+        self.assertEquals(split_prefixes('PATCH '), ['PATCH'])
+        self.assertEquals(split_prefixes('PATCH,RFC'), ['PATCH', 'RFC'])
+        self.assertEquals(split_prefixes('PATCH 1/2'), ['PATCH', '1/2'])
+
+class SubjectTest(TestCase):
+
+    def testCleanSubject(self):
+        self.assertEquals(clean_subject('meep'), 'meep')
+        self.assertEquals(clean_subject('Re: meep'), 'meep')
+        self.assertEquals(clean_subject('[PATCH] meep'), 'meep')
+        self.assertEquals(clean_subject('[PATCH] meep \n meep'), 'meep meep')
+        self.assertEquals(clean_subject('[PATCH RFC] meep'), '[RFC] meep')
+        self.assertEquals(clean_subject('[PATCH,RFC] meep'), '[RFC] meep')
+        self.assertEquals(clean_subject('[PATCH,1/2] meep'), '[1/2] meep')
+        self.assertEquals(clean_subject('[PATCH RFC 1/2] meep'),
+                                            '[RFC,1/2] meep')
+        self.assertEquals(clean_subject('[PATCH] [RFC] meep'),
+                                            '[RFC] meep')
+        self.assertEquals(clean_subject('[PATCH] [RFC,1/2] meep'),
+                                            '[RFC,1/2] meep')
+        self.assertEquals(clean_subject('[PATCH] [RFC] [1/2] meep'),
+                                            '[RFC,1/2] meep')
+        self.assertEquals(clean_subject('[PATCH] rewrite [a-z] regexes'),
+                                            'rewrite [a-z] regexes')
+        self.assertEquals(clean_subject('[PATCH] [RFC] rewrite [a-z] regexes'),
+                                            '[RFC] rewrite [a-z] regexes')
+        self.assertEquals(clean_subject('[foo] [bar] meep', ['foo']),
+                                            '[bar] meep')
+        self.assertEquals(clean_subject('[FOO] [bar] meep', ['foo']),
+                                            '[bar] meep')