From 85916e6c56076a29c6113e169d3e4926a7c886b1 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 28 May 2015 13:44:14 +0800 Subject: tests: Remove old-style test runner module 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 --- patchwork/tests/__init__.py | 35 -------------------------------- patchwork/tests/test_patchparser.py | 40 ++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 36 deletions(-) (limited to 'patchwork/tests') diff --git a/patchwork/tests/__init__.py b/patchwork/tests/__init__.py index 662386a..e69de29 100644 --- a/patchwork/tests/__init__.py +++ b/patchwork/tests/__init__.py @@ -1,35 +0,0 @@ -# Patchwork - automated patch tracking system -# Copyright (C) 2008 Jeremy Kerr -# -# 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 * diff --git a/patchwork/tests/test_patchparser.py b/patchwork/tests/test_patchparser.py index 5eefeb5..da2b07a 100644 --- a/patchwork/tests/test_patchparser.py +++ b/patchwork/tests/test_patchparser.py @@ -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') -- cgit v1.2.3