Mercurial > p > roundup > code
comparison test/test_indexer.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 |
|---|---|
| 18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 19 # SOFTWARE. | 19 # SOFTWARE. |
| 20 | 20 |
| 21 import os, unittest, shutil | 21 import os, unittest, shutil |
| 22 | 22 |
| 23 import pytest | |
| 23 from roundup.backends import get_backend, have_backend | 24 from roundup.backends import get_backend, have_backend |
| 24 from roundup.backends.indexer_rdbms import Indexer | 25 from roundup.backends.indexer_rdbms import Indexer |
| 25 | 26 |
| 26 # borrow from other tests | 27 # borrow from other tests |
| 27 from db_test_base import setupSchema, config | 28 from db_test_base import setupSchema, config |
| 28 from test_postgresql import postgresqlOpener | 29 from .test_postgresql import postgresqlOpener, skip_postgresql |
| 29 from test_mysql import mysqlOpener | 30 from .test_mysql import mysqlOpener, skip_mysql |
| 30 from test_sqlite import sqliteOpener | 31 from test_sqlite import sqliteOpener |
| 32 | |
| 33 try: | |
| 34 import xapian | |
| 35 SKIP_XAPIAN = False | |
| 36 except ImportError: | |
| 37 SKIP_XAPIAN = True | |
| 38 | |
| 39 skip_xapian = pytest.mark.skipif( | |
| 40 SKIP_XAPIAN, | |
| 41 reason="Skipping Xapian indexer tests: 'xapian' not installed") | |
| 42 | |
| 31 | 43 |
| 32 class db: | 44 class db: |
| 33 class config(dict): | 45 class config(dict): |
| 34 DATABASE = 'test-index' | 46 DATABASE = 'test-index' |
| 35 config = config() | 47 config = config() |
| 137 self.assertEqual(len(self.dex.find(['many'])), 123) | 149 self.assertEqual(len(self.dex.find(['many'])), 123) |
| 138 | 150 |
| 139 def tearDown(self): | 151 def tearDown(self): |
| 140 shutil.rmtree('test-index') | 152 shutil.rmtree('test-index') |
| 141 | 153 |
| 154 | |
| 155 @skip_xapian | |
| 142 class XapianIndexerTest(IndexerTest): | 156 class XapianIndexerTest(IndexerTest): |
| 143 def setUp(self): | 157 def setUp(self): |
| 144 if os.path.exists('test-index'): | 158 if os.path.exists('test-index'): |
| 145 shutil.rmtree('test-index') | 159 shutil.rmtree('test-index') |
| 146 os.mkdir('test-index') | 160 os.mkdir('test-index') |
| 162 self.db.close() | 176 self.db.close() |
| 163 if os.path.exists(config.DATABASE): | 177 if os.path.exists(config.DATABASE): |
| 164 shutil.rmtree(config.DATABASE) | 178 shutil.rmtree(config.DATABASE) |
| 165 | 179 |
| 166 | 180 |
| 181 @skip_postgresql | |
| 167 class postgresqlIndexerTest(postgresqlOpener, RDBMSIndexerTest, IndexerTest): | 182 class postgresqlIndexerTest(postgresqlOpener, RDBMSIndexerTest, IndexerTest): |
| 168 def setUp(self): | 183 def setUp(self): |
| 169 postgresqlOpener.setUp(self) | 184 postgresqlOpener.setUp(self) |
| 170 RDBMSIndexerTest.setUp(self) | 185 RDBMSIndexerTest.setUp(self) |
| 171 def tearDown(self): | 186 def tearDown(self): |
| 172 RDBMSIndexerTest.tearDown(self) | 187 RDBMSIndexerTest.tearDown(self) |
| 173 postgresqlOpener.tearDown(self) | 188 postgresqlOpener.tearDown(self) |
| 174 | 189 |
| 175 | 190 |
| 191 @skip_mysql | |
| 176 class mysqlIndexerTest(mysqlOpener, RDBMSIndexerTest, IndexerTest): | 192 class mysqlIndexerTest(mysqlOpener, RDBMSIndexerTest, IndexerTest): |
| 177 def setUp(self): | 193 def setUp(self): |
| 178 mysqlOpener.setUp(self) | 194 mysqlOpener.setUp(self) |
| 179 RDBMSIndexerTest.setUp(self) | 195 RDBMSIndexerTest.setUp(self) |
| 180 def tearDown(self): | 196 def tearDown(self): |
