doctest: Ignore exception detail
authorGuido Günther <agx@sigxcpu.org>
Fri, 17 Apr 2020 09:29:19 +0000 (11:29 +0200)
committerGuido Günther <agx@sigxcpu.org>
Fri, 17 Apr 2020 09:39:38 +0000 (11:39 +0200)
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.

tests/doctests/test_GitVfs.py
tests/doctests/test_PristineTar.py

index 16501e4969b80df36ec2f42e2c6512817712374d..4c498667795c73b4c4c4fd7cc1899e473014d438 100644 (file)
@@ -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'
index dfeb7193d53bd22bc17f03627afa8fd929af15f3..9e8f633602b9a0feaf4d666ec25601b88a1a7606 100644 (file)
@@ -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'