Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testsuite fails on Python 3.12 #1242

Open
glaubitz opened this issue Mar 6, 2024 · 0 comments · May be fixed by #1243
Open

Testsuite fails on Python 3.12 #1242

glaubitz opened this issue Mar 6, 2024 · 0 comments · May be fixed by #1243
Labels

Comments

@glaubitz
Copy link

glaubitz commented Mar 6, 2024

On Python 3.12, the testsuite fails with the following tests:

[   31s] =========================== short test summary info ============================
[   31s] FAILED tests/unit/common/monitored_resource_util/test_monitored_resource.py::TestMonitoredResource::test_aws_monitored_resource
[   31s] FAILED tests/unit/common/monitored_resource_util/test_monitored_resource.py::TestMonitoredResource::test_gcp_gce_monitored_resource
[   31s] FAILED tests/unit/common/monitored_resource_util/test_monitored_resource.py::TestMonitoredResource::test_gcp_k8s_monitored_resource
[   31s] FAILED tests/unit/stats/test_aggregation_data.py::TestDistributionAggregationData::test_exemplar_int_attachment_key
[   31s] FAILED tests/unit/stats/test_aggregation_data.py::TestDistributionAggregationData::test_exemplar_int_attachment_value
[   31s] FAILED tests/unit/stats/test_aggregation_data.py::TestDistributionAggregationData::test_exemplar_null_attachment_key
[   31s] FAILED tests/unit/stats/test_aggregation_data.py::TestDistributionAggregationData::test_exemplar_null_attachment_value
[   31s] FAILED tests/unit/stats/test_aggregation_data.py::TestDistributionAggregationData::test_exemplar_null_attachments
[   31s] FAILED tests/unit/stats/test_measurement_map.py::TestMeasurementMap::test_put_attachment_int_key
[   31s] FAILED tests/unit/stats/test_measurement_map.py::TestMeasurementMap::test_put_attachment_int_value
[   31s] FAILED tests/unit/stats/test_measurement_map.py::TestMeasurementMap::test_put_attachment_none_key
[   31s] FAILED tests/unit/stats/test_measurement_map.py::TestMeasurementMap::test_put_attachment_none_value
[   31s] ========== 12 failed, 535 passed, 2 deselected, 94 warnings in 4.26s ===========

One of the test failures looks like this:

[   24s] ______________ TestMonitoredResource.test_aws_monitored_resource _______________
[   24s] 
[   24s] self = <test_monitored_resource.TestMonitoredResource testMethod=test_aws_monitored_resource>
[   24s] aws_md_mock = <MagicMock name='AwsIdentityDocumentUtils' id='140226359062464'>
[   24s] 
[   24s]     @mock.patch('opencensus.common.monitored_resource.monitored_resource'
[   24s]                 '.aws_identity_doc_utils.AwsIdentityDocumentUtils')
[   24s]     def test_aws_monitored_resource(self, aws_md_mock):
[   24s]     
[   24s]         mocked_labels = {
[   24s]             'instance_id': 'i-1234567890abcdef0',
[   24s]             'aws_account': '123456789012',
[   24s]             'region': 'us-west-2'
[   24s]         }
[   24s]     
[   24s]         aws_md_mock.return_value = mock.Mock()
[   24s]         aws_md_mock.return_value.get_aws_metadata.return_value = mocked_labels
[   24s]     
[   24s]         with mock_aws_env():
[   24s]             resource = monitored_resource.get_instance()
[   24s]         self.assertEqual(resource.get_type(), 'aws_ec2_instance')
[   24s]         self.assertEqual(resource.get_labels(), mocked_labels)
[   24s]     
[   24s]         with mock_oc_env():
[   24s]             with mock_aws_env():
[   24s]                 resource = monitored_resource.get_instance()
[   24s]         self.assertEqual(resource.get_type(), 'mock_resource_type')
[   24s] >       self.assertDictContainsSubset(
[   24s]             {'mock_label_key': 'mock_label_value'}, resource.get_labels())
[   24s] E       AttributeError: 'TestMonitoredResource' object has no attribute 'assertDictContainsSubset'
[   24s] 
[   24s] tests/unit/common/monitored_resource_util/test_monitored_resource.py:169: AttributeError
@glaubitz glaubitz added the bug label Mar 6, 2024
s-t-e-v-e-n-k added a commit to s-t-e-v-e-n-k/opencensus-python that referenced this issue Apr 9, 2024
Both assertDictContainsSubset and assertRaisesRegexp have been
deprecated, and removed in Python 3.12. Use assertGreaterEqual on the
dictionary items to compare dictionaries instead of
assertDictContainsSubset.

Fixes census-instrumentation#1242
@s-t-e-v-e-n-k s-t-e-v-e-n-k linked a pull request Apr 9, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant