[PATCH 13/13] pylint: examine test/ext too

0 views
Skip to first unread message

Rob Browning

unread,
Mar 14, 2026, 5:39:00 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
GNUmakefile | 3 ++-
pylint | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index ec99470e..14a433f1 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -318,7 +318,8 @@ lint-lib: dev/bup-exec dev/bup-python $(bup_deps)
# unused-wildcard-import: we often "import * from wvpytest"
.PHONY: lint-test
lint-test: dev/bup-exec dev/bup-python $(bup_deps)
- ./pylint -d unused-wildcard-import -d wildcard-import test/lib test/int
+ ./pylint -d unused-wildcard-import -d wildcard-import \
+ test/lib test/int test/ext

.PHONY: lint
lint: lint-lib lint-test
diff --git a/pylint b/pylint
index 59966865..be3fa334 100755
--- a/pylint
+++ b/pylint
@@ -43,7 +43,7 @@ if test "$#" -eq 0; then
dev/bup-python -m pylint \
-d unused-wildcard-import \
-d wildcard-import \
- test/lib test/int
+ test/lib test/int test/ext
else
set -x
exec dev/bup-python -m pylint "$@"
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:00 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Previously we only checked test/int. Fix what's needed to lint
test/ext too.

This should be the last of the pending pylint related patches. Thanks
to Johannes Berg for review.

Pushed to main.

--
Rob Browning
rlb @defaultvalue.org and @debian.org
GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A
GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4

Rob Browning

