Mercurial > hg
comparison tests/test-rust-ancestor.py @ 41350:ab0d762d89ef stable
rust-cpython: raising error.WdirUnsupported
The Graph implementation of hg-cpython returns the appropriate error
upon encounter with the working directory special revision number, and
this gives us in particular a code path to test from test-rust-ancestors.py
In the current implementation, the exception is actually raised from
the iterator instantiation; we are nonetheless consuming the iterator
in the test with `list()` in order not to depend on implementation details.
author | Georges Racinet <georges.racinet@octobus.net> |
---|---|
date | Wed, 23 Jan 2019 07:49:36 -0500 |
parents | 619ee4039bd4 |
children | 0c7b353ce100 |
comparison
equal
deleted
inserted
replaced
41349:ee943a920606 | 41350:ab0d762d89ef |
---|---|
1 from __future__ import absolute_import | 1 from __future__ import absolute_import |
2 import sys | 2 import sys |
3 import unittest | 3 import unittest |
4 | |
5 from mercurial import ( | |
6 error, | |
7 node, | |
8 ) | |
4 | 9 |
5 try: | 10 try: |
6 from mercurial import rustext | 11 from mercurial import rustext |
7 rustext.__name__ # trigger immediate actual import | 12 rustext.__name__ # trigger immediate actual import |
8 except ImportError: | 13 except ImportError: |
151 exc = arc.exception | 156 exc = arc.exception |
152 self.assertIsInstance(exc, ValueError) | 157 self.assertIsInstance(exc, ValueError) |
153 # rust-cpython issues appropriate str instances for Python 2 and 3 | 158 # rust-cpython issues appropriate str instances for Python 2 and 3 |
154 self.assertEqual(exc.args, ('ParentOutOfRange', 1)) | 159 self.assertEqual(exc.args, ('ParentOutOfRange', 1)) |
155 | 160 |
161 def testwdirunsupported(self): | |
162 # trying to access ancestors of the working directory raises | |
163 # WdirUnsupported directly | |
164 idx = self.parseindex() | |
165 with self.assertRaises(error.WdirUnsupported): | |
166 list(AncestorsIterator(idx, [node.wdirrev], -1, False)) | |
156 | 167 |
157 if __name__ == '__main__': | 168 if __name__ == '__main__': |
158 import silenttestrunner | 169 import silenttestrunner |
159 silenttestrunner.main(__name__) | 170 silenttestrunner.main(__name__) |