🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #6359

Bug#1155493: apt-xapian-index: test suite does not run: ./runtests collects Python's stdlib tests, and TestIndexer uses assert_ ...

#6359
From: Robert August Vincent II
Date: Thu, 26 Nov 2026 22:40
258 lines
14179 bytes
Package: apt-xapian-index
Version: 0.59
Severity: normal
Tags: patch upstream

Dear Maintainer,

The package's test suite does not currently run, for two independent reasons.
Neither affects users of the installed package, so this is filed separately
from the IndexError crash I am reporting against the relations plugin. It does
mean that the build-time test step has not been testing the package.

1. ./runtests collects Python's standard library tests instead of the package's

test/ has no __init__.py, so it is not a package, and with the PYTHONPATH that
runtests sets, "import test" finds Python's own stdlib test package first:

  $ PYTHONPATH=$PWD python3 -c "import test; print(test.__file__)"
  /usr/lib/python3.14/test/__init__.py

The consequence is that "./runtests -v" runs 70 tests, every one of them from
Python's test_support module, and none of the package's at all.

This is not a property of one machine or one release. The directory, including
the test_support module that gets collected, is shipped by the core stdlib
package:

  $ dpkg -S /usr/lib/python3.14/test/test_support.py
  libpython3.14-stdlib:amd64: /usr/lib/python3.14/test/test_support.py

  $ apt-cache show python3.14 | grep ^Depends
  Depends: python3.14-minimal (= ...), libpython3.14-stdlib (= ...), ...

libpython3.14-stdlib provides 76 files under test/ and python3.14 depends on
it, so anything able to run the suite necessarily has the colliding package.
The optional libpython3.14-testsuite is NOT installed here and is not
involved. A minimal build chroot is affected too.

What varies between environments is only whether it is noticed. Here the run
reports 12 failures and 4 errors, but those are Python's own stdlib tests
misbehaving under nose2 rather than anything in this package - the same
numbers appear with the package nowhere in sight:

  $ cd /tmp && python3 -m nose2 test.test_support
  Ran 70 tests in 2.685s
  FAILED (failures=12, errors=4, skipped=2)

(nose2 0.16.0, Python 3.14.8.) On an environment where those stdlib tests
happen to pass under nose2, ./runtests would exit 0 while having tested the
standard library, which is the quieter and worse outcome. Since debian/rules
runs ./runtests in override_dh_auto_test unless nocheck is set, that is
presumably what has been happening.

The attached patch passes "-s test -t test", which makes nose2 treat the test
directory as both the start and the top-level directory, so modules there are
imported top-level and the stdlib package is never consulted.

I tried the two other obvious candidates and they are worse. Adding an empty
test/__init__.py does fix the import - "import test" then resolves to the
repository's directory, regular package beating namespace portion - but it
makes nose2 import test.test_indexer, whose "import tools" then fails with
ModuleNotFoundError, so it needs the test code changed too. And "-s test -t ."
does not work at all: nose2 reports "Start directory is not importable".

2. The existing TestIndexer tests use assert_, removed in Python 3.12

With collection fixed - nose2 run from inside test/ - the package's own tests
are found, and all four TestIndexer tests error:

  ERROR: testAptRebuild (test_indexer.TestIndexer.testAptRebuild)
  ERROR: testDeb822Rebuild (test_indexer.TestIndexer.testDeb822Rebuild)
  ERROR: testIncrementalRebuild (test_indexer.TestIndexer.testIncrementalRebuild)
  ERROR: testIncrementalRebuildFromEmpty (test_indexer.TestIndexer.testIncrementalRebuildFromEmpty)

  AttributeError: 'TestIndexer' object has no attribute 'assert_'.
  Did you mean: 'assertIn'?

unittest.TestCase.assert_ was a deprecated alias for assertTrue and was
removed in Python 3.12. There are 11 call sites in test/test_indexer.py:

  $ grep -c 'assert_(' test/test_indexer.py
  11

  $ python3 -c "import unittest; print(hasattr(unittest.TestCase, 'assert_'))"
  False

So even with collection working, the suite cannot pass on any Python from
3.12 onward. The attached patch replaces assert_ with assertTrue at those 11
sites, which is what assert_ was an alias for; no assertion changes meaning.

WHAT THE PATCH DOES NOT FIX

With both changes applied the package's four tests are collected and execute,
and they still do not pass here - for a third reason the patch deliberately
leaves alone:

  ERROR: testAptRebuild (test_indexer.TestIndexer.testAptRebuild)
    File "/usr/lib/python3/dist-packages/apt/cache.py", line 280, in __getitem__
      rawpkg = self._cache[key]
  KeyError: 'libept-dev'

The fixtures name libept-dev at three sites in test/test_indexer.py, and that
package does not exist in Ubuntu 26.10 - "apt-cache policy libept-dev" returns
nothing at all. So the tests depend on specific packages being present in the
local apt cache. That is a fixture assumption rather than a harness fault, and
how to handle it - skip when absent, or choose packages that are always
present - seemed a decision for you rather than for me.