unread,
Mar 14, 2026, 5:39:00 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
Tested-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 1 -
test/ext/test_argv.py | 3 +--
test/ext/test_ftp.py | 2 +-
test/ext/test_get.py | 4 +---
test/ext/test_prune_older.py | 7 +++----
test/ext/test_split_trees.py | 1 -
6 files changed, 6 insertions(+), 12 deletions(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index 9260d332..e35fece0 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -1,6 +1,5 @@

from os import environb as environ, fsdecode
-from pathlib import Path
from subprocess import run
import os, pytest, subprocess, sys

diff --git a/test/ext/test_argv.py b/test/ext/test_argv.py
index a82ab8e2..e637199d 100644
--- a/test/ext/test_argv.py
+++ b/test/ext/test_argv.py
@@ -1,8 +1,7 @@


from random import randint
-from subprocess import CalledProcessError, check_output
-from sys import stderr, stdout
+from subprocess import check_output


from test.lib.wvpytest import wvpasseq
diff --git a/test/ext/test_ftp.py b/test/ext/test_ftp.py
index f7bda75e..7f57be46 100644
--- a/test/ext/test_ftp.py
+++ b/test/ext/test_ftp.py
@@ -7,7 +7,7 @@ import re
from bup.compat import environ
from bup.helpers import unlink as unlink_if_exists
from buptest import exc as ex, exo
-from wvpytest import wvfail, wvpass, wvpasseq, wvpassne, wvstart
+from wvpytest import wvpass, wvpasseq, wvstart
import bup.path

bup_cmd = bup.path.exe()
diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index 0629d8e6..894c0003 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -1,17 +1,15 @@

-from errno import ENOENT
from itertools import product
from os import chdir, mkdir, rename
from shutil import rmtree
from subprocess import DEVNULL, PIPE
import os, pytest, re, sys

-from bup import compat
from bup.compat import environ
from bup.helpers import EXIT_FAILURE, bquote, unlink
from bup.io import byte_stream
from buptest import exc as ex, exo
-from wvpytest import wvcheck, wvfail, wvmsg, wvpass, wvpasseq, wvpassne, wvstart
+from wvpytest import wvcheck, wvpasseq, wvpassne, wvstart
import bup.path


diff --git a/test/ext/test_prune_older.py b/test/ext/test_prune_older.py
index 92e1614e..d4143920 100644
--- a/test/ext/test_prune_older.py
+++ b/test/ext/test_prune_older.py
@@ -7,15 +7,14 @@ from random import choice, randint
from shutil import copytree, rmtree
from subprocess import PIPE
from sys import stderr
-from time import localtime, strftime, time, tzset
+from time import localtime, strftime, time
import random, sys

-from bup import compat
from bup.compat import environ
-from bup.helpers import partition, period_as_secs
+from bup.helpers import period_as_secs
from bup.io import byte_stream
from buptest import exc as ex, exo
-from wvpytest import wvfail, wvpass, wvpasseq, wvpassne, wvstart
+from wvpytest import wvpass, wvpasseq, wvpassne, wvstart
import bup.path


diff --git a/test/ext/test_split_trees.py b/test/ext/test_split_trees.py
index abdb9019..3c638861 100755
--- a/test/ext/test_split_trees.py
+++ b/test/ext/test_split_trees.py
@@ -1,7 +1,6 @@

from os import chdir, environb as environ
from os.path import join as joinp
-import pytest

from buptest import exc as ex, exo
import bup.path
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:00 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/test_ftp.py | 1 +
1 file changed, 1 insertion(+)

diff --git a/test/ext/test_ftp.py b/test/ext/test_ftp.py
index 49892a8a..f7bda75e 100644
--- a/test/ext/test_ftp.py
+++ b/test/ext/test_ftp.py
@@ -12,6 +12,7 @@ import bup.path

bup_cmd = bup.path.exe()

+# pylint: disable-next=function-redefined
def bup(*args, **kwargs):
if 'stdout' not in kwargs:
return exo((bup_cmd,) + args, **kwargs)
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:00 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 19 ++++++++++---------
test/ext/test_get.py | 3 +++
2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index a81f19e4..f0f2e681 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -56,11 +56,11 @@ class BupSubprocTestRunner(pytest.Item):
# "short", "long", "auto".
assert isinstance(style, (type(None), str)), style
ex = excinfo.value
- if isinstance(ex, BupSubprocFailure):
- msg = ['Exit status: %d' % ex.status,
- 'Failures:']
- msg.extend(fsdecode(s) for s in ex.failures)
- return '\n'.join(msg)
+ if not isinstance(ex, BupSubprocFailure):
+ return None
+ msg = [f'Exit status: {ex.status}', 'Failures:']
+ msg.extend(fsdecode(s) for s in ex.failures)
+ return '\n'.join(msg)

def reportinfo(self):
# This does not appear to be documented, but is in the
@@ -84,10 +84,11 @@ class BupSubprocTestFile(pytest.File):

def _collect_item(item):
name = os.path.basename(item.name)
- if name.startswith('test-') and not name.endswith('~'):
- if name == 'test-versioning-and-archive':
- item.add_marker(pytest.mark.release)
- return item
+ if name.endswith('~') or not name.startswith('test-'):
+ return None
+ if name == 'test-versioning-and-archive':
+ item.add_marker(pytest.mark.release)
+ return item

if pytest_ver: # 7+
def pytest_collect_file(parent, file_path):
diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index 56abe89c..142b77c2 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -113,6 +113,7 @@ def validate_tree(src_id, dest_id):
verify_trees_match(b'restore-src/', b'restore-dest/')
rmrf(b'restore-src')
rmrf(b'restore-dest')
+ return True

def validate_commit(src_id, dest_id):
exr = verify_rcz((b'git', b'--git-dir', b'get-src', b'cat-file', b'commit', src_id))
@@ -148,6 +149,7 @@ def validate_commit(src_id, dest_id):
verify_trees_match(b'restore-src/', b'restore-dest/')
rmrf(b'restore-src')
rmrf(b'restore-dest')
+ return True

def _get_save_coid(save):
# FIXME: add/use some kind of ls dereference opt
@@ -192,6 +194,7 @@ def _validate_save(orig_dir, save, save_subpath, commit_id, tree_id):
b'cat-file', b'commit', commit_id))
if cat.rc: return False
wvpasseq(b'tree ' + tree_id, cat.out.splitlines()[0])
+ return True

# FIXME: re-merge save and new_save?

--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:00 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 1 -
test/ext/test_argv.py | 2 +-
test/ext/test_get.py | 6 +++---
3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index e35fece0..e498fed2 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -70,7 +70,6 @@ class BupSubprocTestRunner(pytest.Item):

