mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-23 01:16:34 +03:00
Test methods reordered to improve readability
This commit is contained in:
parent
dca6cffd6e
commit
71d1690870
|
@ -35,6 +35,7 @@ class ExtrasDictCursorTests(unittest.TestCase):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.conn.close()
|
self.conn.close()
|
||||||
|
|
||||||
|
|
||||||
def testDictCursorWithPlainCursorFetchOne(self):
|
def testDictCursorWithPlainCursorFetchOne(self):
|
||||||
self._testWithPlainCursor(lambda curs: curs.fetchone())
|
self._testWithPlainCursor(lambda curs: curs.fetchone())
|
||||||
|
|
||||||
|
@ -53,6 +54,21 @@ class ExtrasDictCursorTests(unittest.TestCase):
|
||||||
return row
|
return row
|
||||||
self._testWithPlainCursor(getter)
|
self._testWithPlainCursor(getter)
|
||||||
|
|
||||||
|
def testUpdateRow(self):
|
||||||
|
row = self._testWithPlainCursor(lambda curs: curs.fetchone())
|
||||||
|
row['foo'] = 'qux'
|
||||||
|
self.failUnless(row['foo'] == 'qux')
|
||||||
|
self.failUnless(row[0] == 'qux')
|
||||||
|
|
||||||
|
def _testWithPlainCursor(self, getter):
|
||||||
|
curs = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
||||||
|
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
||||||
|
row = getter(curs)
|
||||||
|
self.failUnless(row['foo'] == 'bar')
|
||||||
|
self.failUnless(row[0] == 'bar')
|
||||||
|
return row
|
||||||
|
|
||||||
|
|
||||||
def testDictCursorWithPlainCursorRealFetchOne(self):
|
def testDictCursorWithPlainCursorRealFetchOne(self):
|
||||||
self._testWithPlainCursorReal(lambda curs: curs.fetchone())
|
self._testWithPlainCursorReal(lambda curs: curs.fetchone())
|
||||||
|
|
||||||
|
@ -71,6 +87,12 @@ class ExtrasDictCursorTests(unittest.TestCase):
|
||||||
return row
|
return row
|
||||||
self._testWithPlainCursorReal(getter)
|
self._testWithPlainCursorReal(getter)
|
||||||
|
|
||||||
|
def _testWithPlainCursorReal(self, getter):
|
||||||
|
curs = self.conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
|
||||||
|
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
||||||
|
row = getter(curs)
|
||||||
|
self.failUnless(row['foo'] == 'bar')
|
||||||
|
|
||||||
|
|
||||||
def testDictCursorWithNamedCursorFetchOne(self):
|
def testDictCursorWithNamedCursorFetchOne(self):
|
||||||
self._testWithNamedCursor(lambda curs: curs.fetchone())
|
self._testWithNamedCursor(lambda curs: curs.fetchone())
|
||||||
|
@ -95,6 +117,13 @@ class ExtrasDictCursorTests(unittest.TestCase):
|
||||||
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.DictCursor)
|
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.DictCursor)
|
||||||
self._testNamedCursorNotGreedy(curs)
|
self._testNamedCursorNotGreedy(curs)
|
||||||
|
|
||||||
|
def _testWithNamedCursor(self, getter):
|
||||||
|
curs = self.conn.cursor('aname', cursor_factory=psycopg2.extras.DictCursor)
|
||||||
|
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
||||||
|
row = getter(curs)
|
||||||
|
self.failUnless(row['foo'] == 'bar')
|
||||||
|
self.failUnless(row[0] == 'bar')
|
||||||
|
|
||||||
|
|
||||||
def testDictCursorRealWithNamedCursorFetchOne(self):
|
def testDictCursorRealWithNamedCursorFetchOne(self):
|
||||||
self._testWithNamedCursorReal(lambda curs: curs.fetchone())
|
self._testWithNamedCursorReal(lambda curs: curs.fetchone())
|
||||||
|
@ -119,39 +148,12 @@ class ExtrasDictCursorTests(unittest.TestCase):
|
||||||
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.RealDictCursor)
|
curs = self.conn.cursor('tmp', cursor_factory=psycopg2.extras.RealDictCursor)
|
||||||
self._testNamedCursorNotGreedy(curs)
|
self._testNamedCursorNotGreedy(curs)
|
||||||
|
|
||||||
|
|
||||||
def _testWithPlainCursor(self, getter):
|
|
||||||
curs = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
|
||||||
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
|
||||||
row = getter(curs)
|
|
||||||
self.failUnless(row['foo'] == 'bar')
|
|
||||||
self.failUnless(row[0] == 'bar')
|
|
||||||
return row
|
|
||||||
|
|
||||||
def _testWithNamedCursor(self, getter):
|
|
||||||
curs = self.conn.cursor('aname', cursor_factory=psycopg2.extras.DictCursor)
|
|
||||||
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
|
||||||
row = getter(curs)
|
|
||||||
self.failUnless(row['foo'] == 'bar')
|
|
||||||
self.failUnless(row[0] == 'bar')
|
|
||||||
|
|
||||||
def _testWithPlainCursorReal(self, getter):
|
|
||||||
curs = self.conn.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
|
|
||||||
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
|
||||||
row = getter(curs)
|
|
||||||
self.failUnless(row['foo'] == 'bar')
|
|
||||||
|
|
||||||
def _testWithNamedCursorReal(self, getter):
|
def _testWithNamedCursorReal(self, getter):
|
||||||
curs = self.conn.cursor('aname', cursor_factory=psycopg2.extras.RealDictCursor)
|
curs = self.conn.cursor('aname', cursor_factory=psycopg2.extras.RealDictCursor)
|
||||||
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
curs.execute("SELECT * FROM ExtrasDictCursorTests")
|
||||||
row = getter(curs)
|
row = getter(curs)
|
||||||
self.failUnless(row['foo'] == 'bar')
|
self.failUnless(row['foo'] == 'bar')
|
||||||
|
|
||||||
def testUpdateRow(self):
|
|
||||||
row = self._testWithPlainCursor(lambda curs: curs.fetchone())
|
|
||||||
row['foo'] = 'qux'
|
|
||||||
self.failUnless(row['foo'] == 'qux')
|
|
||||||
self.failUnless(row[0] == 'qux')
|
|
||||||
|
|
||||||
def _testNamedCursorNotGreedy(self, curs):
|
def _testNamedCursorNotGreedy(self, curs):
|
||||||
curs.itersize = 2
|
curs.itersize = 2
|
||||||
|
|
Loading…
Reference in New Issue
Block a user