Looks good, pushed.
On 07.08.2013 17:53, Martin Milata wrote:
Signed-off-by: Martin Milata mmilata@redhat.com
.gitignore | 1 + tests/python/gdb.py | 15 +++------------ tests/python/java.py | 12 ++---------- tests/python/koops.py | 7 +------ tests/python/metrics.py | 8 +------- tests/python/python.py | 13 ++----------- tests/python/test_helpers.py | 11 +++++++++++ 7 files changed, 21 insertions(+), 46 deletions(-)
diff --git a/.gitignore b/.gitignore index ae69aa9..cbcf307 100644 --- a/.gitignore +++ b/.gitignore @@ -51,3 +51,4 @@ satyr.1 /tests/testsuite /tests/testsuite.log /tests/testsuite.dir +/tests/python/test_helpers.pyc diff --git a/tests/python/gdb.py b/tests/python/gdb.py index fdc61a6..f271fe0 100755 --- a/tests/python/gdb.py +++ b/tests/python/gdb.py @@ -1,13 +1,7 @@ #!/usr/bin/env python
import unittest -from test_helpers import BindingsTestCase, load_input_contents
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
contents = load_input_contents('../gdb_stacktraces/rhbz-803600') threads_expected = 2 @@ -24,14 +18,11 @@ class TestGdbStacktrace(BindingsTestCase): def setUp(self): self.trace = satyr.GdbStacktrace(contents)
def frame_count(self, trace):
return sum(map(lambda x: len(x.frames), trace.threads))
def test_correct_thread_count(self): self.assertEqual(len(self.trace.threads), threads_expected) def test_correct_frame_count(self):
self.assertEqual(self.frame_count(self.trace), frames_expected)
self.assertEqual(frame_count(self.trace), frames_expected) def test_dup(self): dup = self.trace.dup()
@@ -52,7 +43,7 @@ class TestGdbStacktrace(BindingsTestCase): def test_normalize(self): dup = self.trace.dup() dup.normalize()
self.assertNotEqual(self.frame_count(dup), self.frame_count(self.trace))
self.assertNotEqual(frame_count(dup), frame_count(self.trace)) def test_str(self): out = str(self.trace)
diff --git a/tests/python/java.py b/tests/python/java.py index eaa3d48..0bed791 100755 --- a/tests/python/java.py +++ b/tests/python/java.py @@ -1,12 +1,7 @@ #!/usr/bin/env python
import unittest -from test_helpers import BindingsTestCase, load_input_contents
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
contents = load_input_contents('../java_stacktraces/java-02') threads_expected = 1 @@ -25,14 +20,11 @@ class TestJavaStacktrace(BindingsTestCase): def setUp(self): self.trace = satyr.JavaStacktrace(contents)
def frame_count(self, trace):
return sum(map(lambda x: len(x.frames), trace.threads))
def test_correct_thread_count(self): self.assertEqual(len(self.trace.threads), threads_expected) def test_correct_frame_count(self):
self.assertEqual(self.frame_count(self.trace), frames_expected)
self.assertEqual(frame_count(self.trace), frames_expected) def test_dup(self): dup = self.trace.dup()
diff --git a/tests/python/koops.py b/tests/python/koops.py index 4922c61..241ad21 100755 --- a/tests/python/koops.py +++ b/tests/python/koops.py @@ -1,12 +1,7 @@ #!/usr/bin/env python
import unittest -from test_helpers import BindingsTestCase, load_input_contents
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
contents = load_input_contents('../kerneloopses/rhbz-827868') frames_expected = 32 diff --git a/tests/python/metrics.py b/tests/python/metrics.py index ea79d10..1230ef6 100755 --- a/tests/python/metrics.py +++ b/tests/python/metrics.py @@ -1,13 +1,7 @@ #!/usr/bin/env python
import unittest
-from test_helpers import load_input_contents
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
class TestDistances(unittest.TestCase): def setUp(self): diff --git a/tests/python/python.py b/tests/python/python.py index 1fcd49d..9529536 100755 --- a/tests/python/python.py +++ b/tests/python/python.py @@ -1,13 +1,7 @@ #!/usr/bin/env python
import unittest
-from test_helpers import BindingsTestCase, load_input_contents
-try:
- import _satyr as satyr
-except ImportError:
- import satyr
+from test_helpers import *
path = '../python_stacktraces/python-01' contents = load_input_contents(path) @@ -24,11 +18,8 @@ class TestPythonStacktrace(BindingsTestCase): def setUp(self): self.trace = satyr.PythonStacktrace(contents)
- def frame_count(self, trace):
return len(trace.frames)
def test_correct_frame_count(self):
self.assertEqual(self.frame_count(self.trace), frames_expected)
self.assertEqual(frame_count(self.trace), frames_expected) def test_dup(self): dup = self.trace.dup()
diff --git a/tests/python/test_helpers.py b/tests/python/test_helpers.py index ba023a0..d99b53a 100644 --- a/tests/python/test_helpers.py +++ b/tests/python/test_helpers.py @@ -1,6 +1,11 @@ import os import unittest
+try:
- import _satyr as satyr
+except ImportError:
- import satyr
- class BindingsTestCase(unittest.TestCase): def assertGetSetCorrect(self, obj, attr, orig_val, new_val): '''
@@ -18,6 +23,12 @@ def load_input_contents(path): with file(path) as f: return f.read()
+def frame_count(trace):
- if hasattr(trace, 'frames'):
return len(trace.frames)
- else:
return sum(map(lambda x: len(x.frames), trace.threads))
- if __name__ == '__main__': import sys sys.exit('This module is not meant to be run directly')