class BupSubprocTestFile(pytest.File):
def collect(self):
- name = self.fspath.basename
# name='' because there's only one test: running the command.
# i.e there are no sub-tests. Otherwise the status messages
# duplicate the test name like this:
diff --git a/test/ext/test_argv.py b/test/ext/test_argv.py
index e637199d..8daa3271 100644
--- a/test/ext/test_argv.py
+++ b/test/ext/test_argv.py
@@ -10,7 +10,7 @@ def rand_bytes(n):
return bytes([randint(1, 255) for x in range(n)])

def test_argv():
- for trial in range(100):
+ for _ in range(100):
cmd = [b'dev/echo-argv-bytes', rand_bytes(randint(1, 32))]
out = check_output(cmd)
wvpasseq(b'\0\n'.join(cmd) + b'\0\n', out)
diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index 894c0003..7b74a583 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -39,8 +39,8 @@ def rmrf(path):
err.append((function, path, excinfo))
rmtree(path, onerror=onerror)
if err:
- function, path, excinfo = err[0]
- ex_type, exc, traceback = excinfo
+ fn_, path, excinfo = err[0]
+ ex_type_, exc, traceback_ = excinfo
if (not isinstance(exc, FileNotFoundError)):
raise exc

@@ -1008,7 +1008,7 @@ def create_get_src():
tree_0_id = out[0]
commit_0_id = out[-1]
exr = exo((bup_cmd, b'-d', b'get-src', b'ls', b'src'))
- save_0 = exr.out.splitlines()[0]
+ save_0_ = exr.out.splitlines()[0]
ex((b'git', b'--git-dir', b'get-src', b'branch', b'src-0', b'src'))
ex((b'cp', b'-RPp', b'src', b'src-0'))

--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/test_ftp.py | 6 +++---
test/ext/test_get.py | 50 ++++++++++++++++++++++----------------------
2 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/test/ext/test_ftp.py b/test/ext/test_ftp.py
index 7efe13f1..4678030f 100644
--- a/test/ext/test_ftp.py
+++ b/test/ext/test_ftp.py
@@ -52,14 +52,14 @@ def test_ftp(tmpdir):
symlink(b'dir', b'dir-symlink')
symlink(b'not-there', b'bad-symlink')

- chdir(tmpdir)
+ chdir(tmpdir)
bup(b'init')
bup(b'index', b'src')
bup(b'save', b'-n', b'src', b'--strip', b'src')
save_utc = int(exo((b'git', b'show',
b'-s', b'--format=%at', b'src')).out.strip())
save_name = strftime('%Y-%m-%d-%H%M%S', localtime(save_utc)).encode('ascii')
-
+
wvstart('help')
wvpasseq(b'Commands: ls cd pwd cat get mget help quit\n',
exo((bup_cmd, b'ftp'), input=b'help\n', stderr=PIPE).out)
@@ -98,7 +98,7 @@ def test_ftp(tmpdir):
wvpasseq(b'excitement!\nmore excitement!\n',
bup(b'ftp',
input=b'cat src/latest/file-1 src/latest/dir/file-2\n').out)
-
+
wvstart('get')
bup(b'ftp', input=jl(b'get src/latest/file-1 dest'))
with open(b'dest', 'rb') as f:
diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index dedd978f..824a220d 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -72,7 +72,7 @@ def verify_nrx(rx, string):
def validate_clean_repo():
out = verify_rcz((b'git', b'--git-dir', b'get-dest', b'fsck')).out
verify_nrx(br'dangling|mismatch|missing|unreachable', out)
-
+
def validate_blob(src_id, dest_id):
global top
rmrf(b'restore-src')
@@ -106,7 +106,7 @@ def validate_tree(src_id, dest_id):
% bquote(dest_c),
shell=True)
if exr.rc != 0: return False
-
+
# git archive doesn't include an entry for ./.
unlink(b'restore-src/pax_global_header')
unlink(b'restore-dest/pax_global_header')
@@ -129,7 +129,7 @@ def validate_commit(src_id, dest_id):
dest_cat = exr.out
wvpasseq(src_cat, dest_cat)
if src_cat != dest_cat: return False
-
+
rmrf(b'restore-src')
rmrf(b'restore-dest')
mkdir(b'restore-src')
@@ -144,7 +144,7 @@ def validate_commit(src_id, dest_id):
b' | tar xf - -C restore-dest'),
shell=True)
if exr.rc != 0: return False
-
+
# git archive doesn't include an entry for ./.
ex((b'touch', b'-r', b'restore-src', b'restore-dest'))
verify_trees_match(b'restore-src/', b'restore-dest/')
@@ -198,7 +198,7 @@ def _validate_save(orig_dir, save, save_subpath, commit_id, tree_id):
return True

