Mercurial > p > roundup > code
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 5035:b5bb492e4b3c | 5036:380d8d8b30a3 |
|---|---|
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 | 17 |
| 18 import unittest | 18 import unittest |
| 19 | 19 |
| 20 import pytest | |
| 20 from roundup.hyperdb import DatabaseError | 21 from roundup.hyperdb import DatabaseError |
| 21 | 22 |
| 22 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest | 23 from db_test_base import DBTest, ROTest, config, SchemaTest, ClassicInitTest |
| 23 from db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest | 24 from db_test_base import ConcurrentDBTest, HTMLItemTest, FilterCacheTest |
| 24 from db_test_base import ClassicInitBase, setupTracker | 25 from db_test_base import ClassicInitBase, setupTracker |
| 25 | 26 |
| 26 from roundup.backends import get_backend, have_backend | 27 from roundup.backends import get_backend, have_backend |
| 27 | 28 |
| 29 if not have_backend('postgresql'): | |
| 30 SKIP_POSTGRESQL = True | |
| 31 else: | |
| 32 SKIP_POSTGRESQL = False | |
| 33 | |
| 34 skip_postgresql = pytest.mark.skipif( | |
| 35 SKIP_POSTGRESQL, reason='Skipping PostgreSQL tests: not enabled') | |
| 36 | |
| 37 | |
| 28 class postgresqlOpener: | 38 class postgresqlOpener: |
| 29 if have_backend('postgresql'): | 39 if have_backend('postgresql'): |
| 30 module = get_backend('postgresql') | 40 module = get_backend('postgresql') |
| 31 | 41 |
| 32 def setUp(self): | 42 def setUp(self): |
| 38 def nuke_database(self): | 48 def nuke_database(self): |
| 39 # clear out the database - easiest way is to nuke and re-create it | 49 # clear out the database - easiest way is to nuke and re-create it |
| 40 self.module.db_nuke(config) | 50 self.module.db_nuke(config) |
| 41 | 51 |
| 42 | 52 |
| 53 @skip_postgresql | |
| 43 class postgresqlDBTest(postgresqlOpener, DBTest, unittest.TestCase): | 54 class postgresqlDBTest(postgresqlOpener, DBTest, unittest.TestCase): |
| 44 def setUp(self): | 55 def setUp(self): |
| 45 postgresqlOpener.setUp(self) | 56 postgresqlOpener.setUp(self) |
| 46 DBTest.setUp(self) | 57 DBTest.setUp(self) |
| 47 | 58 |
| 48 def tearDown(self): | 59 def tearDown(self): |
| 49 DBTest.tearDown(self) | 60 DBTest.tearDown(self) |
| 50 postgresqlOpener.tearDown(self) | 61 postgresqlOpener.tearDown(self) |
| 51 | 62 |
| 52 | 63 |
| 64 @skip_postgresql | |
| 53 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase): | 65 class postgresqlROTest(postgresqlOpener, ROTest, unittest.TestCase): |
| 54 def setUp(self): | 66 def setUp(self): |
| 55 postgresqlOpener.setUp(self) | 67 postgresqlOpener.setUp(self) |
| 56 ROTest.setUp(self) | 68 ROTest.setUp(self) |
| 57 | 69 |
| 58 def tearDown(self): | 70 def tearDown(self): |
| 59 ROTest.tearDown(self) | 71 ROTest.tearDown(self) |
| 60 postgresqlOpener.tearDown(self) | 72 postgresqlOpener.tearDown(self) |
| 61 | 73 |
| 62 | 74 |
| 75 @skip_postgresql | |
| 63 class postgresqlConcurrencyTest(postgresqlOpener, ConcurrentDBTest, | 76 class postgresqlConcurrencyTest(postgresqlOpener, ConcurrentDBTest, |
| 64 unittest.TestCase): | 77 unittest.TestCase): |
| 65 backend = 'postgresql' | 78 backend = 'postgresql' |
| 66 def setUp(self): | 79 def setUp(self): |
| 67 postgresqlOpener.setUp(self) | 80 postgresqlOpener.setUp(self) |
| 70 def tearDown(self): | 83 def tearDown(self): |
| 71 ConcurrentDBTest.tearDown(self) | 84 ConcurrentDBTest.tearDown(self) |
| 72 postgresqlOpener.tearDown(self) | 85 postgresqlOpener.tearDown(self) |
| 73 | 86 |
| 74 | 87 |
| 88 @skip_postgresql | |
| 75 class postgresqlJournalTest(postgresqlOpener, ClassicInitBase, | 89 class postgresqlJournalTest(postgresqlOpener, ClassicInitBase, |
| 76 unittest.TestCase): | 90 unittest.TestCase): |
| 77 backend = 'postgresql' | 91 backend = 'postgresql' |
| 78 def setUp(self): | 92 def setUp(self): |
| 79 postgresqlOpener.setUp(self) | 93 postgresqlOpener.setUp(self) |
| 120 self.tracker.config.RDBMS_ISOLATION_LEVEL='repeatable read' | 134 self.tracker.config.RDBMS_ISOLATION_LEVEL='repeatable read' |
| 121 exc = self.module.TransactionRollbackError | 135 exc = self.module.TransactionRollbackError |
| 122 self.assertRaises(exc, self._test_journal, []) | 136 self.assertRaises(exc, self._test_journal, []) |
| 123 | 137 |
| 124 | 138 |
| 139 @skip_postgresql | |
| 125 class postgresqlHTMLItemTest(postgresqlOpener, HTMLItemTest, | 140 class postgresqlHTMLItemTest(postgresqlOpener, HTMLItemTest, |
| 126 unittest.TestCase): | 141 unittest.TestCase): |
| 127 backend = 'postgresql' | 142 backend = 'postgresql' |
| 128 def setUp(self): | 143 def setUp(self): |
| 129 postgresqlOpener.setUp(self) | 144 postgresqlOpener.setUp(self) |
| 132 def tearDown(self): | 147 def tearDown(self): |
| 133 HTMLItemTest.tearDown(self) | 148 HTMLItemTest.tearDown(self) |
| 134 postgresqlOpener.tearDown(self) | 149 postgresqlOpener.tearDown(self) |
| 135 | 150 |
| 136 | 151 |
| 152 @skip_postgresql | |
| 137 class postgresqlFilterCacheTest(postgresqlOpener, FilterCacheTest, | 153 class postgresqlFilterCacheTest(postgresqlOpener, FilterCacheTest, |
| 138 unittest.TestCase): | 154 unittest.TestCase): |
| 139 backend = 'postgresql' | 155 backend = 'postgresql' |
| 140 def setUp(self): | 156 def setUp(self): |
| 141 postgresqlOpener.setUp(self) | 157 postgresqlOpener.setUp(self) |
| 144 def tearDown(self): | 160 def tearDown(self): |
| 145 FilterCacheTest.tearDown(self) | 161 FilterCacheTest.tearDown(self) |
| 146 postgresqlOpener.tearDown(self) | 162 postgresqlOpener.tearDown(self) |
| 147 | 163 |
| 148 | 164 |
| 165 @skip_postgresql | |
| 149 class postgresqlSchemaTest(postgresqlOpener, SchemaTest, unittest.TestCase): | 166 class postgresqlSchemaTest(postgresqlOpener, SchemaTest, unittest.TestCase): |
| 150 def setUp(self): | 167 def setUp(self): |
| 151 postgresqlOpener.setUp(self) | 168 postgresqlOpener.setUp(self) |
| 152 SchemaTest.setUp(self) | 169 SchemaTest.setUp(self) |
| 153 | 170 |
| 154 def tearDown(self): | 171 def tearDown(self): |
| 155 SchemaTest.tearDown(self) | 172 SchemaTest.tearDown(self) |
| 156 postgresqlOpener.tearDown(self) | 173 postgresqlOpener.tearDown(self) |
| 157 | 174 |
| 158 | 175 |
| 176 @skip_postgresql | |
| 159 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest, | 177 class postgresqlClassicInitTest(postgresqlOpener, ClassicInitTest, |
| 160 unittest.TestCase): | 178 unittest.TestCase): |
| 161 backend = 'postgresql' | 179 backend = 'postgresql' |
| 162 def setUp(self): | 180 def setUp(self): |
| 163 postgresqlOpener.setUp(self) | 181 postgresqlOpener.setUp(self) |
| 167 ClassicInitTest.tearDown(self) | 185 ClassicInitTest.tearDown(self) |
| 168 postgresqlOpener.tearDown(self) | 186 postgresqlOpener.tearDown(self) |
| 169 | 187 |
| 170 | 188 |
| 171 from session_common import RDBMSTest | 189 from session_common import RDBMSTest |
| 190 @skip_postgresql | |
| 172 class postgresqlSessionTest(postgresqlOpener, RDBMSTest, unittest.TestCase): | 191 class postgresqlSessionTest(postgresqlOpener, RDBMSTest, unittest.TestCase): |
| 173 def setUp(self): | 192 def setUp(self): |
| 174 postgresqlOpener.setUp(self) | 193 postgresqlOpener.setUp(self) |
| 175 RDBMSTest.setUp(self) | 194 RDBMSTest.setUp(self) |
| 176 def tearDown(self): | 195 def tearDown(self): |
