Beispiel #1
0
def test_get_code_line(session, filename, line_number, function, code):
    code_line1 = get_code_line(session, filename, line_number, function, code)
    code_line2 = get_code_line(session, filename, line_number, function, code)
    assert code_line1.id == code_line2.id
    assert code_line1.function_name == code_line2.function_name
    assert code_line1.filename == code_line2.filename
    assert code_line1.line_number == code_line2.line_number
    assert code_line1.code == code_line2.code
Beispiel #2
0
 def test_get_code_line(self):
     with session_scope() as db_session:
         code_line1 = get_code_line(db_session, FN, LN, FUN, CODE)
         code_line2 = get_code_line(db_session, FN, LN, FUN, CODE)
         self.assertEqual(code_line1.id, code_line2.id)
         self.assertEqual(code_line1.function_name, code_line2.function_name)
         self.assertEqual(code_line1.filename, code_line2.filename)
         self.assertEqual(code_line1.line_number, code_line2.line_number)
         self.assertEqual(code_line1.code, code_line2.code)
Beispiel #3
0
def add_stack_line(db_session, request_id, position, indent, duration,
                   code_line):
    """
    Adds a StackLine to the database (and possibly a CodeLine)
    :param db_session: Session for the database
    :param request_id: id of the request
    :param position: position of the StackLine
    :param indent: indent-value
    :param duration: duration of this line (in ms)
    :param code_line: quadruple that consists of: (filename, line_number, function_name, code)
    """
    fn, ln, name, code = code_line
    db_code_line = get_code_line(db_session, fn, ln, name, code)
    db_session.add(
        StackLine(request_id=request_id,
                  position=position,
                  indent=indent,
                  code_id=db_code_line.id,
                  duration=duration))