From: Stephen Finucane Date: Sun, 19 Jun 2016 19:36:14 +0000 (+0100) Subject: tests: Remove 'find_in_context' X-Git-Tag: v2.0.0-rc1~328 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=93b3ed95e606fce4eb231d69e54ddbf2cc27e7da;p=thirdparty%2Fpatchwork.git tests: Remove 'find_in_context' The aformentioned function handled both dicts and lists in a request's context field. Seeing as only dicts are ever returned, this is not necessary. Signed-off-by: Stephen Finucane Reviewed-by: Andy Doan --- diff --git a/patchwork/tests/test_bundles.py b/patchwork/tests/test_bundles.py index cbed216b..e822fbe6 100644 --- a/patchwork/tests/test_bundles.py +++ b/patchwork/tests/test_bundles.py @@ -25,11 +25,14 @@ import unittest from django.conf import settings from django.test import TestCase from django.utils.http import urlencode -from django.utils.six.moves import range, zip +from django.utils.six.moves import range +from django.utils.six.moves import zip -from patchwork.models import Bundle, BundlePatch -from patchwork.tests.utils import (defaults, create_user, find_in_context, - create_patches) +from patchwork.models import Bundle +from patchwork.models import BundlePatch +from patchwork.tests.utils import create_patches +from patchwork.tests.utils import create_user +from patchwork.tests.utils import defaults def bundle_url(bundle): @@ -46,8 +49,7 @@ class BundleListTest(TestCase): def testNoBundles(self): response = self.client.get('/user/bundles/') self.assertEqual(response.status_code, 200) - self.assertEqual( - len(find_in_context(response.context, 'bundles')), 0) + self.assertEqual(len(response.context['bundles']), 0) def testSingleBundle(self): defaults.project.save() @@ -55,8 +57,7 @@ class BundleListTest(TestCase): bundle.save() response = self.client.get('/user/bundles/') self.assertEqual(response.status_code, 200) - self.assertEqual( - len(find_in_context(response.context, 'bundles')), 1) + self.assertEqual(len(response.context['bundles']), 1) def tearDown(self): self.user.delete() @@ -87,7 +88,7 @@ class BundleViewTest(BundleTestBase): def testEmptyBundle(self): response = self.client.get(bundle_url(self.bundle)) self.assertEqual(response.status_code, 200) - page = find_in_context(response.context, 'page') + page = response.context['page'] self.assertEqual(len(page.object_list), 0) def testNonEmptyBundle(self): @@ -95,7 +96,7 @@ class BundleViewTest(BundleTestBase): response = self.client.get(bundle_url(self.bundle)) self.assertEqual(response.status_code, 200) - page = find_in_context(response.context, 'page') + page = response.context['page'] self.assertEqual(len(page.object_list), 1) def testBundleOrder(self): diff --git a/patchwork/tests/utils.py b/patchwork/tests/utils.py index 26087821..37478b6e 100644 --- a/patchwork/tests/utils.py +++ b/patchwork/tests/utils.py @@ -126,18 +126,6 @@ def create_covers(count=1): return covers -def find_in_context(context, key): - if isinstance(context, list): - for c in context: - v = find_in_context(c, key) - if v is not None: - return v - else: - if key in context: - return context[key] - return None - - def read_patch(filename, encoding=None): file_path = os.path.join(_test_patch_dir, filename) if encoding is not None: