diff options
author | Gerhard Häring <gh@ghaering.de> | 2008-05-04 13:15:12 (GMT) |
---|---|---|
committer | Gerhard Häring <gh@ghaering.de> | 2008-05-04 13:15:12 (GMT) |
commit | 5a366c3b8bf1e8afb2d48a02b498f2eaab812c49 (patch) | |
tree | 39166c3187d413d0e11378568b35dc0e430c8981 /Lib | |
parent | ffa3357d5227ff746ba243fa5cd720f397ac7bec (diff) | |
download | cpython-5a366c3b8bf1e8afb2d48a02b498f2eaab812c49.zip cpython-5a366c3b8bf1e8afb2d48a02b498f2eaab812c49.tar.gz cpython-5a366c3b8bf1e8afb2d48a02b498f2eaab812c49.tar.bz2 |
Applied sqliterow-richcmp.diff patch from Thomas Heller in Issue2152. The
sqlite3.Row type is now correctly hashable.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/sqlite3/test/factory.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/sqlite3/test/factory.py b/Lib/sqlite3/test/factory.py index 9469d79..ff41a9d 100644 --- a/Lib/sqlite3/test/factory.py +++ b/Lib/sqlite3/test/factory.py @@ -131,6 +131,26 @@ class RowFactoryTests(unittest.TestCase): self.failUnlessEqual(d["a"], row["a"]) self.failUnlessEqual(d["b"], row["b"]) + def CheckSqliteRowHashCmp(self): + """Checks if the row object compares and hashes correctly""" + self.con.row_factory = sqlite.Row + row_1 = self.con.execute("select 1 as a, 2 as b").fetchone() + row_2 = self.con.execute("select 1 as a, 2 as b").fetchone() + row_3 = self.con.execute("select 1 as a, 3 as b").fetchone() + + self.failUnless(row_1 == row_1) + self.failUnless(row_1 == row_2) + self.failUnless(row_2 != row_3) + + self.failIf(row_1 != row_1) + self.failIf(row_1 != row_2) + self.failIf(row_2 == row_3) + + self.failUnlessEqual(row_1, row_2) + self.failUnlessEqual(hash(row_1), hash(row_2)) + self.failIfEqual(row_1, row_3) + self.failIfEqual(hash(row_1), hash(row_3)) + def tearDown(self): self.con.close() |