[PATCH] pep8: Resolve some issues with lambda functions
Stephen Finucane
stephen.finucane at intel.com
Thu Feb 4 08:24:53 AEDT 2016
Signed-off-by: Stephen Finucane <stephen.finucane at intel.com>
---
patchwork/tests/browser.py | 17 +++++++++--------
patchwork/views/user.py | 4 ++--
2 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/patchwork/tests/browser.py b/patchwork/tests/browser.py
index 4444f9d..848e9be 100644
--- a/patchwork/tests/browser.py
+++ b/patchwork/tests/browser.py
@@ -21,11 +21,10 @@ import errno
import os
import time
-import django
-if django.VERSION < (1, 7):
- from django.test import LiveServerTestCase as StaticLiveServerTestCase
-else:
+try:
from django.contrib.staticfiles.testing import StaticLiveServerTestCase
+except: # Django < 1.7
+ from django.test import LiveServerTestCase as StaticLiveServerTestCase
from selenium.common.exceptions import (
NoSuchElementException, StaleElementReferenceException,
TimeoutException)
@@ -139,22 +138,24 @@ class SeleniumTestCase(StaticLiveServerTestCase):
return self.selenium.switch_to.active_element
def wait_until_present(self, name):
- is_present = lambda driver: driver.find_element_by_name(name)
+ def is_present(driver):
+ return driver.find_element_by_name(name)
msg = "An element named '%s' should be on the page" % name
element = Wait(self.selenium).until(is_present, msg)
self.screenshot()
return element
def wait_until_visible(self, selector):
- is_visible = lambda driver: self.find(selector).is_displayed()
+ def is_visible(driver):
+ return self.find(selector).is_displayed()
msg = "The element matching '%s' should be visible" % selector
Wait(self.selenium).until(is_visible, msg)
self.screenshot()
return self.find(selector)
def wait_until_focused(self, selector):
- is_focused = lambda driver: (
- self.find(selector) == self.focused_element())
+ def is_focused(driver):
+ return self.find(selector) == self.focused_element()
msg = "The element matching '%s' should be focused" % selector
Wait(self.selenium).until(is_focused, msg)
self.screenshot()
diff --git a/patchwork/views/user.py b/patchwork/views/user.py
index d6e5797..dd5eada 100644
--- a/patchwork/views/user.py
+++ b/patchwork/views/user.py
@@ -148,8 +148,8 @@ def link(request):
[form.cleaned_data['email']])
except Exception:
context['confirmation'] = None
- context['error'] = 'An error occurred during confirmation. ' + \
- 'Please try again later'
+ context['error'] = ('An error occurred during confirmation. '
+ 'Please try again later')
else:
form = UserPersonLinkForm()
context['linkform'] = form
--
2.0.0
More information about the Patchwork
mailing list