From 66bb6a87251336579bde5bdf2e1c0049a1cfea03 Mon Sep 17 00:00:00 2001 From: John R Dietrick Date: Sun, 3 Jan 2016 01:21:29 -0500 Subject: [PATCH] Get skipIf without installing unittest2 In Python 2.7+, unittest *is* unittest2. We prefer this one. But in Python 2.6, we can get skipIf from django.utils.unittest, provided Django is 1.8 or older. --- tests/requirements.txt | 1 - tests/test_main.py | 8 ++++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/requirements.txt b/tests/requirements.txt index ac59224..5eb9697 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -6,4 +6,3 @@ dj-email-url dj-search-url django-cache-url>=1.0.0 six -unittest2 diff --git a/tests/test_main.py b/tests/test_main.py index e6e1dd2..b7e374c 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,13 +1,17 @@ import os import subprocess import sys -import unittest2 from django import VERSION as DJANGO_VERSION from django.conf import global_settings from django.test import TestCase from django.core.exceptions import ImproperlyConfigured +if sys.version_info >= (2, 7): + from unittest import skipIf +else: + from django.utils.unittest import skipIf + from mock import patch from configurations.importer import ConfigurationImporter @@ -111,7 +115,7 @@ class MainTests(TestCase): stdout=subprocess.PIPE) self.assertIn('--configuration', proc.communicate()[0].decode('utf-8')) - @unittest2.skipIf(DJANGO_VERSION >= (1, 10), 'only applies to Django < 1.10') + @skipIf(DJANGO_VERSION >= (1, 10), 'only applies to Django < 1.10') def test_deprecated_option_list_command(self): """ Verify that the configuration option is correctly added to any