diff test/test_postgresql.py @ 5036:380d8d8b30a3

Replace existing run_tests.py script with a pytest script The existing run_test.py script is quite old, a bit restrictive, and doesn't always behave as documented. The pytest testing tool is mature, well documented, and maintained. The run_tests.py script is generating by installing py.test and running: py.tests --genscript=run_tests.py Note: to generate a script that is compatible with python2.6 the command needs to be run using python2.6
author John Kristensen <john@jerrykan.com>
date Thu, 20 Aug 2015 18:15:23 +1000
parents 63c79c0992ae
children 364c54991861
line wrap: on
line diff
--- a/test/test_postgresql.py	Fri Aug 21 17:37:22 2015 +1000
+++ b/test/test_postgresql.py	Thu Aug 20 18:15:23 2015 +1000
@@ -17,6 +17,7 @@
 
 import unittest
 
+import pytest
 from roundup.hyperdb import DatabaseError
 
 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest
@@ -25,6 +26,15 @@
 
 from roundup.backends import get_backend, have_backend
 
+if not have_backend('postgresql'):
+    SKIP_POSTGRESQL = True
+else:
+    SKIP_POSTGRESQL = False
+
+skip_postgresql = pytest.mark.skipif(
+    SKIP_POSTGRESQL, reason='Skipping PostgreSQL tests: not enabled')
+
+
 class postgresqlOpener:
     if have_backend('postgresql'):
         module = get_backend('postgresql')
@@ -40,6 +50,7 @@
         self.module.db_nuke(config)
 
 
+@skip_postgresql
 class postgresqlDBTest(postgresqlOpener, DBTest, unittest.TestCase):
     def setUp(self):
         postgresqlOpener.setUp(self)
@@ -50,6 +61,7 @@
         postgresqlOpener.tearDown(self)
 
 
+@skip_postgresql
 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase):
     def setUp(self):
         postgresqlOpener.setUp(self)
@@ -60,6 +72,7 @@
         postgresqlOpener.tearDown(self)
 
 
+@skip_postgresql
 class postgresqlConcurrencyTest(postgresqlOpener, ConcurrentDBTest,
                                 unittest.TestCase):
     backend = 'postgresql'
@@ -72,6 +85,7 @@
         postgresqlOpener.tearDown(self)
 
 
+@skip_postgresql
 class postgresqlJournalTest(postgresqlOpener, ClassicInitBase,
                             unittest.TestCase):
     backend = 'postgresql'
@@ -122,6 +136,7 @@
         self.assertRaises(exc, self._test_journal, [])
 
 
+@skip_postgresql
 class postgresqlHTMLItemTest(postgresqlOpener, HTMLItemTest,
                              unittest.TestCase):
     backend = 'postgresql'
@@ -134,6 +149,7 @@
         postgresqlOpener.tearDown(self)
 
 
+@skip_postgresql
 class postgresqlFilterCacheTest(postgresqlOpener, FilterCacheTest,
                                 unittest.TestCase):
     backend = 'postgresql'
@@ -146,6 +162,7 @@
         postgresqlOpener.tearDown(self)
 
 
+@skip_postgresql
 class postgresqlSchemaTest(postgresqlOpener, SchemaTest, unittest.TestCase):
     def setUp(self):
         postgresqlOpener.setUp(self)
@@ -156,6 +173,7 @@
         postgresqlOpener.tearDown(self)
 
 
+@skip_postgresql
 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest,
                                 unittest.TestCase):
     backend = 'postgresql'
@@ -169,6 +187,7 @@
 
 
 from session_common import RDBMSTest
+@skip_postgresql
 class postgresqlSessionTest(postgresqlOpener, RDBMSTest, unittest.TestCase):
     def setUp(self):
         postgresqlOpener.setUp(self)

Roundup Issue Tracker: http://roundup-tracker.org/