made all tests run with Python 2.6 that has unittest2 installed. Added basic tox.ini file for running tox tests
diff --git a/.hgignore b/.hgignore
index 5ada10a..b5fbdde 100644
--- a/.hgignore
+++ b/.hgignore
@@ -2,6 +2,7 @@
*.pyc
.coverage
+.tox
htmlcov
tags
build
diff --git a/test/run_all_unittests.py b/test/run_all_unittests.py
index 54ad5f0..100744a 100755
--- a/test/run_all_unittests.py
+++ b/test/run_all_unittests.py
@@ -7,13 +7,16 @@
# Eli Bendersky (eliben@gmail.com)
# This code is in the public domain
#-------------------------------------------------------------------------------
-from unittest import TestLoader, TextTestRunner
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
if __name__ == '__main__':
try:
- tests = TestLoader().discover('test', 'test*.py', 'test')
- TextTestRunner().run(tests)
+ tests = unittest.TestLoader().discover('test', 'test*.py', 'test')
+ unittest.TextTestRunner().run(tests)
except ImportError as err:
print err
print '!! Please execute from the root directory of pyelftools'
diff --git a/test/test_callframe.py b/test/test_callframe.py
index 30e405b..3fe1b9a 100644
--- a/test/test_callframe.py
+++ b/test/test_callframe.py
@@ -1,4 +1,8 @@
-import sys, unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+import sys
from cStringIO import StringIO
sys.path.extend(['.', '..'])
diff --git a/test/test_dwarf_expr.py b/test/test_dwarf_expr.py
index 8e293db..d740eaf 100644
--- a/test/test_dwarf_expr.py
+++ b/test/test_dwarf_expr.py
@@ -1,4 +1,8 @@
-import sys, unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+import sys
from cStringIO import StringIO
sys.path.extend(('..', '.'))
diff --git a/test/test_dwarf_lineprogram.py b/test/test_dwarf_lineprogram.py
index 56d96c3..d3e1100 100644
--- a/test/test_dwarf_lineprogram.py
+++ b/test/test_dwarf_lineprogram.py
@@ -1,4 +1,8 @@
-import sys, unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+import sys
from cStringIO import StringIO
sys.path.extend(['.', '..'])
diff --git a/test/test_dwarf_structs.py b/test/test_dwarf_structs.py
index a1e30d7..d85ee0f 100644
--- a/test/test_dwarf_structs.py
+++ b/test/test_dwarf_structs.py
@@ -1,4 +1,8 @@
-import sys, unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+import sys
sys.path.extend(['.', '..'])
from elftools.dwarf.structs import DWARFStructs
diff --git a/test/test_utils.py b/test/test_utils.py
index 54a09bb..a30ac3a 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -1,4 +1,8 @@
-import sys, unittest
+try:
+ import unittest2 as unittest
+except ImportError:
+ import unittest
+import sys
from cStringIO import StringIO
from random import randint
diff --git a/tox.ini b/tox.ini
new file mode 100644
index 0000000..a91cd2f
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,12 @@
+[tox]
+envlist = py27,py26
+
+[testenv]
+commands =
+ python test/run_all_unittests.py
+ python test/run_readelf_tests.py
+
+[testenv:py26]
+deps =
+ unittest2
+