From b9c759566b2ecddafc4730b47dfa3fc885f00a85 Mon Sep 17 00:00:00 2001 From: Cameron Porter Date: Mon, 1 Mar 2021 19:51:20 -0600 Subject: [PATCH 1/3] Add testing and support for python 3.9. Remove testtools as a test dependency. It's not used except for a version skip that is easy to replace. testtools still relies on unittest2, a python 2-ism that generates warnings in python 3.9. Fix the snapcraft release by updating to a newer snapcraft action that fixes the 'add-path' error. --- .github/workflows/release.yml | 46 +++++++------- .github/workflows/tests.yml | 108 ++++++++++++++++---------------- README.rst | 4 +- setup.py | 1 + tests/CLI/modules/user_tests.py | 5 +- tools/test-requirements.txt | 1 - tox.ini | 2 +- 7 files changed, 84 insertions(+), 83 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 36ef10414..9b244a86b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,23 +1,23 @@ -name: Release - -on: - release: - types: [published] - -jobs: - release: - runs-on: ubuntu-latest - strategy: - matrix: - arch: ['armhf','amd64','arm64','ppc64el','s390x','i386'] - steps: - - name: Install Snapcraft - uses: samuelmeuli/action-snapcraft@v1.1.1 - with: - snapcraft_token: ${{ secrets.snapcraft_token }} - - name: Push to stable - run: | - VERSION=`snapcraft list-revisions slcli --arch ${{ matrix.arch }} | grep "edge\*" | awk '{print $1}'` - echo Publishing $VERSION on ${{ matrix.arch }} - snapcraft release slcli $VERSION stable - +name: Release + +on: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-18.04 + strategy: + matrix: + arch: ['armhf','amd64','arm64','ppc64el','s390x','i386'] + steps: + - name: Install Snapcraft + uses: samuelmeuli/action-snapcraft@v1.2.0 + with: + snapcraft_token: ${{ secrets.snapcraft_token }} + - name: Push to stable + run: | + VERSION=`snapcraft list-revisions slcli --arch ${{ matrix.arch }} | grep "edge\*" | awk '{print $1}'` + echo Publishing $VERSION on ${{ matrix.arch }} + snapcraft release slcli $VERSION stable + diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7aa408ed8..7bc787791 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,54 +1,54 @@ -name: Tests - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] -jobs: - test: - 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@v1 - with: - python-version: ${{ matrix.python-version }} - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r tools/test-requirements.txt - - name: Tox Test - run: tox -e py - coverage: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r tools/test-requirements.txt - - name: Tox Coverage - run: tox -e coverage - analysis: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Set up Python - uses: actions/setup-python@v1 - with: - python-version: 3.8 - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install -r tools/test-requirements.txt - - name: Tox Analysis - run: tox -e analysis \ No newline at end of file +name: Tests + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.5,3.6,3.7,3.8,3.9] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tools/test-requirements.txt + - name: Tox Test + run: tox -e py + coverage: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tools/test-requirements.txt + - name: Tox Coverage + run: tox -e coverage + analysis: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v1 + with: + python-version: 3.9 + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r tools/test-requirements.txt + - name: Tox Analysis + run: tox -e analysis diff --git a/README.rst b/README.rst index 4f741a5d0..75e5d6f54 100644 --- a/README.rst +++ b/README.rst @@ -127,7 +127,7 @@ If you are using the library directly in python, you can do something like this. System Requirements ------------------- -* Python 3.5, 3.6, 3.7, or 3.8. +* Python 3.5, 3.6, 3.7, 3.8, or 3.9. * A valid SoftLayer API username and key. * A connection to SoftLayer's private network is required to use our private network API endpoints. @@ -150,6 +150,6 @@ Python Packages Copyright --------- -This software is Copyright (c) 2016-2019 SoftLayer Technologies, Inc. +This software is Copyright (c) 2016-2021 SoftLayer Technologies, Inc. See the bundled LICENSE file for more information. diff --git a/setup.py b/setup.py index 2591b055a..7bbc3ebe5 100644 --- a/setup.py +++ b/setup.py @@ -54,6 +54,7 @@ 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', ], diff --git a/tests/CLI/modules/user_tests.py b/tests/CLI/modules/user_tests.py index b6723a2b2..246a5b0a2 100644 --- a/tests/CLI/modules/user_tests.py +++ b/tests/CLI/modules/user_tests.py @@ -8,7 +8,6 @@ import sys import mock -import testtools from SoftLayer import testing @@ -168,10 +167,12 @@ def test_create_user_no_confirm(self, confirm_mock): result = self.run_command(['user', 'create', 'test', '-e', 'test@us.ibm.com', '-p', 'testword']) self.assertEqual(result.exit_code, 2) - @testtools.skipIf(sys.version_info < (3, 6), "Secrets module only exists in version 3.6+") @mock.patch('secrets.choice') @mock.patch('SoftLayer.CLI.formatting.confirm') def test_create_user_generate_password_36(self, confirm_mock, secrets): + if sys.version_info < (3, 6): + self.skipTest("Secrets module only exists in version 3.6+") + secrets.return_value = 'Q' confirm_mock.return_value = True result = self.run_command(['user', 'create', 'test', '-e', 'test@us.ibm.com', '-p', 'generate']) diff --git a/tools/test-requirements.txt b/tools/test-requirements.txt index d417e04c1..0f1ec684c 100644 --- a/tools/test-requirements.txt +++ b/tools/test-requirements.txt @@ -4,7 +4,6 @@ pytest pytest-cov mock sphinx -testtools ptable >= 0.9.2 click >= 7 requests >= 2.20.0 diff --git a/tox.ini b/tox.ini index c9b3b5e72..b1fa2c870 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py35,py36,py37,py38,pypy3,analysis,coverage,docs +envlist = py35,py36,py37,py38,py39,pypy3,analysis,coverage,docs [flake8] From f019f3dd68447b95aacce6978b86f21d2b72ddb3 Mon Sep 17 00:00:00 2001 From: Cameron Porter Date: Mon, 1 Mar 2021 20:12:20 -0600 Subject: [PATCH 2/3] Use testtools.SkipIf instead so that secrets mocking isn't broken for python 3.5. --- tests/CLI/modules/user_tests.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tests/CLI/modules/user_tests.py b/tests/CLI/modules/user_tests.py index 246a5b0a2..3693d32b5 100644 --- a/tests/CLI/modules/user_tests.py +++ b/tests/CLI/modules/user_tests.py @@ -6,6 +6,7 @@ """ import json import sys +import unittest import mock @@ -167,12 +168,10 @@ def test_create_user_no_confirm(self, confirm_mock): result = self.run_command(['user', 'create', 'test', '-e', 'test@us.ibm.com', '-p', 'testword']) self.assertEqual(result.exit_code, 2) + @unittest.SkipIf(sys.version_info < (3, 6), "Secrets module only exists in version 3.6+") @mock.patch('secrets.choice') @mock.patch('SoftLayer.CLI.formatting.confirm') def test_create_user_generate_password_36(self, confirm_mock, secrets): - if sys.version_info < (3, 6): - self.skipTest("Secrets module only exists in version 3.6+") - secrets.return_value = 'Q' confirm_mock.return_value = True result = self.run_command(['user', 'create', 'test', '-e', 'test@us.ibm.com', '-p', 'generate']) From 8d73349a740a9887ad7cc97acf2057b32aff58ea Mon Sep 17 00:00:00 2001 From: Cameron Porter Date: Mon, 1 Mar 2021 20:16:17 -0600 Subject: [PATCH 3/3] Fix casing --- tests/CLI/modules/user_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/CLI/modules/user_tests.py b/tests/CLI/modules/user_tests.py index 3693d32b5..2f4c1c978 100644 --- a/tests/CLI/modules/user_tests.py +++ b/tests/CLI/modules/user_tests.py @@ -168,7 +168,7 @@ def test_create_user_no_confirm(self, confirm_mock): result = self.run_command(['user', 'create', 'test', '-e', 'test@us.ibm.com', '-p', 'testword']) self.assertEqual(result.exit_code, 2) - @unittest.SkipIf(sys.version_info < (3, 6), "Secrets module only exists in version 3.6+") + @unittest.skipIf(sys.version_info < (3, 6), "Secrets module only exists in version 3.6+") @mock.patch('secrets.choice') @mock.patch('SoftLayer.CLI.formatting.confirm') def test_create_user_generate_password_36(self, confirm_mock, secrets):