From 36fd9632d6ad880b24177a08435eb8e1f9b01714 Mon Sep 17 00:00:00 2001 From: Chris Dent Date: Sun, 30 Apr 2023 12:19:09 +0100 Subject: Add github actions tests (#77) Borrowing the configuration from wsg-intercept and then editing to fit so that we've got some automated tests. To get this to work it was necessary to: * adjust python versions * update action version * pin the ubuntu version * fix warning in test_grantip * form.cgi needs to not use six because it is not running in the virtualenv * quiet deprecations in in form.cgi because cgi module is deprecated * Skip the proxy test as it uses httpbin.org which is unreliable --- .github/workflows/tests.yaml | 36 ++++++++++++++++++++++++++++++++++++ .travis.yml | 28 ---------------------------- tests/cgiapp_data/form.cgi | 11 +++++++++-- tests/test_grantip.py | 4 ++-- tests/test_proxy.py | 5 +++++ 5 files changed, 52 insertions(+), 32 deletions(-) create mode 100644 .github/workflows/tests.yaml delete mode 100644 .travis.yml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..a352171 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,36 @@ +name: tests +on: [push, workflow_dispatch] +jobs: + build: + runs-on: ubuntu-20.04 + strategy: + matrix: + include: + - python: 2.7 + env: py27 + - python: 3.5 + env: py35 + - python: 3.6 + env: py36 + - python: 3.7 + env: py37 + - python: 3.8 + env: py38 + - python: 3.9 + env: py39 + - python: "3.10" + env: py310 + - python: "3.11" + env: py311 + - python: pypy-3.8 + env: pypy3 + name: ${{ matrix.env }} on Python ${{ matrix.python }} + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python }} + - run: pip install tox + - run: tox + env: + TOXENV: ${{ matrix.env }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 6655569..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -sudo: false -language: python -install: - - pip install tox -script: - - tox -matrix: - include: - - python: 2.7 - env: TOXENV=py27-coverage - - python: 3.5 - env: TOXENV=py35-coverage - - python: 3.6 - env: TOXENV=py36-coverage - - python: 3.7 - env: TOXENV=py37-coverage - - python: 3.8 - env: TOXENV=py38-coverage - - python: pypy - env: TOXENV=pypy-coverage - -after_success: - - | - flags=${TOXENV%-coverage} - if [[ "$flags" != "$TOXENV" ]]; then - .tox/$TOXENV/bin/coverage xml - bash <(curl -s https://codecov.io/bash) -Z -X gcov -X search -X xcode -X fix -X coveragepy -f coverage.xml -F "$flags" - fi diff --git a/tests/cgiapp_data/form.cgi b/tests/cgiapp_data/form.cgi index c4c562d..5ad8f68 100755 --- a/tests/cgiapp_data/form.cgi +++ b/tests/cgiapp_data/form.cgi @@ -2,13 +2,20 @@ from __future__ import print_function +import sys + +# Quiet warnings in this CGI so that it does not upset tests. +if not sys.warnoptions: + import warnings + warnings.simplefilter("ignore") + +# TODO: cgi is deprecated and will go away in Python 3.13. import cgi -import six print('Content-type: text/plain') print('') -if six.PY3: +if sys.version_info.major >= 3: # Python 3: cgi.FieldStorage keeps some field names as unicode and some as # the repr() of byte strings, duh. diff --git a/tests/test_grantip.py b/tests/test_grantip.py index 2ddf7f1..cd5c98a 100644 --- a/tests/test_grantip.py +++ b/tests/test_grantip.py @@ -1,7 +1,7 @@ from paste.auth import grantip from paste.fixture import * -def test_make_app(): +def _make_app(): def application(environ, start_response): start_response('200 OK', [('content-type', 'text/plain')]) lines = [ @@ -23,7 +23,7 @@ def test_make_app(): return app def test_req(): - app = test_make_app() + app = _make_app() def doit(remote_addr): res = app.get('/', extra_environ={'REMOTE_ADDR': remote_addr}) return res.body diff --git a/tests/test_proxy.py b/tests/test_proxy.py index 844f9a0..5f80fef 100644 --- a/tests/test_proxy.py +++ b/tests/test_proxy.py @@ -1,6 +1,11 @@ +import pytest + from paste import proxy from paste.fixture import TestApp +# TODO: Skipping this for now as it is unreliable. Ideally we'd run something +# locally and not have to rely on external stuff. +@pytest.mark.skip(reason="httpbin.org is too slow these days") def test_proxy_to_website(): # Not the most robust test... # need to test things like POSTing to pages, and getting from pages -- cgit v1.2.1