Mercurial > p > roundup > code
comparison test/db_test_base.py @ 6240:0c3def4b5275
Check for DesignatorError rather than ValueError
Verify the more explicit exception.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Tue, 28 Jul 2020 06:52:28 -0400 |
| parents | d3878ac549e9 |
| children | b14359503b49 |
comparison
equal
deleted
inserted
replaced
| 6239:d3878ac549e9 | 6240:0c3def4b5275 |
|---|---|
| 2981 fooz=Multilink('a')) | 2981 fooz=Multilink('a')) |
| 2982 b.setkey("name") | 2982 b.setkey("name") |
| 2983 self.db.post_init() | 2983 self.db.post_init() |
| 2984 | 2984 |
| 2985 def test_splitDesignator(self): | 2985 def test_splitDesignator(self): |
| 2986 from roundup.hyperdb import splitDesignator | 2986 from roundup.hyperdb import splitDesignator, DesignatorError |
| 2987 | 2987 |
| 2988 valid_test_cases = [('zip2py44', ('zip2py', '44')), | 2988 valid_test_cases = [('zip2py44', ('zip2py', '44')), |
| 2989 ('zippy2', ('zippy', '2')), | 2989 ('zippy2', ('zippy', '2')), |
| 2990 ('a9', ('a', '9')), | 2990 ('a9', ('a', '9')), |
| 2991 ('a1234', ('a', '1234')), | 2991 ('a1234', ('a', '1234')), |
| 2999 print("Testing %s"%designator[0]) | 2999 print("Testing %s"%designator[0]) |
| 3000 self.assertEqual(splitDesignator(designator[0]), designator[1]) | 3000 self.assertEqual(splitDesignator(designator[0]), designator[1]) |
| 3001 | 3001 |
| 3002 for designator in invalid_test_cases: | 3002 for designator in invalid_test_cases: |
| 3003 print("Testing %s"%designator) | 3003 print("Testing %s"%designator) |
| 3004 with self.assertRaises(ValueError) as ctx: | 3004 with self.assertRaises(DesignatorError) as ctx: |
| 3005 splitDesignator(designator) | 3005 splitDesignator(designator) |
| 3006 error = '"%s" not a node designator' % designator | 3006 error = '"%s" not a node designator' % designator |
| 3007 self.assertEqual(str(ctx.exception), error) | 3007 self.assertEqual(str(ctx.exception), error) |
| 3008 | 3008 |
| 3009 | 3009 |