# FIXME: re-merge save and new_save?
-
+
def validate_save(dest_name, restore_subpath, commit_id, tree_id, orig_value,
get_out):
out = get_out.splitlines()
@@ -271,7 +271,7 @@ def _run_get(disposition, method, what, rewrite=None):
b'--source-url', b'ssh://' + getcwd() + b'/get-src')
else:
raise Exception(f'error: unexpected get disposition {disposition!r}')
-
+
cmd = (*get_cmd, b'--rewrite' if rewrite else b'--copy')
if isinstance(what, bytes):
cmd += (method, what)
@@ -380,7 +380,7 @@ def _test_replace(get_disposition, src_info):
for item in (b'.tag/tinyfile', b'src/latest' + tinyfile_path):
exr = run_get(get_disposition, b'--replace', (item ,b'.tag/obj'),
given=ex_ref)
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_blob(tinyfile_id, tinyfile_id)
verify_only_refs(heads=[], tags=(b'obj',))
wvstart(get_disposition + ' --replace ' + ex_type + ' with tree tag')
@@ -453,7 +453,7 @@ def _test_ff(get_disposition, src_info):
exr = run_get(get_disposition, b'--ff', (item, b'/'))
wvpassne(0, exr.rc)
verify_rx(br'is impossible; can only --append a tree to a branch',
- exr.err)
+ exr.err)
for item in (b'.tag/commit-1', b'src/latest', b'src'):
exr = run_get(get_disposition, b'--ff', (item, b'/'))
wvpassne(0, exr.rc)
@@ -509,7 +509,7 @@ def _test_ff(get_disposition, src_info):
validate_save(b'obj/latest', b'/',
commit_2_id, tree_2_id, b'src-2', exr.out)
verify_only_refs(heads=(b'obj',), tags=[])
-
+
wvstart(get_disposition + ' --ff, implicit destinations')
for item in (b'src', b'src/latest'):
exr = run_get(get_disposition, b'--ff', item)
@@ -866,21 +866,21 @@ def _test_new_tag(get_disposition, src_info):
wvstart(get_disposition + ' --new-tag, blob tag')
for item in (b'.tag/tinyfile', b'src/latest' + tinyfile_path):
exr = run_get(get_disposition, b'--new-tag', (item, b'.tag/obj'))
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_blob(tinyfile_id, tinyfile_id)
verify_only_refs(heads=[], tags=(b'obj',))

wvstart(get_disposition + ' --new-tag, tree tag')
for item in (b'.tag/subtree', b'src/latest' + subtree_vfs_path):
exr = run_get(get_disposition, b'--new-tag', (item, b'.tag/obj'))
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_tree(subtree_id, subtree_id)
verify_only_refs(heads=[], tags=(b'obj',))
-
+
wvstart(get_disposition + ' --new-tag, committish tag')
for item in (b'.tag/commit-2', b'src/latest', b'src'):
exr = run_get(get_disposition, b'--new-tag', (item, b'.tag/obj'))
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_tagged_save(b'obj', b'/', commit_2_id, tree_2_id,
b'src-2', exr.out)
verify_only_refs(heads=[], tags=(b'obj',))
@@ -925,7 +925,7 @@ def _test_new_tag(get_disposition, src_info):

