Conversation
Includes 3.11 in our feature tests. Adds the continue-on-error key to bypass Windows failures until lxml/lxml 356 is resolved.
Because class paths are used in Task definitions we go into import
contortions to preserve them[^1]. 3.11 includes an update that replaces
`unittest.mock._importer` with `pkgutil.resolve_name`, breaking
mock.patch in several tests. For example:
```python-console
Python 3.11.0 (main, Nov 29 2022, 08:46:07) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> clspth = "cumulusci.tasks.salesforce.Deploy.__call__"
>>> import pkgutil
>>> getter = lambda: pkgutil.resolve_name(clspth)
>>> target = getter()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 1, in <lambda>
File "/Users/jestevez/.pyenv/versions/3.11.0/lib/python3.11/pkgutil.py", line 715, in resolve_name
result = getattr(result, p)
^^^^^^^^^^^^^^^^^^
AttributeError: module 'cumulusci.tasks.salesforce.Deploy' has no attribute '__call__'. Did you mean: '__file__'?
>>> # However
>>> from cumulusci.tasks.salesforce import Deploy
>>> getattr(Deploy, '__call__')
<function BaseTask.__call__ at 0x1113b7560>
```
Updating our patches to point at the right namespace works for most of
the mocks on 3.8+.
[^1]: Read "contortions" as "I don't understand them."
Python 3.11 removed pathlib._Accessor in python/cpython 25701. This broke our patch when it replaced a call to `os.getcwd()` with `Path.cwd()` in `Path.absolute()`. As a classmethod `Path.cwd()` receives the class as its implicit first argument meaning we can have 0 or 1 arguments.
The behavior of string enums has changed in 3.11 [what's new]: > Changed Enum.__format__() (the default for format(), str.format() and > f-strings) of enums with mixed-in types (e.g. int, str) to also include > the class name in the output, not just the member’s key. This matches > the existing behavior of enum.Enum.__str__(), returning e.g. > 'AnEnum.MEMBER' for an enum AnEnum(str, Enum) instead of just 'MEMBER'. This almost certainly explains the packaging bugs we've seen. [what's new]: https://docs.python.org/3.11/whatsnew/3.11.html#enum
TheBitShepherd
approved these changes
Dec 7, 2022
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.
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." ↩