]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
tests: Don't use exceptions for flow control
authorStephen Finucane <stephen.finucane@intel.com>
Sat, 7 Nov 2015 01:28:56 +0000 (01:28 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Sat, 7 Nov 2015 04:13:29 +0000 (04:13 +0000)
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

index 80285dbd6d6eefe7e37b37e7dec844097b7786c4..256a4d9eedd4cd14065c5913d925f4d02740f95d 100644 (file)
@@ -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)