From: Ben England Date: Fri, 7 Sep 2018 16:43:21 +0000 (-0400) Subject: remove dependency on unittest2 module X-Git-Tag: fio-3.10~3^2 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=088a092eda135e6fe5b4df5326aec4fe76ace14d;hp=bb661c4027e5a0482b9fcc1c1b4e7e918650ee72 remove dependency on unittest2 module The dependency of fio-histo-log-pctiles.py on unittest2 module was causing heartburn for pbench community so I removed the dependency. If unittest2 python package is installed and unittest2 module can be imported, that's fine, we'll use it if requested, but if it's not, that's fine too, you can still use the program. --- diff --git a/tools/hist/fio-histo-log-pctiles.py b/tools/hist/fio-histo-log-pctiles.py index c398113c..bb016ead 100755 --- a/tools/hist/fio-histo-log-pctiles.py +++ b/tools/hist/fio-histo-log-pctiles.py @@ -24,7 +24,12 @@ import sys, os, math, copy from copy import deepcopy import argparse -import unittest2 + +unittest2_imported = True +try: + import unittest2 +except ImportError: + unittest2_imported = False msec_per_sec = 1000 nsec_per_usec = 1000 @@ -412,14 +417,14 @@ def compute_percentiles_from_logs(): #end of MAIN PROGRAM - ##### below are unit tests ############## -import tempfile, shutil -from os.path import join -should_not_get_here = False +if unittest2_imported: + import tempfile, shutil + from os.path import join + should_not_get_here = False -class Test(unittest2.TestCase): + class Test(unittest2.TestCase): tempdir = None # a little less typing please @@ -651,7 +656,10 @@ class Test(unittest2.TestCase): if __name__ == '__main__': if os.getenv('UNITTEST'): - sys.exit(unittest2.main()) + if unittest2_imported: + sys.exit(unittest2.main()) + else: + raise Exception('you must install unittest2 module to run unit test') else: compute_percentiles_from_logs()