15
0

Accepting request 1166270 from devel:languages:python

- Add patch use-correct-assertion-methods.patch:
  * Use non-removed assertion methods.

- Switch build system from setuptools to pyproject.toml
  + Add python-pip and python-wheel to BuildRequires
  + Replace %python_build with %pyproject_wheel
  + Replace %python_install with %pyproject_install

- Update to 0.11.4
  * Changed bit-mapping for `httpx` and `fastapi` integrations
- Refresh patches for new version
  * opencensus-pr1002-remove-mock.patch
- Switch package to modern Python Stack on SLE-15
  * Add %{?sle15_python_module_pythons}
  * Drop %{?!python_module:%define python_module() python-%{**} python3-%{**}}

OBS-URL: https://build.opensuse.org/request/show/1166270
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/python-opencensus?expand=0&rev=6
This commit is contained in:
2024-04-09 14:47:45 +00:00
committed by Git OBS Bridge
6 changed files with 483 additions and 340 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,3 +0,0 @@
version https://git-lfs.github.com/spec/v1
oid sha256:b31d0a46ef88fc33d5c6013e7a2a51b9a51d9956a9cd2a9a2180d1eb3b05c5d9
size 325762

Binary file not shown.

View File

@@ -1,3 +1,28 @@
-------------------------------------------------------------------
Tue Apr 9 02:34:22 UTC 2024 - Steve Kowalik <steven.kowalik@suse.com>
- Add patch use-correct-assertion-methods.patch:
* Use non-removed assertion methods.
-------------------------------------------------------------------
Tue Mar 26 12:57:43 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Switch build system from setuptools to pyproject.toml
+ Add python-pip and python-wheel to BuildRequires
+ Replace %python_build with %pyproject_wheel
+ Replace %python_install with %pyproject_install
-------------------------------------------------------------------
Tue Mar 5 23:00:18 UTC 2024 - John Paul Adrian Glaubitz <adrian.glaubitz@suse.com>
- Update to 0.11.4
* Changed bit-mapping for `httpx` and `fastapi` integrations
- Refresh patches for new version
* opencensus-pr1002-remove-mock.patch
- Switch package to modern Python Stack on SLE-15
* Add %{?sle15_python_module_pythons}
* Drop %{?!python_module:%define python_module() python-%{**} python3-%{**}}
-------------------------------------------------------------------
Thu Oct 19 10:40:18 UTC 2023 - Markéta Machová <mmachova@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file
# spec file for package python-opencensus
#
# Copyright (c) 2023 SUSE LLC
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -16,7 +16,9 @@
#
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define repo_version 0.11.4-1.1.13
%{?sle15_python_module_pythons}
%global flavor @BUILD_FLAVOR@%{nil}
%if "%{flavor}" == "test"
%define psuffix -test
@@ -26,15 +28,19 @@
%bcond_with test
%endif
Name: python-opencensus%{psuffix}
Version: 0.11.3
Version: 0.11.4
Release: 0
Summary: A stats collection and distributed tracing framework
License: Apache-2.0
URL: https://github.com/census-instrumentation/opencensus-python
Source: https://github.com/census-instrumentation/opencensus-python/archive/v%{version}.tar.gz#/opencensus-python-%{version}-gh.tar.gz
Source: https://github.com/census-instrumentation/opencensus-python/archive/v%{repo_version}.tar.gz#/opencensus-python-%{repo_version}-gh.tar.gz
# PATCH-FIX-UPSTREAM opencensus-pr1002-remove-mock.patch -- gh#census-instrumentation/opencensus-python#1002
Patch0: opencensus-pr1002-remove-mock.patch
# PATCH-FIX-UPSTREAM gh#census-instrumentation/opencensus-python#1243
Patch1: use-correct-assertion-methods.patch
BuildRequires: %{python_module pip}
BuildRequires: %{python_module setuptools}
BuildRequires: %{python_module wheel}
BuildRequires: fdupes
BuildRequires: python-rpm-macros
Requires: python-google-api-core < 3.0.0
@@ -43,9 +49,7 @@ Requires: python-opencensus-context >= 0.1.3
Requires: python-six >= 1.16
BuildArch: noarch
%if %{with test}
BuildRequires: %{python_module google-api-core >= 1.0.0}
BuildRequires: %{python_module opencensus >= %{version}}
BuildRequires: %{python_module opencensus-context >= 0.1.1}
BuildRequires: %{python_module opencensus = %{version}}
BuildRequires: %{python_module pytest}
BuildRequires: %{python_module retrying}
%endif
@@ -59,16 +63,16 @@ and collect performance stats. This repository contains Python related
utilities and supporting software needed by OpenCensus.
%prep
%autosetup -p1 -n opencensus-python-%{version}
%autosetup -p1 -n opencensus-python-%{repo_version}
# do not hardcode versions
sed -i -e 's:==:>=:g' setup.py
%build
%python_build
%pyproject_wheel
%install
%if !%{with test}
%python_install
%pyproject_install
# add ext infrastructure
%python_expand mkdir %{buildroot}%{$python_sitelib}/opencensus/ext/
%python_expand cp %{buildroot}%{$python_sitelib}/opencensus/__init__* %{buildroot}%{$python_sitelib}/opencensus/ext
@@ -89,7 +93,7 @@ donttest="TestGetExporterThreadPeriodic and (test_multiple_producers or test_thr
%doc CHANGELOG.md README.rst
%license LICENSE
%{python_sitelib}/opencensus
%{python_sitelib}/opencensus-%{version}*-info
%{python_sitelib}/opencensus-%{version}.dist-info
%endif
%changelog

