Mercurial > p > roundup > code
comparison test/test_instance.py @ 6325:1a15089c2e49 issue2550923_computed_property
Merge trunk into branch
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 06 Feb 2021 20:15:26 -0500 |
| parents | 778a9f455067 |
| children | 9c3ec0a5c7fc |
comparison
equal
deleted
inserted
replaced
| 6319:20e77c3ce6f6 | 6325:1a15089c2e49 |
|---|---|
| 1 # | |
| 2 # Copyright (C) 2020 John Rouillard | |
| 3 # All rights reserved. | |
| 4 # For license terms see the file COPYING.txt. | |
| 5 # | |
| 6 | |
| 7 from __future__ import print_function | |
| 8 import unittest, os, shutil, errno, sys, difflib | |
| 9 | |
| 10 from roundup import instance | |
| 11 from roundup.instance import TrackerError | |
| 12 | |
| 13 try: | |
| 14 # python2 | |
| 15 import pathlib2 as pathlib | |
| 16 except ImportError: | |
| 17 # python3 | |
| 18 import pathlib | |
| 19 | |
| 20 from . import db_test_base | |
| 21 | |
| 22 class InstanceTest(unittest.TestCase): | |
| 23 | |
| 24 backend = 'anydbm' | |
| 25 | |
| 26 def setUp(self): | |
| 27 self.dirname = '_test_instance' | |
| 28 # set up and open a tracker | |
| 29 self.instance = db_test_base.setupTracker(self.dirname, self.backend) | |
| 30 | |
| 31 # open the database | |
| 32 self.db = self.instance.open('admin') | |
| 33 | |
| 34 self.db.commit() | |
| 35 self.db.close() | |
| 36 | |
| 37 def tearDown(self): | |
| 38 if self.db: | |
| 39 self.db.close() | |
| 40 try: | |
| 41 shutil.rmtree(self.dirname) | |
| 42 except OSError as error: | |
| 43 if error.errno not in (errno.ENOENT, errno.ESRCH): raise | |
| 44 | |
| 45 | |
| 46 def testOpenOldStyle(self): | |
| 47 pathlib.Path(os.path.join(self.dirname, "dbinit.py")).touch() | |
| 48 # no longer support old style tracker configs | |
| 49 self.assertRaises(TrackerError, instance.open, self.dirname) | |
| 50 |