So this patch moves the suite from "runs 70 of Python's tests and none of
yours" to "runs yours, four of which fail on a missing fixture package". That
is progress rather than a green suite, and I would rather say so than imply
otherwise.

For completeness: this applies cleanly alongside the relations.py patch in my
other report. With both, "./runtests -v" collects 10 tests - the 6 new
relations tests pass and the 4 TestIndexer tests fail on the libept-dev
fixture above.

-- System Information:
Distribution: Ubuntu 26.10 (stonking)
Architecture: amd64
Python: 3.14.8
nose2: 0.16.0
apt-xapian-index: 0.59

From 1ec6809264a589fa592db06f2dcdd9d67c72a94e Mon Sep 17 00:00:00 2001
From: Robert August Vincent II <pillarsdotnet@gmail.com>
Date: Thu, 26 Nov 2026 17:23:00 -0500
Subject: [PATCH] tests: collect this package's tests, and stop using assert_

Two independent reasons the suite does not run. Neither changes what any
test asserts.

1. runtests collected Python's standard library instead of this package.

test/ has no __init__.py, so it is importable only as a namespace package,
and a regular package anywhere on sys.path wins over a namespace portion
regardless of order - so "import test" found /usr/lib/python3.14/test/,
which libpython3.14-stdlib ships and python3.14 depends on. "./runtests -v"
therefore ran 70 tests, all from Python's test_support, and none of this
package's.

Passing -s test -t test makes nose2 treat the test directory as both the
start and the top-level directory, so modules there are imported top-level
and the stdlib package is never consulted. Adding test/__init__.py was the
other candidate and is worse: it makes nose2 import test.test_indexer, whose
"import tools" then fails, so it would need the test code changed as well.
Note that -s test -t . does not work either - nose2 reports "Start directory
is not importable".

2. The tests used unittest.TestCase.assert_, removed in Python 3.12.

All four errored with "AttributeError: 'TestIndexer' object has no attribute
'assert_'" before executing anything. Replaced at the 11 call sites with
assertTrue, which is what assert_ was an alias for.

With both changes the package's own four tests are collected and execute.
They still do not pass here, for a third and separate reason this commit does
not touch: the fixtures name libept-dev, which does not exist in Ubuntu 26.10,
so they fail with KeyError: 'libept-dev' from apt.cache. That is a fixture
assumption rather than a harness fault and is left for the maintainer.
---
 runtests             |  4 ++--
 test/test_indexer.py | 22 +++++++++++-----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/runtests b/runtests
index bcf416c..8917078 100755
--- a/runtests
+++ b/runtests
@@ -8,13 +8,13 @@ case "$1" in
 	--cov)
 		echo "Run with code coverage..."
 		shift
-		nose2-3 test --with-coverage --cover-package axi --cover-html --cover-html-dir=test-coverage "$@"
+		nose2-3 -s test -t test --with-coverage --cover-package axi --cover-html --cover-html-dir=test-coverage "$@"
 		echo "Coverage information found at file://`pwd`/test/test-coverage"
 		;;
 	--clean)
 		rm -rf test/test-coverage test/.coverage testdb
 		;;
 	*)
-		python3 -m nose2 test "$@"
+		python3 -m nose2 -s test -t test "$@"
 		;;
 esac
diff --git a/test/test_indexer.py b/test/test_indexer.py
index 72b8c5b..cc8c9f7 100644
--- a/test/test_indexer.py
+++ b/test/test_indexer.py
@@ -56,10 +56,10 @@ class TestIndexer(tools.AxiTestBase):
         self.indexer._test_wrap_apt_cache(smallcache())
 
         # No other indexers are running, ensure lock succeeds
-        self.assert_(self.indexer.lock())
+        self.assertTrue(self.indexer.lock())
 
         # No index exists, so the indexer should decide it needs to run
-        self.assert_(self.indexer.setupIndexing())
+        self.assertTrue(self.indexer.setupIndexing())
 
         # Perform a rebuild
         self.indexer.rebuild()
@@ -76,10 +76,10 @@ class TestIndexer(tools.AxiTestBase):
         subprocess.check_call("apt-cache show apt libept-dev gedit > " + pkgfile, shell=True)
 
         # No other indexers are running, ensure lock succeeds
-        self.assert_(self.indexer.lock())
+        self.assertTrue(self.indexer.lock())
 
         # No index exists, so the indexer should decide it needs to run
-        self.assert_(self.indexer.setupIndexing())
+        self.assertTrue(self.indexer.setupIndexing())
 
         # Perform a rebuild
         self.indexer.rebuild([pkgfile])
@@ -97,8 +97,8 @@ class TestIndexer(tools.AxiTestBase):
         progress = axi.indexer.SilentProgress()
         pre_indexer = axi.indexer.Indexer(progress, True)
         pre_indexer._test_wrap_apt_cache(smallcache(["apt", "libept-dev", "gedit"]))
