From: Eli Bendersky Date: Sun, 26 Feb 2017 14:23:06 +0000 (-0800) Subject: Remove conditional unittest2 imports from tests X-Git-Tag: v0.25~46 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8227b7ac24079d40f6669603a198e0e92740af09;p=pyelftools.git Remove conditional unittest2 imports from tests We require 2.7+ now Also remove setup_syspath calls --- diff --git a/test/run_all_unittests.py b/test/run_all_unittests.py index 70a57d6..6859b94 100755 --- a/test/run_all_unittests.py +++ b/test/run_all_unittests.py @@ -10,11 +10,7 @@ from __future__ import print_function import os, sys - -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest def main(): diff --git a/test/test_arm_support.py b/test/test_arm_support.py index d31f2d1..87b1805 100644 --- a/test/test_arm_support.py +++ b/test/test_arm_support.py @@ -4,13 +4,9 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile diff --git a/test/test_callframe.py b/test/test_callframe.py index 79317d6..617f2c8 100644 --- a/test/test_callframe.py +++ b/test/test_callframe.py @@ -4,12 +4,8 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest -from utils import setup_syspath; setup_syspath() from elftools.common.py3compat import BytesIO from elftools.dwarf.callframe import ( CallFrameInfo, CIE, FDE, instruction_name, CallFrameInstruction, diff --git a/test/test_double_dynstr_section.py b/test/test_double_dynstr_section.py index 5f0c42e..d6fe8e6 100644 --- a/test/test_double_dynstr_section.py +++ b/test/test_double_dynstr_section.py @@ -4,13 +4,9 @@ # Yann Rouillard (yann@pleiades.fr.eu.org) # This code is in the public domain #------------------------------------------------------------------------------ -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile from elftools.elf.dynamic import DynamicSection, DynamicTag diff --git a/test/test_dwarf_expr.py b/test/test_dwarf_expr.py index 22a250f..747ee38 100644 --- a/test/test_dwarf_expr.py +++ b/test/test_dwarf_expr.py @@ -4,12 +4,8 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest -from utils import setup_syspath; setup_syspath() from elftools.dwarf.descriptions import ExprDumper, set_global_machine_arch from elftools.dwarf.structs import DWARFStructs diff --git a/test/test_dwarf_lineprogram.py b/test/test_dwarf_lineprogram.py index 0466926..5a5c65a 100644 --- a/test/test_dwarf_lineprogram.py +++ b/test/test_dwarf_lineprogram.py @@ -4,12 +4,8 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest -from utils import setup_syspath; setup_syspath() from elftools.common.py3compat import BytesIO, iteritems from elftools.dwarf.lineprogram import LineProgram, LineState, LineProgramEntry from elftools.dwarf.structs import DWARFStructs diff --git a/test/test_dwarf_range_lists.py b/test/test_dwarf_range_lists.py index 81dab9a..cde2d8b 100644 --- a/test/test_dwarf_range_lists.py +++ b/test/test_dwarf_range_lists.py @@ -4,13 +4,9 @@ # Eli Bendersky (eliben@gmail.com), Santhosh Kumar Mani (santhoshmani@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest import os +import unittest -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile class TestRangeLists(unittest.TestCase): diff --git a/test/test_dwarf_structs.py b/test/test_dwarf_structs.py index 777ff2c..e8d5b4a 100644 --- a/test/test_dwarf_structs.py +++ b/test/test_dwarf_structs.py @@ -4,12 +4,8 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest -from utils import setup_syspath; setup_syspath() from elftools.dwarf.structs import DWARFStructs diff --git a/test/test_dynamic.py b/test/test_dynamic.py index 8dc6c28..5284a1c 100644 --- a/test/test_dynamic.py +++ b/test/test_dynamic.py @@ -4,14 +4,9 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os -from utils import setup_syspath -setup_syspath() from elftools.elf.elffile import ELFFile from elftools.common.exceptions import ELFError from elftools.elf.dynamic import DynamicTag diff --git a/test/test_elffile.py b/test/test_elffile.py index d7d9602..f23abf0 100644 --- a/test/test_elffile.py +++ b/test/test_elffile.py @@ -4,12 +4,8 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile diff --git a/test/test_get_symbol_by_name.py b/test/test_get_symbol_by_name.py index ce5370e..780af3f 100644 --- a/test/test_get_symbol_by_name.py +++ b/test/test_get_symbol_by_name.py @@ -1,14 +1,15 @@ -# Tests the functionality of the ELF file function `get_symbol_by_name`. - -try: - import unittest2 as unittest -except ImportError: - import unittest +#------------------------------------------------------------------------------- +# Tests the functionality of get_symbol_by_name +# +# Eli Bendersky (eliben@gmail.com) +# This code is in the public domain +#------------------------------------------------------------------------------- +import unittest import os -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile + class TestGetSymbolByName(unittest.TestCase): def test_existing_symbol(self): with open(os.path.join('test', 'testfiles_for_unittests', diff --git a/test/test_gnuversions.py b/test/test_gnuversions.py index 546e0c8..5b6fc1c 100644 --- a/test/test_gnuversions.py +++ b/test/test_gnuversions.py @@ -4,14 +4,9 @@ # Yann Rouillard (yann@pleiades.fr.eu.org) # This code is in the public domain #------------------------------------------------------------------------------ -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os -from utils import setup_syspath -setup_syspath() from elftools.elf.elffile import ELFFile from elftools.elf.constants import VER_FLAGS from elftools.elf.gnuversions import ( diff --git a/test/test_mips_support.py b/test/test_mips_support.py index c0537d0..9430ce4 100644 --- a/test/test_mips_support.py +++ b/test/test_mips_support.py @@ -4,13 +4,9 @@ # Karl Vogel (karl.vogel@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile class TestMIPSSupport(unittest.TestCase): @@ -27,4 +23,3 @@ class TestMIPSSupport(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/test/test_solaris_support.py b/test/test_solaris_support.py index 12410f0..5a573b1 100644 --- a/test/test_solaris_support.py +++ b/test/test_solaris_support.py @@ -4,14 +4,10 @@ # Yann Rouillard (yann@pleiades.fr.eu.org) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os import copy -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile from elftools.elf.constants import SUNW_SYMINFO_FLAGS diff --git a/test/test_stab.py b/test/test_stab.py index 7180b2a..ba36914 100644 --- a/test/test_stab.py +++ b/test/test_stab.py @@ -4,13 +4,9 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest import os -from utils import setup_syspath; setup_syspath() from elftools.elf.elffile import ELFFile from elftools.elf.sections import StabSection diff --git a/test/test_utils.py b/test/test_utils.py index 5972b7d..86b1da1 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -4,13 +4,9 @@ # Eli Bendersky (eliben@gmail.com) # This code is in the public domain #------------------------------------------------------------------------------- -try: - import unittest2 as unittest -except ImportError: - import unittest +import unittest from random import randint -from utils import setup_syspath; setup_syspath() from elftools.common.py3compat import int2byte, BytesIO from elftools.common.utils import (parse_cstring_from_stream, preserve_stream_pos)