diff options
author | Guido Günther <agx@sigxcpu.org> | 2020-04-17 11:29:19 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2020-04-17 11:39:38 +0200 |
commit | e5133756d5024d6f9d0040c3a44c531abd5f3c73 (patch) | |
tree | 1b6f5ac6a2cf1e39f4417d87d2c32c7ffcef7e6d | |
parent | 8f893f9993484c5bf553070a637227a08243e84e (diff) |
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'
<BLANKLINE>
During handling of the above exception, another exception occurred:
<BLANKLINE>
Traceback (most recent call last):
File "/usr/lib/python3.8/doctest.py", line 1329, in __run
exec(compile(example.source, filename, "single",
File "<doctest test_read[12]>", line 1, in <module>
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.
-rw-r--r-- | tests/doctests/test_GitVfs.py | 4 | ||||
-rw-r--r-- | 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' |