Author: cito
Date: Wed Jan 20 13:22:10 2016
New Revision: 771

Log:
Back port some minor fixes from the trunk

This also gives better error message if test runner does not support unittest2.

Modified:
   branches/4.x/docs/contents/pg/db_wrapper.rst
   branches/4.x/pg.py
   branches/4.x/tests/test_classic_connection.py
   branches/4.x/tests/test_classic_dbwrapper.py

Modified: branches/4.x/docs/contents/pg/db_wrapper.rst
==============================================================================
--- branches/4.x/docs/contents/pg/db_wrapper.rst        Wed Jan 20 13:19:45 
2016        (r770)
+++ branches/4.x/docs/contents/pg/db_wrapper.rst        Wed Jan 20 13:22:10 
2016        (r771)
@@ -144,7 +144,7 @@
     :returns: the current value(s) of the run-time parameter(s)
     :rtype: str, list or dict
     :raises TypeError: Invalid parameter type(s)
-    :raises ProgrammingError: Invalid parameter name(s)
+    :raises pg.ProgrammingError: Invalid parameter name(s)
 
 If the parameter is a string, the return value will also be a string
 that is the current setting of the run-time parameter with that name.
@@ -162,7 +162,7 @@
 
 .. versionadded:: 4.2
 
-.. method:: DB.set_parameter(self, parameter, [value], [local])
+.. method:: DB.set_parameter(parameter, [value], [local])
 
     Set the value of run-time parameters
 
@@ -172,7 +172,7 @@
     :type param: str or None
     :raises TypeError: Invalid parameter type(s)
     :raises ValueError: Invalid value argument(s)
-    :raises ProgrammingError: Invalid parameter name(s) or values
+    :raises pg.ProgrammingError: Invalid parameter name(s) or values
 
 If the parameter and the value are strings, the run-time parameter
 will be set to that value.  If no value or *None* is passed as a value,
@@ -295,7 +295,7 @@
     :param str keyname: name of field to use as key (optional)
     :returns: A dictionary - the keys are the attribute names,
       the values are the row values.
-    :raises ProgrammingError: no primary key or missing privilege
+    :raises pg.ProgrammingError: no primary key or missing privilege
 
 This method is the basic mechanism to get a single row.  It assumes
 that the key specifies a unique row.  If *keyname* is not specified,
@@ -318,7 +318,7 @@
     :param dict d: optional dictionary of values
     :returns: the inserted values in the database
     :rtype: dict
-    :raises ProgrammingError: missing privilege or conflict
+    :raises pg.ProgrammingError: missing privilege or conflict
 
 This method inserts a row into a table.  If the optional dictionary is
 not supplied then the required values must be included as keyword/value
@@ -339,7 +339,7 @@
     :param dict d: optional dictionary of values
     :returns: the new row in the database
     :rtype: dict
-    :raises ProgrammingError: no primary key or missing privilege
+    :raises pg.ProgrammingError: no primary key or missing privilege
 
 Similar to insert but updates an existing row.  The update is based on the
 OID value as munged by :meth:`DB.get` or passed as keyword, or on the primary
@@ -412,7 +412,7 @@
     :param str table: name of table
     :param dict d: optional dictionary of values
     :rtype: None
-    :raises ProgrammingError: table has no primary key,
+    :raises pg.ProgrammingError: table has no primary key,
         row is still referenced or missing privilege
 
 This method deletes the row from a table.  It deletes based on the OID value
@@ -420,10 +420,10 @@
 the table.  The return value is the number of deleted rows (i.e. 0 if the
 row did not exist and 1 if the row was deleted).
 
-truncate -- Quickly empty database tables
+truncate -- quickly empty database tables
 -----------------------------------------
 
-.. method:: DB.truncate(self, table, [restart], [cascade], [only]):
+.. method:: DB.truncate(table, [restart], [cascade], [only])
 
     Empty a table or set of tables
 

