Skip to content

Commit e7ccd9b

Browse files
committed
fix tests and pep formatting, use py313 instead of py39
1 parent 1622d2f commit e7ccd9b

File tree

7 files changed

+49
-20
lines changed

7 files changed

+49
-20
lines changed

.github/workflows/tests.yaml

+6-6
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ jobs:
3737
toxenv: py312-pytest
3838
- python: "3.13"
3939
toxenv: py313-pytest
40-
- python: 3.9
41-
toxenv: py39-failskip
42-
- python: 3.9
43-
toxenv: py39-limit
44-
- python: 3.9
45-
toxenv: py39-prefix
40+
- python: "3.13"
41+
toxenv: py313-failskip
42+
- python: "3.13"
43+
toxenv: py313-limit
44+
- python: "3.13"
45+
toxenv: py313-prefix
4646
name: ${{ matrix.toxenv }} on Python ${{ matrix.python }}
4747
steps:
4848
- uses: actions/checkout@v2

gabbi/driver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def build_tests(path, loader, host=None, port=8001, intercept=None,
158158

159159

160160
def py_test_generator(test_dir, host=None, port=8001, intercept=None,
161-
prefix=None, test_loader_name=None,
161+
prefix='', test_loader_name=None,
162162
fixture_module=None, response_handlers=None,
163163
content_handlers=None, require_ssl=False, url=None,
164164
metafunc=None, use_prior_test=True,

gabbi/httpclient.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ def __init__(self, **kwargs):
3636
self.extensions['sni_hostname'] = kwargs['server_hostname']
3737
transport = kwargs.get('intercept')
3838
if transport:
39-
transport = httpx.WSGITransport(app=transport(), script_name=kwargs.get('prefix'))
40-
self.client = httpx.Client(transport=transport, verify=kwargs.get('cert_validate', True))
39+
transport = httpx.WSGITransport(
40+
app=transport(), script_name=kwargs.get("prefix", "")
41+
)
42+
self.client = httpx.Client(
43+
transport=transport, verify=kwargs.get("cert_validate", True)
44+
)
4145

4246
def request(self, absolute_uri, method, body, headers, redirect, timeout):
4347
response = self.client.request(

gabbi/tests/external_server.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,31 @@
1+
#
2+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
3+
# not use this file except in compliance with the License. You may obtain
4+
# a copy of the License at
5+
#
6+
# http://www.apache.org/licenses/LICENSE-2.0
7+
#
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
10+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
11+
# License for the specific language governing permissions and limitations
12+
# under the License.
113

214
import sys
315
from wsgiref import simple_server
416

517
from gabbi.tests import simple_wsgi
618

19+
720
def run(port):
8-
server = simple_server.make_server("127.0.0.1", int(port), simple_wsgi.SimpleWsgi())
21+
server = simple_server.make_server(
22+
"127.0.0.1",
23+
int(port),
24+
simple_wsgi.SimpleWsgi(),
25+
)
926
server.serve_forever()
1027

28+
1129
if __name__ == "__main__":
1230
port = sys.argv[1]
1331
run(port)

gabbi/tests/simple_wsgi.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,20 @@ def __call__(self, environ, start_response):
3030
global METHODS
3131
global CURRENT_POLL
3232

33+
script_name = environ.get('SCRIPT_NAME', '')
34+
path_info = environ.get('PATH_INFO', '').removeprefix(script_name)
3335
request_method = environ['REQUEST_METHOD'].upper()
3436
query_string = environ.get('QUERY_STRING', '')
3537
query_data = urlparse.parse_qs(query_string)
36-
request_url = environ.get('PATH_INFO', '')
37-
path_info = environ.get('PATH_INFO', '')
38+
request_url = script_name + path_info
3839
accept_header = environ.get('HTTP_ACCEPT')
3940
content_type_header = environ.get('CONTENT_TYPE', '')
4041

41-
full_request_url = self._fully_qualify(environ, request_url, query_string)
42+
full_request_url = self._fully_qualify(
43+
environ,
44+
request_url,
45+
query_string,
46+
)
4247

4348
if accept_header and accept_header != '*/*':
4449
response_content_type = accept_header

gabbi/tests/test_runner.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
from io import StringIO
1717
import os
18-
import subprocess
1918
import socket
19+
import subprocess
2020
import sys
2121
import time
2222
import unittest
@@ -32,6 +32,7 @@ def get_free_port():
3232
sock.bind(('', 0))
3333
return sock.getsockname()[1]
3434

35+
3536
class ForkedWSGIServer:
3637

3738
def __init__(self, port):
@@ -43,7 +44,8 @@ def start(self):
4344
env=os.environ.update({"PYTHONPATH": "."}),
4445
close_fds=True)
4546
# We need to sleep a bit to let the wsgi server start.
46-
time.sleep(.2)
47+
# TODO(cdent): This is regrettable.
48+
time.sleep(.4)
4749

4850
def stop(self):
4951
self.process.terminate()

tox.ini

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
22
minversion = 3.1.1
33
skipsdist = True
4-
envlist = pep8,py38,py39,py310,py311,py312,py313,pypy3,pep8,limit,failskip,docs,py39-prefix,py39-limit,py39-verbosity,py39-failskip,py36-pytest,py38-pytest,py39-pytest,py310-pytest,py311-pytest,py312-pytest,py313-pytest
4+
envlist = pep8,py38,py39,py310,py311,py312,py313,pypy3,pep8,limit,failskip,docs,py313-prefix,py313-limit,py313-verbosity,py313-failskip,py36-pytest,py38-pytest,py39-pytest,py310-pytest,py311-pytest,py312-pytest,py313-pytest
55

66
[testenv]
77
deps = -r{toxinidir}/requirements.txt
@@ -40,7 +40,7 @@ commands = py.test gabbi
4040
[testenv:py313-pytest]
4141
commands = py.test {posargs} gabbi
4242

43-
[testenv:py39-prefix]
43+
[testenv:py313-prefix]
4444
setenv = GABBI_PREFIX=/snoopy
4545

4646
[testenv:pep8]
@@ -49,15 +49,15 @@ deps = hacking
4949
commands =
5050
flake8
5151

52-
[testenv:py39-limit]
52+
[testenv:py313-limit]
5353
allowlist_externals = {toxinidir}/test-limit.sh
5454
commands = {toxinidir}/test-limit.sh
5555

56-
[testenv:py39-verbosity]
56+
[testenv:py313-verbosity]
5757
allowlist_externals = {toxinidir}/test-verbosity.sh
5858
commands = {toxinidir}/test-verbosity.sh
5959

60-
[testenv:py39-failskip]
60+
[testenv:py313-failskip]
6161
allowlist_externals = {toxinidir}/test-failskip.sh
6262
commands = {toxinidir}/test-failskip.sh
6363

0 commit comments

Comments
 (0)