wvstart(get_disposition + ' --new-tag, implicit destinations')
exr = run_get(get_disposition, b'--new-tag', b'.tag/commit-2')
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_tagged_save(b'commit-2', b'/', commit_2_id, tree_2_id,
b'src-2', exr.out)
verify_only_refs(heads=[], tags=(b'commit-2',))
@@ -951,13 +951,13 @@ def _test_unnamed(get_disposition, src_info):
wvstart(get_disposition + ' --unnamed file')
for item in (b'.tag/tinyfile', b'src/latest' + tinyfile_path):
exr = run_get(get_disposition, b'--unnamed', item)
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_blob(tinyfile_id, tinyfile_id)
verify_only_refs(heads=[], tags=[])

exr = run_get(get_disposition, b'--unnamed', item,
given=(item, b'.tag/obj'))
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_blob(tinyfile_id, tinyfile_id)
verify_only_refs(heads=[], tags=(b'obj',))

@@ -965,28 +965,28 @@ def _test_unnamed(get_disposition, src_info):
subtree_id = src_info['subtree-id']
for item in (b'.tag/subtree', b'src/latest' + subtree_vfs_path):
exr = run_get(get_disposition, b'--unnamed', item)
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_tree(subtree_id, subtree_id)
verify_only_refs(heads=[], tags=[])
-
+
exr = run_get(get_disposition, b'--unnamed', item,
given=(item, b'.tag/obj'))
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_tree(subtree_id, subtree_id)
verify_only_refs(heads=[], tags=(b'obj',))
-
+
wvstart(get_disposition + ' --unnamed committish')
save_2 = src_info['save-2']
commit_2_id = src_info['commit-2-id']
for item in (b'.tag/commit-2', b'src/' + save_2, b'src'):
exr = run_get(get_disposition, b'--unnamed', item)
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_commit(commit_2_id, commit_2_id)
verify_only_refs(heads=[], tags=[])

exr = run_get(get_disposition, b'--unnamed', item,
given=(item, b'.tag/obj'))
- wvpasseq(0, exr.rc)
+ wvpasseq(0, exr.rc)
validate_commit(commit_2_id, commit_2_id)
verify_only_refs(heads=[], tags=(b'obj',))

@@ -1013,7 +1013,7 @@ def create_get_src():
save_0_ = exr.out.splitlines()[0]
ex((b'git', b'--git-dir', b'get-src', b'branch', b'src-0', b'src'))
ex((b'cp', b'-RPp', b'src', b'src-0'))
-
+
rmrf(b'src')
mkdir(b'src')
mkdir(b'src/empty-dir')
@@ -1030,7 +1030,7 @@ def create_get_src():
save_1 = exr.out.splitlines()[1]
ex((b'git', b'--git-dir', b'get-src', b'branch', b'src-1', b'src'))
ex((b'cp', b'-RPp', b'src', b'src-1'))
-
+
# Make a copy the current state of src so we'll have an ancestor.
ex((b'cp', b'-RPp',
b'get-src/refs/heads/src', b'get-src/refs/heads/src-ancestor'))
@@ -1087,7 +1087,7 @@ def create_get_src():
'save-2' : save_2,
'subtree-path' : subtree_path,
'subtree-vfs-path' : subtree_vfs_path}
-
+
# FIXME: this fails in a strange way:
# WVPASS given nothing get --ff not-there

--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/test_get.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index 6c3b8b46..f1688cf0 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -996,14 +996,14 @@ def create_get_src():
ex((bup_cmd, b'-d', b'get-src', b'init'))

mkdir(b'src')
- with open(b'src/unrelated', 'a'): pass
+ with open(b'src/unrelated', 'wb'): pass
ex((bup_cmd, b'-d', b'get-src', b'index', b'src'))
ex((bup_cmd, b'-d', b'get-src', b'save', b'-tcn', b'unrelated-branch', b'--strip', b'src'))

ex((bup_cmd, b'-d', b'get-src', b'index', b'--clear'))
rmrf(b'src')
mkdir(b'src')
- with open(b'src/zero', 'a'): pass
+ with open(b'src/zero', 'wb'): pass
ex((bup_cmd, b'-d', b'get-src', b'index', b'src'))
exr = exo((bup_cmd, b'-d', b'get-src', b'save', b'-tcn', b'src', b'--strip', b'src'))
out = exr.out.splitlines()
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/test_get.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index 142b77c2..6c3b8b46 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -6,7 +6,7 @@ from shutil import rmtree
from subprocess import DEVNULL, PIPE
import os, pytest, re, sys

