diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 975a5af..7c6e89f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -10,6 +10,10 @@ jobs: run: name: "tests & coverage" runs-on: macos-latest + strategy: + matrix: + python-version: [3.8] + env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }} CODACY_PROJECT_TOKEN: ${{ secrets.CODACY_PROJECT_TOKEN }} @@ -19,7 +23,7 @@ jobs: - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: - python-version: 3.8 + python-version: ${{ matrix.python-version }} - name: Install test dependencies run: | diff --git a/tests/conftest.py b/tests/conftest.py index e482ccf..da9ac77 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,7 +11,6 @@ """Common pytest fixtures.""" - from contextlib import contextmanager import os from shutil import rmtree diff --git a/tests/test_background.py b/tests/test_background.py index 7040cb4..03b98f9 100644 --- a/tests/test_background.py +++ b/tests/test_background.py @@ -11,7 +11,6 @@ """Unit tests for :mod:`workflow.background`.""" - import os from time import sleep diff --git a/tests/test_notify.py b/tests/test_notify.py index 99b20cb..704d612 100644 --- a/tests/test_notify.py +++ b/tests/test_notify.py @@ -11,7 +11,6 @@ """Unit tests for notifications.""" - import hashlib import logging import os diff --git a/tests/test_util_atomic.py b/tests/test_util_atomic.py index f3f46d5..4a6df16 100644 --- a/tests/test_util_atomic.py +++ b/tests/test_util_atomic.py @@ -11,7 +11,6 @@ """Unit tests for :func:`~workflow.util.atomic_writer`.""" - import json import os diff --git a/tests/test_util_lockfile.py b/tests/test_util_lockfile.py index b02aa28..17294c6 100644 --- a/tests/test_util_lockfile.py +++ b/tests/test_util_lockfile.py @@ -11,7 +11,6 @@ """Test LockFile functionality.""" - from collections import namedtuple from multiprocessing import Pool import os diff --git a/tests/test_util_uninterruptible.py b/tests/test_util_uninterruptible.py index 56b8a1a..d4a0710 100644 --- a/tests/test_util_uninterruptible.py +++ b/tests/test_util_uninterruptible.py @@ -11,7 +11,6 @@ """Unit tests for ``uninterruptible`` decorator.""" - import os import signal diff --git a/tests/test_web.py b/tests/test_web.py index fc5a171..a071fcb 100644 --- a/tests/test_web.py +++ b/tests/test_web.py @@ -344,12 +344,15 @@ def test_file_upload_without_form_data(self): def test_file_upload_with_unicode(self): """File upload with Unicode contents is converted to bytes""" url = HTTPBIN_URL + '/post' + content = 'Hére ïs søme ÜÑÎÇÒDÈ™' files = {'file': {'filename': 'cönfüsed.txt', - 'content': 'Hére ïs søme ÜÑÎÇÒDÈ™' + 'content': content }} r = web.post(url, files=files) self.assertEqual(r.status_code, 200) data = r.json() + bindata = data['files']['file'] + self.assertEqual(bindata, content) def test_json_encoding(self): """JSON decoded correctly""" diff --git a/tests/test_web_http_encoding.py b/tests/test_web_http_encoding.py index de69ef4..76b0cf1 100644 --- a/tests/test_web_http_encoding.py +++ b/tests/test_web_http_encoding.py @@ -11,7 +11,6 @@ """HTTP unit tests.""" - import os import pytest diff --git a/tests/test_workflow.py b/tests/test_workflow.py index 8afe0b9..d4c6475 100644 --- a/tests/test_workflow.py +++ b/tests/test_workflow.py @@ -11,7 +11,6 @@ """Unit tests for :mod:`workflow.Workflow`.""" - import logging import os import sys diff --git a/tests/test_workflow3.py b/tests/test_workflow3.py index 9ccf88b..dd604eb 100644 --- a/tests/test_workflow3.py +++ b/tests/test_workflow3.py @@ -11,7 +11,6 @@ """Test Workflow3 feedback.""" - import json import os from io import StringIO diff --git a/tests/test_workflow_encoding.py b/tests/test_workflow_encoding.py index 88371bc..c9e85bf 100644 --- a/tests/test_workflow_encoding.py +++ b/tests/test_workflow_encoding.py @@ -7,7 +7,6 @@ """Unit tests for serializers.""" - import pytest diff --git a/tests/test_workflow_env.py b/tests/test_workflow_env.py index bc51066..2be8bc9 100644 --- a/tests/test_workflow_env.py +++ b/tests/test_workflow_env.py @@ -7,7 +7,6 @@ """Unit tests for environment/info.plist.""" - import logging import os diff --git a/tests/test_workflow_files.py b/tests/test_workflow_files.py index b4834e1..a468c5d 100644 --- a/tests/test_workflow_files.py +++ b/tests/test_workflow_files.py @@ -7,7 +7,6 @@ """Unit tests for Workflow directory & file APIs.""" - import json import os import time diff --git a/tests/test_workflow_filter.py b/tests/test_workflow_filter.py index 1dc64da..848c6e6 100644 --- a/tests/test_workflow_filter.py +++ b/tests/test_workflow_filter.py @@ -7,7 +7,6 @@ """Unit tests for :meth:`workflow.Workflow.filter`.""" - import pytest from workflow.workflow import ( diff --git a/tests/test_workflow_import.py b/tests/test_workflow_import.py index cc749e8..db11d04 100644 --- a/tests/test_workflow_import.py +++ b/tests/test_workflow_import.py @@ -7,7 +7,6 @@ """Unit tests for sys.path manipulation.""" - import os import sys diff --git a/tests/test_workflow_keychain.py b/tests/test_workflow_keychain.py index f24d709..07e973a 100644 --- a/tests/test_workflow_keychain.py +++ b/tests/test_workflow_keychain.py @@ -7,7 +7,6 @@ """Unit tests for Keychain API.""" - import pytest from workflow.workflow import PasswordNotFound, KeychainError diff --git a/tests/test_workflow_magic.py b/tests/test_workflow_magic.py index 4f514dd..b193703 100644 --- a/tests/test_workflow_magic.py +++ b/tests/test_workflow_magic.py @@ -11,7 +11,6 @@ """Unit tests for magic arguments.""" - import os import pytest diff --git a/tests/test_workflow_magic_alfred2.py b/tests/test_workflow_magic_alfred2.py index 2869853..211eae3 100644 --- a/tests/test_workflow_magic_alfred2.py +++ b/tests/test_workflow_magic_alfred2.py @@ -7,7 +7,6 @@ """Unit tests for Alfred 2 magic argument handling.""" - import pytest from workflow import Workflow diff --git a/tests/test_workflow_run.py b/tests/test_workflow_run.py index 8e37657..1204dc3 100644 --- a/tests/test_workflow_run.py +++ b/tests/test_workflow_run.py @@ -7,7 +7,6 @@ """Unit tests for Workflow.run.""" - from io import StringIO import sys diff --git a/tests/test_workflow_serializers.py b/tests/test_workflow_serializers.py index 868721a..adc65e8 100644 --- a/tests/test_workflow_serializers.py +++ b/tests/test_workflow_serializers.py @@ -11,7 +11,6 @@ """Unit tests for serializer classes.""" - import os import pytest diff --git a/tests/test_workflow_settings.py b/tests/test_workflow_settings.py index 9721129..190e0d2 100644 --- a/tests/test_workflow_settings.py +++ b/tests/test_workflow_settings.py @@ -11,7 +11,6 @@ """Unit tests for Workflow.settings API.""" - import json import os import shutil diff --git a/tests/test_workflow_update.py b/tests/test_workflow_update.py index 7a64d5c..91fba29 100644 --- a/tests/test_workflow_update.py +++ b/tests/test_workflow_update.py @@ -11,7 +11,6 @@ """Unit tests for Workflow's update API.""" - from contextlib import contextmanager import os @@ -91,13 +90,19 @@ def update(wf): with fakeresponse(httpserver, RELEASES_JSON, HTTP_HEADERS_JSON): with ctx() as (wf, c): wf.run(update) - assert c.cmd == ['/usr/bin/python3', '-m', 'workflow.background', '__workflow_update_check'] + assert c.cmd == [ + '/usr/bin/python3', '-m', 'workflow.background', + '__workflow_update_check' + ] update_settings = UPDATE_SETTINGS.copy() update_settings['prereleases'] = True with ctx(update_settings=update_settings) as (wf, c): wf.run(update) - assert c.cmd == ['/usr/bin/python3', '-m', 'workflow.background', '__workflow_update_check'] + assert c.cmd == [ + '/usr/bin/python3', '-m', 'workflow.background', + '__workflow_update_check' + ] def test_install_update(httpserver, alfred4): @@ -114,7 +119,10 @@ def fake(wf): print('Magic update command : {0!r}'.format(c.cmd)) - assert c.cmd == ['/usr/bin/python3', '-m', 'workflow.background', '__workflow_update_install'] + assert c.cmd == [ + '/usr/bin/python3', '-m', 'workflow.background', + '__workflow_update_install' + ] update_settings = UPDATE_SETTINGS.copy() del update_settings['version'] @@ -161,7 +169,10 @@ def fake(wf): print('Magic update command : {!r}'.format(c.cmd)) - assert c.cmd == ['/usr/bin/python3', '-m', 'workflow.background', '__workflow_update_install'] + assert c.cmd == [ + '/usr/bin/python3', '-m', 'workflow.background', + '__workflow_update_install' + ] with env(alfred_workflow_version='v10.0-beta'): update_settings = UPDATE_SETTINGS.copy() diff --git a/tests/test_workflow_versions.py b/tests/test_workflow_versions.py index dc55125..81f0b41 100644 --- a/tests/test_workflow_versions.py +++ b/tests/test_workflow_versions.py @@ -7,7 +7,6 @@ """Unit tests for workflow version determination.""" - import pytest from workflow.update import Version diff --git a/tests/test_workflow_xml.py b/tests/test_workflow_xml.py index 245c534..832bb07 100644 --- a/tests/test_workflow_xml.py +++ b/tests/test_workflow_xml.py @@ -11,7 +11,6 @@ """Unit tests for Workflow's XML feedback generation.""" - from contextlib import contextmanager from io import StringIO import sys diff --git a/tests/util.py b/tests/util.py index ab59cb1..edd8bd0 100644 --- a/tests/util.py +++ b/tests/util.py @@ -11,7 +11,6 @@ """Stuff used in multiple tests.""" - from io import StringIO import sys import os diff --git a/tox.ini b/tox.ini index 9b69742..228267e 100644 --- a/tox.ini +++ b/tox.ini @@ -20,8 +20,15 @@ usedevelop = true deps = -r requirements-test.txt coverage +commands = + ./run-tests.sh -commands = ./run-tests.sh +[testenv:lint] +usedevelop = true +deps = + -r requirements-test.txt +commands = + ./run-tests.sh -l [flake8] builtins = unicode