def startTest(self, test): """ Run at the beginning of each test, before per-test fixtures. One weakness is that this is only run for specific kinds of nose testcases. """ if isinstance(test, nose.case.Test): self.testname = calc_testname(test) assert self.testname figleaf.start_section(self.testname)
def test(): figleaf.start() common() figleaf.start_section('a') a() figleaf.stop_section() common2() figleaf.start_section('b') b() figleaf.start_section('c') c() figleaf.stop() in_common = set() union = set() expected = dict(a = set([17, 18, 11, 14]), b = set([22, 11, 21, 14]), c = set([25, 26, 11, 14])) for i in ('a', 'b', 'c'): actual = figleaf.get_info(section_name=i).get(thisfile()) print '******', thisfile() print 'section:', i, '; lines:', actual print expected[i] x = list(expected[i]) x.sort() y = list(actual) y.sort() print x, y assert x == y # note: depends on absolute line no. # so don't shift lines in this file ;) if not in_common: in_common.update(actual) else: in_common.intersection_update(actual) union.update(actual) in_common = list(in_common) in_common.sort() print 'common:', in_common assert in_common == [11, 14] union = list(union) union.sort() print 'union:', union assert union == [11, 14, 17, 18, 21, 22, 25, 26]
import figleaf figleaf.start() def a(): print 'this is a' def b(): print 'this is b' def c(): print 'this is c' figleaf.start_section('foo') a() figleaf.start_section('bar') b() figleaf.stop_section() c() figleaf.stop() figleaf.dump_pickled_coverage(open('.figleaf_sections', 'wb'))
def pytest_runtest_setup(item): """ Notify figleaf that a new testcase/section is about to start. """ figleaf.start_section(item.nodeid)
def test(): figleaf.start() common() figleaf.start_section('a') a() figleaf.stop_section() common2() figleaf.start_section('b') b() figleaf.start_section('c') c() figleaf.stop() in_common = set() union = set() expected = dict(a = set([17, 18, 11, 14]), b = set([11, 14, 21, 22]), c = set([11, 14, 25, 26])) expected_in_common = [11, 14] expected_union = [11, 14, 17, 18, 21, 22, 25, 26] if figleaf.internals.PythonCollector is not figleaf.internals.Collector: expected['a'].update([40, 42, 43, 44, 45, 47]) expected['b'].update([40, 42, 45, 47, 48, 49]) expected['c'].update([40, 42, 45, 47, 50, 51]) expected_in_common += [40, 42, 45, 47] expected_union += [40, 42, 43, 44, 45, 47, 48, 49, 50, 51] for i in ('a', 'b', 'c'): actual = figleaf.get_info(section_name=i).get(thisfile()) print '******', thisfile() print 'section:', i, '; lines:', actual print expected[i] x = list(expected[i]) x.sort() y = list(actual) y.sort() print x, y assert x == y # note: depends on absolute line no. # so don't shift lines in this file ;) if not in_common: in_common.update(actual) else: in_common.intersection_update(actual) union.update(actual) in_common = list(in_common) in_common.sort() print 'common:', in_common assert in_common == expected_in_common union = list(union) union.sort() print 'union:', union assert union == expected_union