-from bup import compat, path
+from bup import compat
from bup.compat import environ
from bup.helpers import EXIT_FAILURE, bquote, unlink
from bup.io import byte_stream
@@ -35,15 +35,16 @@ top = getcwd()
bup_cmd = bup.path.exe()

def rmrf(path):
- err = [] # because python's scoping mess...
+ err = []
def onerror(function, path, excinfo):
+ nonlocal err
err.append((function, path, excinfo))
rmtree(path, onerror=onerror)
if err:
function, path, excinfo = err[0]
- ex_type, ex, traceback = excinfo
- if (not isinstance(ex, OSError)) or ex.errno != ENOENT:
- raise ex
+ ex_type, exc, traceback = excinfo
+ if (not isinstance(exc, FileNotFoundError)):
+ raise exc

def verify_trees_match(path1, path2):
global top
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/test_get.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index f1688cf0..0629d8e6 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -79,7 +79,7 @@ def validate_blob(src_id, dest_id):
rmrf(b'restore-dest')
cat_tree = top + b'/dev/git-cat-tree'
src_blob = verify_rcz((cat_tree, b'--git-dir', b'get-src', src_id)).out
- dest_blob = verify_rcz((cat_tree, b'--git-dir', b'get-src', src_id)).out
+ dest_blob = verify_rcz((cat_tree, b'--git-dir', b'get-src', dest_id)).out
wvpasseq(src_blob, dest_blob)

def validate_tree(src_id, dest_id):
@@ -300,7 +300,7 @@ def run_get(disposition, method, what=None, given=None, rewrite=False):
assert not exr.rc
return _run_get(disposition, method, what, rewrite)

-def _test_universal(get_disposition, src_info):
+def _test_universal(get_disposition, src_info_):
if get_disposition == 'get':
wvstart("can't do nothing")
rmrf(b'get-dest')
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index f98342a2..330c14c0 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -53,7 +53,10 @@ class BupSubprocTestRunner(pytest.Item):
% (cmd, p.returncode, len(failures)),
cmd, p.returncode, failures)

- def repr_failure(self, excinfo):
+ def repr_failure(self, excinfo, style=None):
+ # We ignore the style, which appears to be one of None,
+ # "short", "long", "auto".
+ assert isinstance(style, (type(None), str)), style
ex = excinfo.value
if isinstance(ex, BupSubprocFailure):
msg = ['Exit status: %d' % ex.status,
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 10 ++++------
test/ext/test_get.py | 4 ++--
2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index 330c14c0..a81f19e4 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -1,7 +1,7 @@

from os import environb as environ, fsdecode
from pathlib import Path
-from subprocess import CalledProcessError
+from subprocess import run
import os, pytest, subprocess, sys

from bup.helpers import temp_dir
@@ -30,11 +30,9 @@ class BupSubprocTestRunner(pytest.Item):
with temp_dir(dir=os.path.abspath(b'test/tmp'), prefix=b'bup-test-home-') as home:
env = environ.copy()
env[b'HOME'] = home
- p = subprocess.Popen(cmd,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env=env)
- out = p.communicate()[0]
+ p = run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
+ env=env)
+ out = p.stdout
sys.stdout.flush()
byte_stream(sys.stdout).write(out)
lines = out.splitlines()
diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index ae771ea9..56abe89c 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -992,14 +992,14 @@ def create_get_src():
ex((bup_cmd, b'-d', b'get-src', b'init'))

mkdir(b'src')
- open(b'src/unrelated', 'a').close()
+ with open(b'src/unrelated', 'a'): pass
ex((bup_cmd, b'-d', b'get-src', b'index', b'src'))
ex((bup_cmd, b'-d', b'get-src', b'save', b'-tcn', b'unrelated-branch', b'--strip', b'src'))

