diff mbox

[4/4] tests: Don't use exceptions for flow control

Message ID 1447036156-15377-5-git-send-email-stephen.finucane@intel.com
State Accepted
Headers show

Commit Message

Stephen Finucane Nov. 9, 2015, 2:29 a.m. UTC
Using exceptions for flow control is bad. Be consistent and instead
use proper functions to check for version support. This also allows
the use of tools to automatically identify feature flags when
removing support for Django versions in the future.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
---
 patchwork/tests/browser.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Stephen Finucane Nov. 11, 2015, 4:06 a.m. UTC | #1
> Using exceptions for flow control is bad. Be consistent and instead
> use proper functions to check for version support. This also allows
> the use of tools to automatically identify feature flags when
> removing support for Django versions in the future.
> 
> Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>

Merged.
diff mbox

Patch

diff --git a/patchwork/tests/browser.py b/patchwork/tests/browser.py
index 80285db..256a4d9 100644
--- a/patchwork/tests/browser.py
+++ b/patchwork/tests/browser.py
@@ -21,10 +21,11 @@  import errno
 import os
 import time
 
-try:  # django 1.7+
-    from django.contrib.staticfiles.testing import StaticLiveServerTestCase
-except:
+import django
+if django.VERSION < (1, 7):
     from django.test import LiveServerTestCase as StaticLiveServerTestCase
+else:
+    from django.contrib.staticfiles.testing import StaticLiveServerTestCase
 from selenium.common.exceptions import (
         NoSuchElementException, StaleElementReferenceException,
         TimeoutException)