Exemplo n.º 1
0
    def test_03_branch_rate(self):
        with tracing_import('./code/if_true_else', db=self.db) as module:
            pass
        xml = get_stats_xml(db=self.db, whitelist=[re.compile('.*')], blacklist=[])
        tree = etree.XML(xml)

        for i in tree.xpath('//class'):
            branch_rate = i.xpath("./@branch-rate")[0]
        self.assertXMLBranchRate(branch_rate)
Exemplo n.º 2
0
    def test_01_filename(self):
        with tracing_import('./code/if_true_else', db=self.db) as module:
            pass
        xml = get_stats_xml(db=self.db, whitelist=[re.compile('.*')], blacklist=[])
        tree = etree.XML(xml)

        for i in tree.xpath('//class'):
            filename = i.xpath("./@filename")[0]
        self.assertResultFileName(filename)
Exemplo n.º 3
0
 def test_15_if_false_while_some(self):
     with tracing_import('if_false_while_some', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(0, 2))     
Exemplo n.º 4
0
 def test_12_if_true_for_some_ifelse(self):
     with tracing_import('if_true_for_some_ifelse', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(2, 3))
Exemplo n.º 5
0
 def test_45_true_false__function_value_if_value_else(self):
     with tracing_import('function_value_if_value_else', db=self.db) as module: 
         module.function(True); module.function(False)
     self.assertResultBranchRate(Rate(2, 2))
Exemplo n.º 6
0
 def test_41_for_empty_if_true_if_false_not_nested(self):
     with tracing_import('for_empty_if_true_if_false_not_nested', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(1, 3))
Exemplo n.º 7
0
 def test_02_empty_file(self):
     with tracing_import('empty_file', db=self.db) as module:
         pass
     self.assertResultBranchRate(None)        
Exemplo n.º 8
0
 def test_33_for_some_for_some(self):
     with tracing_import('for_some_for_some', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(2, 2))
Exemplo n.º 9
0
 def test_14_if_false_while_some(self):
     with tracing_import('if_false_while_some', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(1, 4))     
Exemplo n.º 10
0
 def test_13_if_true_for_some_ifelse_for_some(self):
     with tracing_import('if_true_for_some_ifelse_for_some', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(3, 5))
Exemplo n.º 11
0
 def test_10_if_true_if_true_else(self):
     with tracing_import('if_true_if_true_else', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(3, 4))  
Exemplo n.º 12
0
 def test_08_if_true_if_false(self):
     with tracing_import('if_true_if_false', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(2, 5))        
Exemplo n.º 13
0
 def test_43_false_fucntion_value_if_value_else(self):
     with tracing_import('function_value_if_value_else', db=self.db) as module: 
         module.function(False)
     self.assertResultLineRate(Rate(3, 4))
Exemplo n.º 14
0
 def test_40_for_empty_if_true_if_false_not_nested(self):
     with tracing_import('for_empty_if_true_if_false_not_nested', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(4, 6))
Exemplo n.º 15
0
 def test_39_for_empty_break_else(self):
     with tracing_import('for_empty_break_else', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(2, 3))
Exemplo n.º 16
0
 def test_28_while_some_while_some(self):
     with tracing_import('while_some_while_some', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(2, 2))
Exemplo n.º 17
0
 def test_31_for_empty(self):
     with tracing_import('for_empty', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(0, 1))
Exemplo n.º 18
0
 def test_15_if_true_while_some_ifelse(self):
     with tracing_import('if_true_while_some_ifelse', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(4, 5))
Exemplo n.º 19
0
 def test_37_for_some_while_false(self):
     with tracing_import('for_some_while_false', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(1, 2))
Exemplo n.º 20
0
 def test_17_if_false_while_false_if_true_while_false(self):
     with tracing_import('if_false_while_false_if_true_while_false', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(3, 6)) 
Exemplo n.º 21
0
 def test_40_for_empty_break_else(self):
     with tracing_import('for_empty_break_else', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(1, 2))
Exemplo n.º 22
0
 def test_18_while_some(self):
     with tracing_import('while_some', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(3, 3))        
Exemplo n.º 23
0
 def test_42_true_true_true_false__function_a_b_if_a_if_b_else(self):
     with tracing_import('function_a_b_if_a_if_b_else', db=self.db) as module:
         module.function(True, True); module.function(True, False)
     self.assertResultBranchRate(Rate(3, 3))
Exemplo n.º 24
0
 def test_01_no_branch(self):
     with tracing_import('no_branch', db=self.db) as module:
         pass
     self.assertResultBranchRate(None)
Exemplo n.º 25
0
 def test_09_if_false_if_true_else(self):
     with tracing_import('if_false_if_true_else', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(0, 3))
Exemplo n.º 26
0
 def test_20_while_false(self):
     with tracing_import('while_false', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(0, 1))          
Exemplo n.º 27
0
 def test_14_if_false_for_some_ifelse_for_some(self):
     with tracing_import('if_false_for_some_ifelse_for_some', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(2, 4))
Exemplo n.º 28
0
 def test_25_while_false_for_some(self):
     with tracing_import('while_false_for_some', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(0, 3))
Exemplo n.º 29
0
 def test_17_if_true_while_false_ifelse(self):
     with tracing_import('if_true_while_false_ifelse', db=self.db) as module:
         pass
     self.assertResultBranchRate(Rate(1, 3))    
Exemplo n.º 30
0
 def test_01_no_branch(self):
     with tracing_import('no_branch', db=self.db) as module:
         pass
     self.assertResultLineRate(Rate(3, 3))