ex((bup_cmd, b'-d', b'get-src', b'index', b'--clear'))
rmrf(b'src')
mkdir(b'src')
- open(b'src/zero', 'a').close()
+ with open(b'src/zero', 'a'): pass

Rob Browning

unread,
Mar 14, 2026, 5:39:01 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index f0f2e681..9260d332 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -14,9 +14,8 @@ from bup.io import byte_stream
pytest_ver = getattr(pytest, 'version_tuple', None)

class BupSubprocFailure(Exception):
- def __init__(self, msg, cmd, status, failures):
+ def __init__(self, msg, status=None, failures=tuple()):
super().__init__(msg)
- self.cmd = cmd
self.status = status
self.failures = failures

@@ -49,7 +48,7 @@ class BupSubprocTestRunner(pytest.Item):
if failures or p.returncode != 0:
raise BupSubprocFailure('%s failed (exit %d, %d failures)'
% (cmd, p.returncode, len(failures)),
- cmd, p.returncode, failures)
+ p.returncode, failures)

def repr_failure(self, excinfo, style=None):
# We ignore the style, which appears to be one of None,
--
2.47.3

Rob Browning

unread,
Mar 14, 2026, 5:39:02 PM (10 days ago) Mar 14
to bup-...@googlegroups.com
Signed-off-by: Rob Browning <r...@defaultvalue.org>
---
test/ext/conftest.py | 4 +++-
test/ext/test_ftp.py | 5 +++--
test/ext/test_get.py | 8 +++++---
test/ext/test_prune_older.py | 5 +++--
4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/test/ext/conftest.py b/test/ext/conftest.py
index e498fed2..c5f80d5b 100644
--- a/test/ext/conftest.py
+++ b/test/ext/conftest.py
@@ -1,7 +1,9 @@

from os import environb as environ, fsdecode
from subprocess import run
-import os, pytest, subprocess, sys
+import os, subprocess, sys
+
+import pytest

from bup.helpers import temp_dir
from bup.io import byte_stream
diff --git a/test/ext/test_ftp.py b/test/ext/test_ftp.py
index 7f57be46..7efe13f1 100644
--- a/test/ext/test_ftp.py
+++ b/test/ext/test_ftp.py
@@ -4,10 +4,11 @@ from subprocess import PIPE
from time import localtime, strftime, tzset
import re

-from bup.compat import environ
-from bup.helpers import unlink as unlink_if_exists
from buptest import exc as ex, exo
from wvpytest import wvpass, wvpasseq, wvstart
+
+from bup.compat import environ
+from bup.helpers import unlink as unlink_if_exists
import bup.path

bup_cmd = bup.path.exe()
diff --git a/test/ext/test_get.py b/test/ext/test_get.py
index 7b74a583..dedd978f 100644
--- a/test/ext/test_get.py
+++ b/test/ext/test_get.py
@@ -3,13 +3,15 @@ from itertools import product
from os import chdir, mkdir, rename
from shutil import rmtree
from subprocess import DEVNULL, PIPE
-import os, pytest, re, sys
+import os, re, sys
+
+from buptest import exc as ex, exo
+from wvpytest import wvcheck, wvpasseq, wvpassne, wvstart
+import pytest

from bup.compat import environ
from bup.helpers import EXIT_FAILURE, bquote, unlink
from bup.io import byte_stream
-from buptest import exc as ex, exo
-from wvpytest import wvcheck, wvpasseq, wvpassne, wvstart
import bup.path


diff --git a/test/ext/test_prune_older.py b/test/ext/test_prune_older.py
index d4143920..9eec9793 100644
--- a/test/ext/test_prune_older.py
+++ b/test/ext/test_prune_older.py
@@ -10,11 +10,12 @@ from sys import stderr
from time import localtime, strftime, time
import random, sys

+from buptest import exc as ex, exo
+from wvpytest import wvpass, wvpasseq, wvpassne, wvstart
+
from bup.compat import environ
from bup.helpers import period_as_secs
from bup.io import byte_stream
-from buptest import exc as ex, exo
-from wvpytest import wvpass, wvpasseq, wvpassne, wvstart
import bup.path


--
2.47.3

Reply all
Reply to author
Forward
0 new messages