"DISABLE_GCC_WARNING", "DISABLE_GCC_WARNINGS"}
in_function = False
+ found_openbrace = False
for lineno, line in enumerate(f):
if not in_function:
# find the start of a function
continue
func_start = lineno
in_function = True
-
+ elif not found_openbrace and line.startswith("{"):
+ found_openbrace = True
+ func_start = lineno
else:
# Find the end of a function
if line.startswith("}"):
- n_lines = lineno - func_start
+ n_lines = lineno - func_start + 1
in_function = False
+ found_openbrace = False
yield (func_name, n_lines)
+#!/usr/bin/python
+
"""Some simple tests for practracker metrics"""
import unittest
def test_function_length(self):
funcs = StringIO.StringIO(function_file)
# All functions should have length 2
- for name, lines in metrics.function_lines(funcs):
+ for name, lines in metrics.get_function_lines(funcs):
self.assertEqual(name, "fun")
funcs.seek(0)
- for name, lines in metrics.function_lines(funcs):
- self.assertEqual(lines, 2)
+ for name, lines in metrics.get_function_lines(funcs):
+ self.assertEqual(lines, 4)
if __name__ == '__main__':
unittest.main()