Accepting request 850728 from home:mcepl:branches:devel:languages:python

- Add two-basic-unit-tests.patch which includes two at least simple test
  patches (gh#certifi/python-certifi#137).

OBS-URL: https://build.opensuse.org/request/show/850728
OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-certifi?expand=0&rev=50
This commit is contained in:
Matej Cepl 2020-11-25 13:44:34 +00:00 committed by Git OBS Bridge
parent 3746aa922f
commit 970a8cea3c
4 changed files with 112 additions and 17 deletions

View File

@ -1,22 +1,30 @@
diff -ur certifi-2020.6.20.o/certifi/core.py certifi-2020.6.20/certifi/core.py ---
--- certifi-2020.6.20.o/certifi/core.py 2020-06-07 11:35:28.000000000 +0200 certifi/core.py | 54 +++++++++---------------------------------------------
+++ certifi-2020.6.20/certifi/core.py 2020-08-16 19:38:17.167625302 +0200 1 file changed, 9 insertions(+), 45 deletions(-)
@@ -5,56 +5,18 @@
--- a/certifi/core.py
+++ b/certifi/core.py
@@ -1,60 +1,24 @@
# -*- coding: utf-8 -*-
+import io
"""
certifi.py
~~~~~~~~~~ ~~~~~~~~~~
This module returns the installation location of cacert.pem or its contents. This module returns the installation location of cacert.pem or its contents.
-""" +
+Patched by openSUSE: return the system bundle
"""
-import os -import os
-try: -try:
- from importlib.resources import path as get_path, read_text - from importlib.resources import path as get_path, read_text
+Patched by openSUSE: return the system bundle
+"""
- _CACERT_CTX = None - _CACERT_CTX = None
- _CACERT_PATH = None - _CACERT_PATH = None
+def read_text(_module=None, _path=None, encoding="ascii"): +def read_text(_module=None, _path=None, encoding="ascii"):
+ with open(where(), "r", encoding=encoding) as data: + with io.open(where(), "r", encoding=encoding) as data:
+ return data.read() + return data.read()
- def where(): - def where():

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Wed Nov 25 11:41:29 UTC 2020 - Matej Cepl <mcepl@suse.com>
- Add two-basic-unit-tests.patch which includes two at least simple test
patches (gh#certifi/python-certifi#137).
------------------------------------------------------------------- -------------------------------------------------------------------
Sun Aug 16 17:45:09 UTC 2020 - Benjamin Greiner <code@bnavigator.de> Sun Aug 16 17:45:09 UTC 2020 - Benjamin Greiner <code@bnavigator.de>

View File

@ -25,10 +25,14 @@ License: MPL-2.0
Group: Development/Languages/Python Group: Development/Languages/Python
URL: https://github.com/certifi/python-certifi URL: https://github.com/certifi/python-certifi
Source: https://files.pythonhosted.org/packages/source/c/certifi/certifi-%{version}.tar.gz Source: https://files.pythonhosted.org/packages/source/c/certifi/certifi-%{version}.tar.gz
# PATCH-FIX-SUSE -- prefer SUSE certificates (only for use on SUSE platforms) # PATCH-FIX-SUSE -- prefer SUSE certificates
Patch0: python-certifi-shipped-requests-cabundle.patch Patch0: python-certifi-shipped-requests-cabundle.patch
# PATCH-FEATURE-UPSTREAM two-basic-unit-tests.patch gh#certifi/python-certifi#137 mcepl@suse.com
# Add at least primitive test suite (by bnavigator)
Patch1: two-basic-unit-tests.patch
BuildRequires: %{python_module setuptools} BuildRequires: %{python_module setuptools}
BuildRequires: ca-certificates BuildRequires: ca-certificates
BuildRequires: ca-certificates-mozilla
BuildRequires: fdupes BuildRequires: fdupes
BuildRequires: python-rpm-macros BuildRequires: python-rpm-macros
Requires: ca-certificates Requires: ca-certificates
@ -44,10 +48,7 @@ identity of TLS hosts. It has been extracted from the Requests project.
Note that on SUSE packages the used CA bundle is actually the system bundle Note that on SUSE packages the used CA bundle is actually the system bundle
%prep %prep
%setup -q -n certifi-%{version} %autosetup -p1 -n certifi-%{version}
%if 0%{?suse_version}
%patch0 -p1
%endif
%build %build
%python_build %python_build
@ -57,9 +58,7 @@ Note that on SUSE packages the used CA bundle is actually the system bundle
%{python_expand chmod +x %{buildroot}%{$python_sitelib}/certifi/core.py %{python_expand chmod +x %{buildroot}%{$python_sitelib}/certifi/core.py
sed -i "s|#!%{_bindir}/env python|#!%__$python|" %{buildroot}/%{$python_sitelib}/certifi/core.py sed -i "s|#!%{_bindir}/env python|#!%__$python|" %{buildroot}/%{$python_sitelib}/certifi/core.py
%if 0%{?suse_version}
rm %{buildroot}%{$python_sitelib}/certifi/cacert.pem rm %{buildroot}%{$python_sitelib}/certifi/cacert.pem
%endif
} }
%python_expand $python -m compileall %{buildroot}%{$python_sitelib}/certifi/ %python_expand $python -m compileall %{buildroot}%{$python_sitelib}/certifi/
@ -68,8 +67,7 @@ Note that on SUSE packages the used CA bundle is actually the system bundle
%python_expand %fdupes %{buildroot}%{$python_sitelib} %python_expand %fdupes %{buildroot}%{$python_sitelib}
%check %check
# There are no upstream unit tests https://github.com/certifi/python-certifi/issues/136 %pyunittest -v certifi.tests.test_certifi
# Please check that downstream packages like python-requests still build after an update of certifi
%files %{python_files} %files %{python_files}
%license LICENSE %license LICENSE

View File

@ -0,0 +1,83 @@
From 7d617ff9dddee73bde86b79c9aa2f1c98f19e339 Mon Sep 17 00:00:00 2001
From: Benjamin Greiner <code@bnavigator.de>
Date: Sun, 16 Aug 2020 20:17:39 +0200
Subject: [PATCH 1/2] add 2 basic unit tests
---
.github/workflows/python-package.yml | 40 +++++++++++++++++++++++++++++++++++
certifi/tests/__init__.py | 2 +
certifi/tests/test_certifi.py | 19 ++++++++++++++++
3 files changed, 61 insertions(+)
create mode 100644 certifi/tests/__init__.py
create mode 100755 certifi/tests/test_certifi.py
--- /dev/null
+++ b/certifi/tests/__init__.py
@@ -0,0 +1,2 @@
+# certifi.tests module
+
--- /dev/null
+++ b/certifi/tests/test_certifi.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+"""
+unit tests to make sure everything behaves as expected
+"""
+
+import os
+import unittest
+
+import certifi
+
+
+class TestCertifi(unittest.TestCase):
+ def test_cabundle_exists(self):
+ """Check that the reported bundle exists"""
+ self.assertTrue(os.path.exists(certifi.where()))
+
+ def test_read_contents(self):
+ """Check that the returned contents contain a certificate"""
+ self.assertIn("-----BEGIN CERTIFICATE-----", certifi.contents())
--- /dev/null
+++ b/.github/workflows/python-package.yml
@@ -0,0 +1,40 @@
+# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
+# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
+
+name: Python package
+
+on:
+ push:
+ branches: [ master ]
+ pull_request:
+ branches: [ master ]
+
+jobs:
+ build:
+
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ python-version: [3.5, 3.6, 3.7, 3.8]
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up Python ${{ matrix.python-version }}
+ uses: actions/setup-python@v2
+ with:
+ python-version: ${{ matrix.python-version }}
+ - name: Install test dependencies
+ run: |
+ python -m pip install --upgrade pip
+ pip install pytest
+ # pip install flake8 pytest
+ # if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
+ #- name: Lint with flake8
+ # run: |
+ # # stop the build if there are Python syntax errors or undefined names
+ # flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
+ # # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
+ # flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
+ - name: Test with pytest
+ run: |
+ pytest