diff options
author | Michael DeHaan <mdehaan@redhat.com> | 2007-02-13 14:51:27 -0500 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-02-13 14:51:27 -0500 |
commit | 802fb994dd7588972f691c7b4009504b52223280 (patch) | |
tree | 093bc07b80aba3850713148d6b680c1ff2e00d93 /tests/tests.py | |
parent | 16202b072277b1f1e1578a555fe3040b82631f71 (diff) | |
download | third_party-cobbler-802fb994dd7588972f691c7b4009504b52223280.tar.gz third_party-cobbler-802fb994dd7588972f691c7b4009504b52223280.tar.xz third_party-cobbler-802fb994dd7588972f691c7b4009504b52223280.zip |
Added pycallgraph code to generate a cobbler call graph, for exploring
relationships and hot spots. Right now, there isn't anything exceptionally
eye opening, but it's kind of neat to see it visualized.
Requires graphviz.
Diffstat (limited to 'tests/tests.py')
-rw-r--r-- | tests/tests.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/tests.py b/tests/tests.py index 59c8796..0445e3b 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -2,6 +2,13 @@ # # Michael DeHaan <mdehaan@redhat.com> +HAS_GRAPH = False + +try: + import pycallgraph_mod as pycallgraph + HAS_GRAPH = True +except: + pass import sys import unittest @@ -41,6 +48,8 @@ cleanup_dirs = [] class BootTest(unittest.TestCase): def setUp(self): + + # Create temp dir self.topdir = tempfile.mkdtemp(prefix="_cobbler-",dir="/tmp") #self.topdir = "/tmp" # only for refactoring, fix later @@ -66,6 +75,9 @@ class BootTest(unittest.TestCase): shutil.rmtree(self.topdir,ignore_errors=True) self.api = None + if HAS_GRAPH: + pycallgraph.save_dot("%s.dot" % self.__class__.__name__) + def make_basic_config(self): distro = self.api.new_distro() self.assertTrue(distro.set_name("testdistro0")) @@ -331,4 +343,13 @@ if __name__ == "__main__": if not os.path.exists("setup.py"): print "tests: must invoke from top level directory" sys.exit(1) - unittest.main() + if HAS_GRAPH: + pycallgraph.start_trace() + loader = unittest.defaultTestLoader + test_module = __import__("tests") # self import considered harmful? + tests = loader.loadTestsFromModule(test_module) + runner = unittest.TextTestRunner() + runner.run(tests) + if HAS_GRAPH: + pycallgraph.make_graph('test.png') + |