I am beginner in Python, and I am in front of a smal problem. I am using PyQt5 for my IHM. It is a form. I need to fill some combobox with datas in a database.
For the moment, it's in a class name Ui_dialog. I have two questions.
- How can I properly make an unit test on these function? I do not really know how to start my tests sometimes...
- Does I need to use the ressources of my project ( database, xmls... ) or I need to make some specials datas for my test in order cover all possible cases ?
def fill_combobox_from_database(self,name_of_table,name_of_field,combobox):
connexion = sqlite3.connect(os.path.dirname(os.path.abspath(__file__))+"\\"+Ui_dialog.NAME_DB)
cursor = connexion.cursor()
try:
request = "select {0} from {1}".format(name_of_field,name_of_table)
results = cursor.execute(request)
for row in results:
combobox.addItem(row[0])
except Exception as e:
print(e)
Thanks for reading me and for helping me!
Aucun commentaire:
Enregistrer un commentaire