Fix unit tests on Python 3.11 #3456
Merged
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.
Adds 3.11 to feature test workflows and includes the following changes to get them to pass:
Update enum assert for 3.11
The behavior of string enums has changed in 3.11 what's new:
Update create_task_fixture for 3.11
Python 3.11 removed pathlib._Accessor in bpo-43012: remove
pathlib._Accessorpython/cpython#25701. Thisbroke our patch when it replaced a call to
os.getcwd()withPath.cwd()inPath.absolute(). As a classmethodPath.cwd()receives the class as its implicit first argument meaning we can have 0
or 1 arguments.
Update mock.patch namespaces for 3.11
Because class paths are used in Task definitions we go into import
contortions to preserve them1. 3.11 includes an update that replaces
unittest.mock._importerwithpkgutil.resolve_name, breakingmock.patch in several tests. For example:
Updating our patches to point at the right namespace works for most of
the mocks on 3.8+.
Footnotes
Read "contortions" as "I don't understand them." ↩