Skip to content

Fix the warnings the test suite emits at their source - #938

Open
marlon-costa-dc wants to merge 2 commits into
python-rope:masterfrom
marlon-costa-dc:pr/test-suite-warnings
Open

marlon-costa-dc wants to merge 2 commits into
python-rope:masterfrom
marlon-costa-dc:pr/test-suite-warnings

Conversation

@marlon-costa-dc

Copy link
Copy Markdown
Contributor

Summary

The test suite emitted warnings on every run (DeprecationWarning, ResourceWarning, SyntaxWarning, and fork-with-threads warnings). Under -W error, 855 tests failed and 475 errored. This fixes each warning at its source:

  • Project no longer calls the deprecated _init_source_folders path.
  • AutoImport closes every sqlite connection it opens, and its cache workers start with forkserver/spawn instead of forking a threaded process.
  • datetime.utcnow() is replaced by datetime.now(timezone.utc).
  • Tests close the files and connections they open, use raw strings for regexes, assert expected warnings with assertWarns, and find a compiled stdlib module instead of assuming _sqlite3 has a __file__.

Evidence

pytest ropetest -n 8 -W error: 2159 passed, 7 skipped, 5 xfailed, 0 warnings (serial runs also pass).

🤖 Generated with Claude Code

@codecov

codecov Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.84946% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.42%. Comparing base (1f102bb) to head (5aa9777).

Files with missing lines Patch % Lines
ropetest/contrib/autoimport/conftest.py 87.50% 1 Missing ⚠️
ropetest/testutils.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #938      +/-   ##
==========================================
- Coverage   95.43%   95.42%   -0.02%     
==========================================
  Files         134      134              
  Lines       26843    26880      +37     
==========================================
+ Hits        25618    25649      +31     
- Misses       1225     1231       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

marlon-costa-dc and others added 2 commits November 8, 2026 19:42
Running the suite with `-W error` failed 855 tests and errored 475. Each
warning had a real cause:

- `Project.__init__` called its own `_init_source_folders`, which is marked
  deprecated, so every `Project()` warned. Its body is inlined in the only
  caller and the private method is removed.
- `libutils.path_relative_to_project_root` called the deprecated public
  `relative`. Both now share a private `_relative`.
- `AutoImport.close()` closed only the calling thread's connection. Each
  thread opens its own, so connections from worker threads leaked. Every
  connection is now registered and closed. Connections are created with
  `check_same_thread=False` so close() may close them.
- The autoimport process pools forked a multi-threaded process
  (DeprecationWarning: use of fork() may lead to deadlocks). Workers now
  start from `forkserver`, the POSIX default since Python 3.14, or from
  `spawn` where it is not available.
- `datetime.utcnow()` is replaced by `datetime.now(timezone.utc)`.
- `testutils.time_limit` returned a decorator factory instead of a
  decorator when not running under pytest's main process (e.g. xdist
  workers). The decorated test was replaced and never ran.
- Tests: close the files, sqlite connections and AutoImport objects they
  open; pass `memory=` explicitly instead of relying on the deprecated
  default; assert that deprecated JobSet getters warn
  (`assertWarns`) instead of letting them warn; use raw strings for regex
  messages; discover a stdlib extension module from the import system for
  `compiled_lib` (python-build-standalone links `_sqlite3` statically).

Result on Python 3.13: 2159 passed, 0 warnings, both serially and with
pytest-xdist, and `-W error` passes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wrapper now delegates to _relative; the test asserts it warns and
returns the same project-relative path as path_relative_to_project_root.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mcepl
mcepl force-pushed the pr/test-suite-warnings branch from 36f8c69 to 5aa9777 Compare November 8, 2026 18:42

This branch has not been deployed

No deployments
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.

1 participant