Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
sqlite3.test.factory.RowFactoryTests Class Reference

List of all members.

Public Member Functions

def setUp
def CheckCustomFactory
def CheckSqliteRowIndex
def CheckSqliteRowIter
def CheckSqliteRowAsTuple
def CheckSqliteRowAsDict
def CheckSqliteRowHashCmp
def tearDown

Public Attributes

 con

Detailed Description

Definition at line 83 of file factory.py.


Member Function Documentation

Definition at line 87 of file factory.py.

00087 
00088     def CheckCustomFactory(self):
00089         self.con.row_factory = lambda cur, row: list(row)
00090         row = self.con.execute("select 1, 2").fetchone()
00091         self.assertTrue(isinstance(row,
00092                                    list),
00093                         "row is not instance of list")

Here is the call graph for this function:

Checks if the row object can be correctly converted to a dictionary

Definition at line 126 of file factory.py.

00126 
00127     def CheckSqliteRowAsDict(self):
00128         """Checks if the row object can be correctly converted to a dictionary"""
00129         self.con.row_factory = sqlite.Row
00130         row = self.con.execute("select 1 as a, 2 as b").fetchone()
00131         d = dict(row)
00132         self.assertEqual(d["a"], row["a"])
00133         self.assertEqual(d["b"], row["b"])

Here is the call graph for this function:

Checks if the row object can be converted to a tuple

Definition at line 120 of file factory.py.

00120 
00121     def CheckSqliteRowAsTuple(self):
00122         """Checks if the row object can be converted to a tuple"""
00123         self.con.row_factory = sqlite.Row
00124         row = self.con.execute("select 1 as a, 2 as b").fetchone()
00125         t = tuple(row)

Checks if the row object compares and hashes correctly

Definition at line 134 of file factory.py.

00134 
00135     def CheckSqliteRowHashCmp(self):
00136         """Checks if the row object compares and hashes correctly"""
00137         self.con.row_factory = sqlite.Row
00138         row_1 = self.con.execute("select 1 as a, 2 as b").fetchone()
00139         row_2 = self.con.execute("select 1 as a, 2 as b").fetchone()
00140         row_3 = self.con.execute("select 1 as a, 3 as b").fetchone()
00141 
00142         self.assertTrue(row_1 == row_1)
00143         self.assertTrue(row_1 == row_2)
00144         self.assertTrue(row_2 != row_3)
00145 
00146         self.assertFalse(row_1 != row_1)
00147         self.assertFalse(row_1 != row_2)
00148         self.assertFalse(row_2 == row_3)
00149 
00150         self.assertEqual(row_1, row_2)
00151         self.assertEqual(hash(row_1), hash(row_2))
00152         self.assertNotEqual(row_1, row_3)
00153         self.assertNotEqual(hash(row_1), hash(row_3))

Here is the call graph for this function:

Definition at line 94 of file factory.py.

00094 
00095     def CheckSqliteRowIndex(self):
00096         self.con.row_factory = sqlite.Row
00097         row = self.con.execute("select 1 as a, 2 as b").fetchone()
00098         self.assertTrue(isinstance(row,
00099                                    sqlite.Row),
00100                         "row is not instance of sqlite.Row")
00101 
00102         col1, col2 = row["a"], row["b"]
00103         self.assertTrue(col1 == 1, "by name: wrong result for column 'a'")
00104         self.assertTrue(col2 == 2, "by name: wrong result for column 'a'")
00105 
00106         col1, col2 = row["A"], row["B"]
00107         self.assertTrue(col1 == 1, "by name: wrong result for column 'A'")
00108         self.assertTrue(col2 == 2, "by name: wrong result for column 'B'")
00109 
00110         col1, col2 = row[0], row[1]
00111         self.assertTrue(col1 == 1, "by index: wrong result for column 0")
00112         self.assertTrue(col2 == 2, "by index: wrong result for column 1")

Here is the call graph for this function:

Checks if the row object is iterable

Definition at line 113 of file factory.py.

00113 
00114     def CheckSqliteRowIter(self):
00115         """Checks if the row object is iterable"""
00116         self.con.row_factory = sqlite.Row
00117         row = self.con.execute("select 1 as a, 2 as b").fetchone()
00118         for col in row:
00119             pass

Definition at line 84 of file factory.py.

00084 
00085     def setUp(self):
00086         self.con = sqlite.connect(":memory:")

Here is the caller graph for this function:

Definition at line 154 of file factory.py.

00154 
00155     def tearDown(self):
00156         self.con.close()

Here is the caller graph for this function:


Member Data Documentation

Definition at line 85 of file factory.py.


The documentation for this class was generated from the following file: