From c499be05ea3454f6b4f5faab46785f68349883eb Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Tue, 27 Nov 2012 21:47:15 -0800 Subject: [PATCH] fix some tests under PyPy In PyPy's pure-Python implementation of the sqlite3 module, sqlite3.Row has no __len__ method. This works around calling len(row). --- test/test_db.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_db.py b/test/test_db.py index dc1d0ce0f..4d451c3f1 100644 --- a/test/test_db.py +++ b/test/test_db.py @@ -654,7 +654,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from items") row = c.fetchone() - self.assertEqual(len(row), len(self.old_fields)) + self.assertEqual(len(row.keys()), len(self.old_fields)) def test_open_with_new_field_adds_column(self): new_lib = beets.library.Library(self.libfile, @@ -662,7 +662,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from items") row = c.fetchone() - self.assertEqual(len(row), len(self.new_fields)) + self.assertEqual(len(row.keys()), len(self.new_fields)) def test_open_with_fewer_fields_leaves_untouched(self): new_lib = beets.library.Library(self.libfile, @@ -670,7 +670,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from items") row = c.fetchone() - self.assertEqual(len(row), len(self.old_fields)) + self.assertEqual(len(row.keys()), len(self.old_fields)) def test_open_with_multiple_new_fields(self): new_lib = beets.library.Library(self.libfile, @@ -678,7 +678,7 @@ class MigrationTest(unittest.TestCase): c = new_lib._connection().cursor() c.execute("select * from items") row = c.fetchone() - self.assertEqual(len(row), len(self.newer_fields)) + self.assertEqual(len(row.keys()), len(self.newer_fields)) def test_open_old_db_adds_album_table(self): conn = sqlite3.connect(self.libfile)