Skip to content

Fix functional test suite on Python 3 and modern pytest - #883

Merged
dnzbk merged 1 commit into
nzbgetcom:developfrom
xbmc4lyfe:fix/functional-tests-python3
Jul 31, 2026
Merged

Fix functional test suite on Python 3 and modern pytest#883
dnzbk merged 1 commit into
nzbgetcom:developfrom
xbmc4lyfe:fix/functional-tests-python3

Conversation

@xbmc4lyfe

Copy link
Copy Markdown
Contributor

Description

Makes the functional test suite in tests/functional runnable again on current toolchains. The suite predates Python 3 (xrange, str-based base64, distutils) and pytest 5 (the removed pytest.config global), so it could not run at all; docs/FUNCTIONAL_TESTING.md carried a "broken" note.

Changes:

  • xrange()range(), with floor division at the xrange(sizemb / partmb) call sites
  • explicit encode()/decode() around base64.standard_b64encode so the XML-RPC append call keeps sending the base64 text as a string parameter
  • check_config is now a session-scoped fixture using request.config, replacing the pytest.config global and the pytest.check_config namespace injection; prepare_testdata fixtures read ini values via request.config
  • --hold looked up through the stored pytest session
  • distutils.spawn.find_executableshutil.which (distutils was removed in Python 3.12)
  • Python 2 xmlrpclib import fallback dropped
  • Nzbget.clear() wraps range() in list()xmlrpc.client cannot marshal a range object
  • docs/FUNCTIONAL_TESTING.md refreshed: "broken" note removed, py.testpytest (the py.test entry point was removed in pytest 8), missing --hold example added

AI assistance

  • This PR involved AI assistance (see AI Policy)

Claude Code was used to implement the changes and run the verification below.

Lib changes

None.

Testing

Full suite run per docs/FUNCTIONAL_TESTING.md against 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 nested download/conftest.py were verified to work under a bare pytest invocation.

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 dnzbk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this - verified locally and every failure matches the pre-existing expectation drift catalogued in #882. Nothing new introduced. The suite is runnable again, which is the important part.

@dnzbk
dnzbk merged commit 7fa6bc0 into nzbgetcom:develop Jul 31, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Functional tests: 10 tests fail with outdated expectations against current NZBGet behavior

2 participants