Fix functional test suite on Python 3 and modern pytest - #883
Merged
Conversation
The functional test suite predates Python 3 and no longer ran on current toolchains: - xrange() was removed in Python 3; use range(), and switch the xrange(sizemb / partmb) call sites to floor division since '/' produces a float on Python 3 - base64.standard_b64encode() takes and returns bytes on Python 3; encode/decode explicitly so the XML-RPC append call keeps sending the base64 text as a string parameter - the pytest.config global was removed in pytest 5; turn check_config into a session-scoped fixture using request.config (replacing the pytest.check_config namespace injection) and read ini values in the prepare_testdata fixtures via request.config - look up the --hold option through the stored pytest session - distutils was removed in Python 3.12; replace distutils.spawn.find_executable with shutil.which - drop the Python 2 xmlrpclib import fallback - Nzbget.clear() passed a range object to xmlrpc.client, which cannot marshal it; wrap it in list() Also refresh docs/FUNCTIONAL_TESTING.md: drop the "tests are broken" note, replace the py.test spelling removed in pytest 8 with pytest, fix a Windows-only path example and add the missing --hold command example. Signed-off-by: xbmc4lyfe <273732874+xbmc4lyfe@users.noreply.github.com>
dnzbk
self-requested a review
July 31, 2026 10:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Makes the functional test suite in
tests/functionalrunnable again on current toolchains. The suite predates Python 3 (xrange, str-basedbase64,distutils) and pytest 5 (the removedpytest.configglobal), so it could not run at all;docs/FUNCTIONAL_TESTING.mdcarried a "broken" note.Changes:
xrange()→range(), with floor division at thexrange(sizemb / partmb)call sitesencode()/decode()aroundbase64.standard_b64encodeso the XML-RPCappendcall keeps sending the base64 text as a string parametercheck_configis now a session-scoped fixture usingrequest.config, replacing thepytest.configglobal and thepytest.check_confignamespace injection;prepare_testdatafixtures read ini values viarequest.config--holdlooked up through the stored pytest sessiondistutils.spawn.find_executable→shutil.which(distutils was removed in Python 3.12)xmlrpclibimport fallback droppedNzbget.clear()wrapsrange()inlist()—xmlrpc.clientcannot marshal a range objectdocs/FUNCTIONAL_TESTING.mdrefreshed: "broken" note removed,py.test→pytest(thepy.testentry point was removed in pytest 8), missing--holdexample addedAI assistance
Claude Code was used to implement the changes and run the verification below.
Lib changes
None.
Testing
Full suite run per
docs/FUNCTIONAL_TESTING.mdagainst a Release build of develop (macOS arm64, Python 3.14.6, pytest 9.0.3, homebrew 7z/par2/unrar): 118 of 128 tests pass (9m25s). The 10 failures are pre-existing expectation drift against current NZBGet behavior — they fail identically in isolated reruns and are catalogued in #882. Test collection (pytest --collect-only) and the ini options from the nesteddownload/conftest.pywere verified to work under a barepytestinvocation.