-        self.assert_(pre_indexer.lock())
-        self.assert_(pre_indexer.setupIndexing())
+        self.assertTrue(pre_indexer.lock())
+        self.assertTrue(pre_indexer.setupIndexing())
         pre_indexer.rebuild()
         pre_indexer = None
         curidx = open(axi.XAPIANINDEX).read()
@@ -110,12 +110,12 @@ class TestIndexer(tools.AxiTestBase):
         self.indexer._test_wrap_apt_cache(smallcache(["apt", "coreutils", "gedit"]))
 
         # No other indexers are running, ensure lock succeeds
-        self.assert_(self.indexer.lock())
+        self.assertTrue(self.indexer.lock())
 
         # An index exists the plugin modification timestamps are the same, so
         # we need to force the indexer to run
-        self.assert_(not self.indexer.setupIndexing())
-        self.assert_(self.indexer.setupIndexing(force=True))
+        self.assertTrue(not self.indexer.setupIndexing())
+        self.assertTrue(self.indexer.setupIndexing(force=True))
 
         # Perform a rebuild
         self.indexer.incrementalUpdate()
@@ -135,10 +135,10 @@ class TestIndexer(tools.AxiTestBase):
         self.indexer._test_wrap_apt_cache(smallcache())
 
         # No other indexers are running, ensure lock succeeds
-        self.assert_(self.indexer.lock())
+        self.assertTrue(self.indexer.lock())
 
         # No index exists, so the indexer should decide it needs to run
-        self.assert_(self.indexer.setupIndexing())
+        self.assertTrue(self.indexer.setupIndexing())
 
         # Perform an incremental rebuild, which should fall back on a normal
         # one
-- 
2.55.0
Technical Details
Message-ID: <O3Qid-elrv-9@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Robert August Vincent II <pillarsdotnet@gmail.com>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1155493: apt-xapian-index: test suite does not run: ./runtests collects Python's stdlib tests, and TestIndexer uses assert_ removed in 3.12
Date: Thu, 26 Nov 2026 23:40:01 +0100
Message-ID: <O3Qid-elrv-9@gated-at.bofh.it>
X-Original-To: submit@bugs.debian.org
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Thu Nov 26 22:37:10 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -0.547
Reply-To: Robert August Vincent II <pillarsdotnet@gmail.com>, 1155493@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: ilu@solydxk.com
X-Debian-Pr-Message: report 1155493
X-Debian-Pr-Package: apt-xapian-index
X-Debian-Pr-Keywords: patch upstream
X-Debian-Pr-Source: apt-xapian-index
X-Gm-Message-State: APuU4Z/Hv7qj2xWsfQj/ccyJrDaUEuLui2FuLVM3dICDZWvrfCRyPOXl
	w93UvWZDlX4kH9xFfjBOWiGxtblw36n4avjwsgD47NtC6JK3f2r9VHgYKsBXSqc=
X-Gm-Gg: AZFdTZeLOkr2h3x9YT/Lfx/OuZYanfdMSi/e2DVlDNJO9/MQq58YdyquHth/1Zlz25k
	9cJ1HzKwHIGVKrSSxW7mwWJvNwPXRpjh++/CQTfQfgeEre4YVCbROVr7VqcViyYkIvklQMFJPMU
	Bbu4MGZuo9azVFRAT+TgykWesO0ygUl4cRzaUGHvc/3Sc+tc5FuSuoDfKeVErhwkkDe1MJj+FIk
	Bs5gUhlc3CrY7aP81RvLewyQX8Z8TBSM3CGJPzwVgFG0lyVpVQp7tLtwnttgn45KS1YDIBnapmW
	mgrE3LfFzjCK3SwasTQBHUN9PZuWbHA6Sh5z7LJ5C3MeL4kvskGbFafnTLL+2rfVP6GyDwtf6g4
	Qk24DksA0d2omaMEzI3L1c+CLtF1R1lW4o96gbsoV2CHNSZFL/YiIp+x5mO0iqIbPFHkGAkfRNH
	ZKP1NQZ4TjB/QNAxK/QKwhGddjZPM1WuInvqo35PV0nuNENTXxPepliYfe3aZ8MkFGVYHtaRDp/
	zw2AIOYU462Jc8lWdEhs1slFqz4e6TJIxxbORZDfry0A62la/GSuOTpcKYHA72IGdKjHxjJE4ln
	92D3JemdBE2H2o5qCqvUTAezEnKH+lbg/oaiGuFJRWc/Jy++hLulAAo/i6fIK3AHRTJiREKPZzc
	n+yLO8EwZITzdI8oQVt6wS8tsDBmnI7WbaiJC4BUy0EuKmj3z7hrC2SIz2OutYHL4J30Jni+fFA
	XRr/aoNuJy1rAHqQg4B23hrts=
X-Received: by 2002:a05:690e:440c:b0:679:c12b:ec0c with SMTP id 956f58d0204a3-67df445eda4mr7015511d50.53.1795732500504;
        Thu, 26 Nov 2026 14:35:00 -0800 (PST)
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2005287
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 258
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Thu, 26 Nov 2026 17:34:59 -0500
X-Original-Message-ID: <6b08b413.68c022b.279af121@bobse16>