View File

@@ -0,0 +1,190 @@
From 9fc5f15d51ed33fa3d34592912c9e40c0756fd43 Mon Sep 17 00:00:00 2001
From: Steve Kowalik <steven@wedontsleep.org>
Date: Tue, 9 Apr 2024 12:23:25 +1000
Subject: [PATCH] Use non-deprecated assertion methods
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 #1242
---
.../tests/test_prometheus_stats.py | 6 ++---
.../test_monitored_resource.py | 27 ++++++++++++-------
tests/unit/stats/test_aggregation_data.py | 12 ++++-----
tests/unit/stats/test_measurement_map.py | 8 +++---
4 files changed, 30 insertions(+), 23 deletions(-)
diff --git a/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py b/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py
index bc19b47ef..2b4e1c8c2 100644
--- a/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py
+++ b/contrib/opencensus-ext-prometheus/tests/test_prometheus_stats.py
@@ -229,7 +229,7 @@ def test_collector_to_metric_invalid_dist(self):
collector.register_view(view)
desc = collector.registered_views[list(REGISTERED_VIEW)[0]]
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
ValueError,
'unsupported aggregation type <class \'mock.mock.Mock\'>'):
collector.to_metric(desc=desc, tag_values=[None], agg_data=agg)
@@ -278,8 +278,8 @@ def test_collector_collect_with_none_label_value(self):
class TestPrometheusStatsExporter(unittest.TestCase):
def test_exporter_constructor_no_namespace(self):
- with self.assertRaisesRegexp(ValueError,
- 'Namespace can not be empty string.'):
+ with self.assertRaisesRegex(ValueError,
+ 'Namespace can not be empty string.'):
prometheus.new_stats_exporter(prometheus.Options())
def test_emit(self):
diff --git a/tests/unit/common/monitored_resource_util/test_monitored_resource.py b/tests/unit/common/monitored_resource_util/test_monitored_resource.py
index 38a1fe4b5..a97038841 100644
--- a/tests/unit/common/monitored_resource_util/test_monitored_resource.py
+++ b/tests/unit/common/monitored_resource_util/test_monitored_resource.py
@@ -102,9 +102,11 @@ def test_gcp_gce_monitored_resource(self, gcp_md_mock):
with mock_gce_env():
resource = monitored_resource.get_instance()
self.assertEqual(resource.get_type(), 'mock_resource_type')
- self.assertDictContainsSubset(
- {'mock_label_key': 'mock_label_value'}, resource.get_labels())
- self.assertDictContainsSubset(mocked_labels, resource.get_labels())
+ self.assertGreaterEqual(
+ resource.get_labels().items(),
+ {'mock_label_key': 'mock_label_value'}.items())
+ self.assertGreaterEqual(
+ resource.get_labels().items(), mocked_labels.items())
@mock.patch('opencensus.common.monitored_resource.monitored_resource'
'.gcp_metadata_config.GcpMetadataConfig')
@@ -130,16 +132,19 @@ def test_gcp_k8s_monitored_resource(self, gcp_md_mock):
gcp_md_mock.get_attribute.assert_called_once_with(cluster_name_key)
self.assertEqual(r1.get_type(), 'k8s_container')
- self.assertDictContainsSubset(mocked_labels, r1.get_labels())
+ self.assertGreaterEqual(
+ r1.get_labels().items(), mocked_labels.items())
with mock_oc_env():
with mock_k8s_env():
r2 = monitored_resource.get_instance()
self.assertEqual(r1.get_type(), 'k8s_container')
- self.assertDictContainsSubset(mocked_labels, r1.get_labels())
- self.assertDictContainsSubset(
- {'mock_label_key': 'mock_label_value'}, r2.get_labels())
+ self.assertGreaterEqual(
+ r1.get_labels().items(), mocked_labels.items())
+ self.assertGreaterEqual(
+ r2.get_labels().items(),
+ {'mock_label_key': 'mock_label_value'}.items())
@mock.patch('opencensus.common.monitored_resource.monitored_resource'
'.aws_identity_doc_utils.AwsIdentityDocumentUtils')
@@ -163,9 +168,11 @@ def test_aws_monitored_resource(self, aws_md_mock):
with mock_aws_env():
resource = monitored_resource.get_instance()
self.assertEqual(resource.get_type(), 'mock_resource_type')
- self.assertDictContainsSubset(
- {'mock_label_key': 'mock_label_value'}, resource.get_labels())
- self.assertDictContainsSubset(mocked_labels, resource.get_labels())
+ self.assertGreaterEqual(
+ resource.get_labels().items(),
+ {'mock_label_key': 'mock_label_value'}.items())
+ self.assertGreaterEqual(
+ resource.get_labels().items(), mocked_labels.items())
def test_k8s_environment(self):
patch = mock.patch.dict(os.environ,
diff --git a/tests/unit/stats/test_aggregation_data.py b/tests/unit/stats/test_aggregation_data.py
index d1870f2c9..d009b91a2 100644
--- a/tests/unit/stats/test_aggregation_data.py
+++ b/tests/unit/stats/test_aggregation_data.py
@@ -295,15 +295,15 @@ def test_exemplar(self):
def test_exemplar_null_attachments(self):
timestamp = time.time()
- with self.assertRaisesRegexp(TypeError,
- 'attachments should not be empty'):
+ with self.assertRaisesRegex(TypeError,
+ 'attachments should not be empty'):
aggregation_data_module.Exemplar(6, timestamp, None)
def test_exemplar_null_attachment_key(self):
timestamp = time.time()
attachment = {None: "one", "Two": "two"}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
@@ -312,7 +312,7 @@ def test_exemplar_null_attachment_value(self):
timestamp = time.time()
attachment = {"One": "one", "Two": None}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
@@ -321,7 +321,7 @@ def test_exemplar_int_attachment_key(self):
timestamp = time.time()
attachment = {1: "one", "Two": "two"}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
@@ -330,7 +330,7 @@ def test_exemplar_int_attachment_value(self):
timestamp = time.time()
attachment = {"One": "one", "Two": 2}
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
aggregation_data_module.Exemplar(6, timestamp, attachment)
diff --git a/tests/unit/stats/test_measurement_map.py b/tests/unit/stats/test_measurement_map.py
index 89add276b..44d41ee86 100644
--- a/tests/unit/stats/test_measurement_map.py
+++ b/tests/unit/stats/test_measurement_map.py
@@ -58,7 +58,7 @@ def test_put_attachment_none_key(self):
test_value = 'testValue'
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)
@@ -69,7 +69,7 @@ def test_put_attachment_none_value(self):
test_value = None
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)
@@ -80,7 +80,7 @@ def test_put_attachment_int_key(self):
test_value = 'testValue'
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment key should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)
@@ -91,7 +91,7 @@ def test_put_attachment_int_value(self):
test_value = 42
measurement_map = measurement_map_module.MeasurementMap(
measure_to_view_map=measure_to_view_map, attachments={})
- with self.assertRaisesRegexp(
+ with self.assertRaisesRegex(
TypeError,
'attachment value should not be empty and should be a string'):
measurement_map.measure_put_attachment(test_key, test_value)