From e5133756d5024d6f9d0040c3a44c531abd5f3c73 Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 17 Apr 2020 11:29:19 +0200 Subject: doctest: Ignore exception detail We used the tests to check whether the right exception was returned but python 3.8 breaks this again: File "/var/scratch/src/git-buildpackage/git-buildpackage/tests/doctests/test_GitVfs.py", line 56, in test_read Failed example: gf = vfs.open('doesnotexist') # doctest:+ELLIPSIS Expected: Traceback (most recent call last): ... OSError: can't get HEAD:doesnotexist: fatal: Path 'doesnotexist' does not exist in 'HEAD' Got: Traceback (most recent call last): File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/vfs.py", line 74, in open return GitVfs._File(self._repo.show( File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/repository.py", line 1645, in show raise GitRepositoryError("can't get %s: %s" % (id, stderr.decode().rstrip())) gbp.git.repository.GitRepositoryError: can't get HEAD:doesnotexist: fatal: path 'doesnotexist' does not exist in 'HEAD' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/lib/python3.8/doctest.py", line 1329, in __run exec(compile(example.source, filename, "single", File "", line 1, in gf = vfs.open('doesnotexist') # doctest:+ELLIPSIS File "/var/scratch/src/git-buildpackage/git-buildpackage/gbp/git/vfs.py", line 78, in open raise OSError(e) OSError: can't get HEAD:doesnotexist: fatal: path 'doesnotexist' does not exist in 'HEAD' Doctest were a nice feature but keeping up with the subtle breackage is too cumbersome. --- tests/doctests/test_GitVfs.py | 4 ++-- tests/doctests/test_PristineTar.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/doctests/test_GitVfs.py b/tests/doctests/test_GitVfs.py index 16501e49..4c498667 100644 --- a/tests/doctests/test_GitVfs.py +++ b/tests/doctests/test_GitVfs.py @@ -53,7 +53,7 @@ def test_read(): >>> gf.close() >>> gbp.git.vfs.GitVfs(repo, 'HEAD').open('foo.txt').read() == content.decode() True - >>> gf = vfs.open('doesnotexist') + >>> gf = vfs.open('doesnotexist') # doctest:+IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... OSError: can't get HEAD:doesnotexist: fatal: Path 'doesnotexist' does not exist in 'HEAD' @@ -91,7 +91,7 @@ def test_binary_read(): >>> gf.close() >>> gbp.git.vfs.GitVfs(repo, 'HEAD').open('foo.txt', 'rb').read() == content True - >>> gf = vfs.open('doesnotexist') + >>> gf = vfs.open('doesnotexist') # doctest:+IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... OSError: can't get HEAD:doesnotexist: fatal: Path 'doesnotexist' does not exist in 'HEAD' diff --git a/tests/doctests/test_PristineTar.py b/tests/doctests/test_PristineTar.py index dfeb7193..9e8f6336 100644 --- a/tests/doctests/test_PristineTar.py +++ b/tests/doctests/test_PristineTar.py @@ -209,7 +209,7 @@ def test_pristine_tar_checkout_nonexistent(): >>> repo = gbp.deb.git.DebianGitRepository(dirs['repo']) >>> _gbp_log_err_bak = gbp.log.err >>> gbp.log.err = lambda x: None - >>> repo.pristine_tar.checkout('upstream', '1.1', 'gzip', '..') + >>> repo.pristine_tar.checkout('upstream', '1.1', 'gzip', '..') # doctest:+IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): ... gbp.command_wrappers.CommandExecFailed: Pristine-tar couldn't checkout "upstream_1.1.orig.tar.gz": fatal: Path 'upstream_1.1.orig.tar.gz.delta' does not exist in 'refs/heads/pristine-tar' -- cgit v1.2.3