python - input value for LIMIT(unitest) -


i'm confused on one. limit default none, if test in unitest , ask specific number of comments type mismatch. know "int" not correct term. i'm saying limit should integer. proper way of addressing input depending on limit in unitest.

def list_comments(db, limit=none): limit = "int"     limit = "int"      cur = db.cursor()     cur.execute("select id, comment comments order id desc limit ?", (limit,))     results = cur.fetchall()      print results      return results 

remove limit = "int" behind function, , make limit parameter default 0 , use placeholder %s;

def list_comments(db, limit=0):     cur = db.cursor()     cur.execute("select id, comment comments order id desc limit %s", (str(limit)))     results = cur.fetchall()      print results      return results 

also remove comma if it's not needed yet; (limit,).

i've parsed limit value string on purpose (you can check if it's integer) let match %s placeholder.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -