#8179 Tests broken with python version < 3.7 (module 're' has no attribute 'Pattern')
Closed: fixed 4 years ago by rcritten. Opened 4 years ago by sorlov.

The problem: when the test suite test_integration/test_krbtpolicy.py is executed with python 3.6, it fails with the message:

    def assert_error(result, pattern, returncode=None):
        """
        Assert that ``result`` command failed and its stderr contains ``pattern``.
        ``pattern`` may be a ``str`` or a ``re.Pattern`` (regular expression).

        """
>       if isinstance(pattern, re.Pattern):
E       AttributeError: module 're' has no attribute 'Pattern'

This happens because of change in commit 3d779b4 (part of #8142) which changed function assert_error() in ipatests/pytest_ipa/integration/tasks.py

The following line was added: https://pagure.io/freeipa/blob/44fca092ead0316084d68917032e28e5cbb20ad4/f/ipatests/pytest_ipa/integration/tasks.py#_1591:

if isinstance(pattern, re.Pattern):

re.Pattern class was introduced in python 3.7.

The spec file does not specify minimal version of python3, so I suppose any version should be supported.


@ftweedal Can you have a look at the issue?

I suggest to replace isinstance(pattern, re.Pattern) with duck-typing if hasattr(pattern, "search"): # re pattern.

Metadata Update from @cheimes:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/4144
- Issue assigned to cheimes
- Issue set to the milestone: FreeIPA 4.8.5
- Issue tagged with: tests

4 years ago

Hi, @sorlov.
@cheimes mentioned the minimal supported Python's version for 4.8 branch as 3.6:
https://fedoraproject.org/wiki/Changes/FreeIPA_Python_2_Removal

master:

  • 10b62ad Make assert_error compatible with Python 3.6

ipa-4-8:

  • e9ed8e7 Make assert_error compatible with Python 3.6

Metadata Update from @rcritten:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

4 years ago

Login to comment on this ticket.

Metadata