mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-04 15:34:01 -07:00
[PR #7348/6c9713b3 backport][stable-7] Fix Python 3.12 unit tests (#7351)
Fix Python 3.12 unit tests (#7348)
* Re-enable Python 3.12 unit tests.
* Stop using deprecated alias.
* Stop using long deprecated subset comparison function.
* Avoid another alias.
* Fix name, add Python 2 compatibility.
* Properly make backwards compatible.
(cherry picked from commit 6c9713b36c
)
Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
551e5e4bd5
commit
3cb9b0fa91
9 changed files with 55 additions and 41 deletions
|
@ -12,6 +12,7 @@ from ansible_collections.community.general.plugins.callback.loganalytics import
|
|||
from datetime import datetime
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
class TestAzureLogAnalytics(unittest.TestCase):
|
||||
|
@ -27,6 +28,10 @@ class TestAzureLogAnalytics(unittest.TestCase):
|
|||
self.mock_host = Mock('MockHost')
|
||||
self.mock_host.name = 'myhost'
|
||||
|
||||
# Add backward compatibility
|
||||
if sys.version_info < (3, 2):
|
||||
self.assertRegex = self.assertRegexpMatches
|
||||
|
||||
@patch('ansible_collections.community.general.plugins.callback.loganalytics.datetime')
|
||||
@patch('ansible_collections.community.general.plugins.callback.loganalytics.open_url')
|
||||
def test_overall(self, open_url_mock, mock_datetime):
|
||||
|
@ -62,5 +67,5 @@ class TestAzureLogAnalytics(unittest.TestCase):
|
|||
args, kwargs = open_url_mock.call_args
|
||||
headers = kwargs['headers']
|
||||
|
||||
self.assertRegexpMatches(headers['Authorization'], r'^SharedKey 01234567-0123-0123-0123-01234567890a:.*=$')
|
||||
self.assertRegex(headers['Authorization'], r'^SharedKey 01234567-0123-0123-0123-01234567890a:.*=$')
|
||||
self.assertEqual(headers['Log-Type'], 'ansible_playbook')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue