python-certifi/two-basic-unit-tests.patch
2020-11-25 13:44:34 +00:00

84 lines
2.6 KiB
Diff

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