You've already forked community.general
mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-29 07:41:16 +03:00
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.
This commit is contained in:
@ -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')
|
||||
|
Reference in New Issue
Block a user