Exemple #1
0
def test_raw_to_dict():
    assert tools.raw_to_dict(Module(103, 123, 98, 8, 19, 5, 3)) == {
        'loc': 103,
        'lloc': 123,
        'sloc': 98,
        'comments': 8,
        'multi': 19,
        'blank': 5,
        'single_comments': 3,
    }
Exemple #2
0
 def test_raw_to_dict(self):
     self.assertEqual(
         tools.raw_to_dict(Module(103, 123, 98, 8, 19, 5)), {
             'loc': 103,
             'lloc': 123,
             'sloc': 98,
             'comments': 8,
             'multi': 19,
             'blank': 5
         })
Exemple #3
0
    def get_raw_metrics(self, node):
        # astunparse.unparse() parses triple quote strings
        # a single quote strings.  A single quote string is
        # interpreted as a sloc instead of a multi.
        # source_segement = unparse(node)

        source_segment = get_source_segment(self.code, node)
        raw_metrics = analyze(source_segment)
        raw_metrics_dict = raw_to_dict(raw_metrics)
        self.loc = raw_metrics_dict["loc"]
        self.lloc = raw_metrics_dict["lloc"]
        self.sloc = raw_metrics_dict["sloc"]
        self.comments = raw_metrics_dict["comments"]
        self.multi = raw_metrics_dict["multi"]
        self.blank = raw_metrics_dict["blank"]
        self.single_comments = raw_metrics_dict["single_comments"]
Exemple #4
0
 def gobble(self, fobj):
     '''Analyze the content of the file object.'''
     return raw_to_dict(analyze(fobj.read()))
Exemple #5
0
 def gobble(self, fobj):
     '''Analyze the content of the file object.'''
     return raw_to_dict(analyze(fobj.read()))
 def test_raw_to_dict(self):
     self.assertEqual(tools.raw_to_dict(Module(103, 123, 98, 8, 19, 5, 3)),
                      {'loc': 103, 'lloc': 123, 'sloc': 98, 'comments': 8,
                          'multi': 19, 'blank': 5, 'single_comments': 3})
Exemple #7
0
def test_raw_to_dict():
    assert tools.raw_to_dict(Module(103, 123, 98, 8, 19, 5, 3)) == \
         {'loc': 103, 'lloc': 123, 'sloc': 98, 'comments': 8,
             'multi': 19, 'blank': 5, 'single_comments': 3}