Skip to content

Commit

Permalink
Add test for dict_factory()
Browse files Browse the repository at this point in the history
  • Loading branch information
kristapsk committed Jan 3, 2024
1 parent 2978b18 commit 8f382d0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions test/jmbase/test_base_support.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#! /usr/bin/env python
import pytest
import copy
from jmbase import random_insert
import pytest
import sqlite3

from jmbase import dict_factory, random_insert

def test_color_coded_logging():
# TODO
Expand Down Expand Up @@ -30,3 +32,14 @@ def test_random_insert(list1, list2):
i_x = list1.index(x)
i_y = list1.index(y)
assert i_y > i_x

def test_dict_factory():
con = sqlite3.connect(":memory:")
con.row_factory = dict_factory
db = con.cursor()
db.execute("CREATE TABLE test (one TEXT, two TEXT)")
db.execute("INSERT INTO test VALUES (?, ?)", [ "one", "two" ])
res = db.execute("SELECT * FROM test")
row = res.fetchone()
assert row["one"] == "one"
assert row["two"] == "two"

0 comments on commit 8f382d0

Please sign in to comment.