From dbd47fe3e0002d9a9c1975075d7435a15b87fb51 Mon Sep 17 00:00:00 2001 From: Matěj Cepl Date: Mon, 16 Apr 2012 23:50:15 +0200 Subject: Make the package compatible with python 2.7 There is actually unittest module now, so we have to work for the possibility that unittest2 is not available. Fixes #49. --- test/__init__.py | 5 ++++- test/test_input.py | 5 ++++- test/test_load.py | 5 ++++- test/test_output.py | 5 ++++- test/test_reader.py | 5 ++++- test/test_writer.py | 5 ++++- 6 files changed, 24 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/__init__.py b/test/__init__.py index 83cdd6d..05ba3b2 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -2,7 +2,10 @@ from __future__ import absolute_import, print_function, unicode_literals import logging import yamlish -import unittest2 as unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import yaml import tempfile import textwrap diff --git a/test/test_input.py b/test/test_input.py index cfd4142..6b5c5ca 100644 --- a/test/test_input.py +++ b/test/test_input.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals import test -import unittest2 as unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import yamlish test_data_list = [ diff --git a/test/test_load.py b/test/test_load.py index b5ac95e..7a76ae1 100644 --- a/test/test_load.py +++ b/test/test_load.py @@ -1,6 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -import unittest2 as unittest +try: + import unittest2 as unittest +except ImportError: + import unittest class TestBasics(unittest.TestCase): def test_import(self): diff --git a/test/test_output.py b/test/test_output.py index 888f812..1105b84 100644 --- a/test/test_output.py +++ b/test/test_output.py @@ -5,7 +5,10 @@ Test general output functionality. Without much stress on the format itself. """ from __future__ import absolute_import, print_function, unicode_literals -import unittest2 as unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import yamlish import yaml import logging diff --git a/test/test_reader.py b/test/test_reader.py index 0676b30..a34104c 100644 --- a/test/test_reader.py +++ b/test/test_reader.py @@ -3,7 +3,10 @@ from __future__ import absolute_import, print_function, unicode_literals import yaml import yamlish import test -import unittest2 as unittest +try: + import unittest2 as unittest +except ImportError: + import unittest test_data_list = [ { diff --git a/test/test_writer.py b/test/test_writer.py index 7d9e690..a3f3893 100644 --- a/test/test_writer.py +++ b/test/test_writer.py @@ -1,7 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import, print_function, unicode_literals -import unittest2 as unittest +try: + import unittest2 as unittest +except ImportError: + import unittest import test import yamlish -- cgit