Skip to content

Commit

Permalink
Add github actions tests (pasteorg#77)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
cdent committed Apr 30, 2023
1 parent 59eaf31 commit 36fd963
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 32 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
28 changes: 0 additions & 28 deletions .travis.yml

This file was deleted.

11 changes: 9 additions & 2 deletions tests/cgiapp_data/form.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions tests/test_grantip.py
Original file line number Diff line number Diff line change
@@ -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 = [
Expand All @@ -23,7 +23,7 @@ def application(environ, start_response):
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
Expand Down
5 changes: 5 additions & 0 deletions tests/test_proxy.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 36fd963

Please sign in to comment.