Modified: branches/4.x/pg.py
==============================================================================
--- branches/4.x/pg.py  Wed Jan 20 13:19:45 2016        (r770)
+++ branches/4.x/pg.py  Wed Jan 20 13:22:10 2016        (r771)
@@ -1162,7 +1162,7 @@
             q.append('CASCADE')
         q = ' '.join(q)
         self._do_debug(q)
-        return self.query(q)
+        return self.db.query(q)
 
     def notification_handler(self,
             event, callback, arg_dict=None, timeout=None, stop_event=None):

Modified: branches/4.x/tests/test_classic_connection.py
==============================================================================
--- branches/4.x/tests/test_classic_connection.py       Wed Jan 20 13:19:45 
2016        (r770)
+++ branches/4.x/tests/test_classic_connection.py       Wed Jan 20 13:22:10 
2016        (r771)
@@ -662,6 +662,8 @@
 class TestInserttable(unittest.TestCase):
     """Test inserttable method."""
 
+    cls_set_up = False
+
     @classmethod
     def setUpClass(cls):
         c = connect()
@@ -671,6 +673,7 @@
             "d numeric, f4 real, f8 double precision, m money,"
             "c char(1), v4 varchar(4), c4 char(4), t text)")
         c.close()
+        cls.cls_set_up = True
 
     @classmethod
     def tearDownClass(cls):
@@ -679,6 +682,7 @@
         c.close()
 
     def setUp(self):
+        self.assertTrue(self.cls_set_up)
         self.c = connect()
         self.c.query("set lc_monetary='C'")
         self.c.query("set datestyle='ISO,YMD'")
@@ -787,12 +791,15 @@
 class TestDirectSocketAccess(unittest.TestCase):
     """Test copy command with direct socket access."""
 
+    cls_set_up = False
+
     @classmethod
     def setUpClass(cls):
         c = connect()
         c.query("drop table if exists test cascade")
         c.query("create table test (i int, v varchar(16))")
         c.close()
+        cls.cls_set_up = True
 
     @classmethod
     def tearDownClass(cls):
@@ -801,6 +808,7 @@
         c.close()
 
     def setUp(self):
+        self.assertTrue(self.cls_set_up)
         self.c = connect()
         self.c.query("set datestyle='ISO,YMD'")
 

Modified: branches/4.x/tests/test_classic_dbwrapper.py
==============================================================================
--- branches/4.x/tests/test_classic_dbwrapper.py        Wed Jan 20 13:19:45 
2016        (r770)
+++ branches/4.x/tests/test_classic_dbwrapper.py        Wed Jan 20 13:22:10 
2016        (r771)
@@ -277,6 +277,8 @@
 class TestDBClass(unittest.TestCase):
     """Test the methods of the DB class wrapped pg connection."""
 
+    cls_set_up = False
+
     @classmethod
     def setUpClass(cls):
         db = DB()
@@ -288,6 +290,7 @@
         db.query("create or replace view test_view as"
             " select i4, v4 from test")
         db.close()
+        cls.cls_set_up = True
 
     @classmethod
     def tearDownClass(cls):
@@ -296,6 +299,7 @@
         db.close()
 
     def setUp(self):
+        self.assertTrue(self.cls_set_up)
         self.db = DB()
         query = self.db.query
         query('set client_encoding=utf8')
@@ -1568,6 +1572,8 @@
 class TestSchemas(unittest.TestCase):
     """Test correct handling of schemas (namespaces)."""
 
+    cls_set_up = False
+
     @classmethod
     def setUpClass(cls):
         db = DB()
@@ -1591,6 +1597,7 @@
             query("create table %s.t%d with oids as select 1 as n, %d as d"
                   % (schema, num_schema, num_schema))
         db.close()
+        cls.cls_set_up = True
 
     @classmethod
     def tearDownClass(cls):
@@ -1607,6 +1614,7 @@
         db.close()
 
     def setUp(self):
+        self.assertTrue(self.cls_set_up)
         self.db = DB()
 
     def tearDown(self):
_______________________________________________
PyGreSQL mailing list
[email protected]
https://mail.vex.net/mailman/listinfo.cgi/pygresql

Reply via email to