Skip to content

Commit 7abbad1

Browse files
committed
Run tests without tox
1 parent dd97b02 commit 7abbad1

File tree

6 files changed

+61
-147
lines changed

6 files changed

+61
-147
lines changed

.github/workflows/main.yml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,18 @@ jobs:
1313
strategy:
1414
fail-fast: false
1515
matrix:
16-
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "pypy-3.8", "pypy-3.9", "pypy-3.10"]
16+
python-version:
17+
- "3.8"
18+
- "3.9"
19+
- "3.10"
20+
- "3.11"
21+
- "3.12"
22+
- "pypy-3.8"
23+
- "pypy-3.9"
24+
- "pypy-3.10"
25+
urllib3-requirement:
26+
- "urllib3>=2"
27+
- "urllib3<2"
1728

1829
steps:
1930
- uses: actions/checkout@v4
@@ -22,22 +33,17 @@ jobs:
2233
uses: actions/setup-python@v5
2334
with:
2435
python-version: ${{ matrix.python-version }}
36+
cache: pip
2537

2638
- name: Install project dependencies
2739
run: |
28-
pip3 install --upgrade pip
29-
pip3 install codecov tox tox-gh-actions
40+
set -xe
41+
pip install --upgrade pip
42+
pip install codecov .[tests] '${{ matrix.urllib3-requirement }}'
43+
pip check
3044
31-
- name: Run online tests with tox
32-
run: tox -- -m online
33-
34-
- name: Run offline tests with tox with no access to the Internet
35-
run: |
36-
# We're using unshare to take Internet access
37-
# away from tox so that we'll notice whenever some new test
38-
# is missing @pytest.mark.online decoration in the future
39-
unshare --map-root-user --net -- \
40-
sh -c 'ip link set lo up; tox -- -m "not online"'
45+
- name: Run tests
46+
run: ./runtests.sh --cov=./vcr --cov-branch --cov-report=xml --cov-append
4147

4248
- name: Run coverage
4349
run: codecov

MANIFEST.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
include README.rst
22
include LICENSE.txt
3-
include tox.ini
43
recursive-include tests *
54
recursive-exclude * __pycache__
65
recursive-exclude * *.py[co]

docs/contributing.rst

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -83,39 +83,21 @@ The PR reviewer is a second set of eyes to see if:
8383
Running VCR's test suite
8484
------------------------
8585

86-
The tests are all run automatically on `Travis
87-
CI <https://travis-ci.org/kevin1024/vcrpy>`__, but you can also run them
88-
yourself using `pytest <http://pytest.org/>`__ and
89-
`Tox <http://tox.testrun.org/>`__.
86+
The tests are all run automatically on `Github Actions CI <https://github.com/kevin1024/vcrpy/actions>`__,
87+
but you can also run them yourself using `pytest <http://pytest.org/>`__.
9088

91-
Tox will automatically run them in all environments VCR.py supports if they are available on your `PATH`. Alternatively you can use `tox-pyenv <https://pypi.org/project/tox-pyenv/>`_ with
92-
`pyenv <https://github.com/pyenv/pyenv>`_.
93-
We recommend you read the documentation for each and see the section further below.
94-
95-
The test suite is pretty big and slow, but you can tell tox to only run specific tests like this::
96-
97-
tox -e {pyNN}-{HTTP_LIBRARY} -- <pytest flags passed through>
98-
99-
tox -e py38-requests -- -v -k "'test_status_code or test_gzip'"
100-
tox -e py38-requests -- -v --last-failed
101-
102-
This will run only tests that look like ``test_status_code`` or
103-
``test_gzip`` in the test suite, and only in the python 3.8 environment
104-
that has ``requests`` installed.
105-
106-
Also, in order for the boto3 tests to run, you will need an AWS key.
89+
In order for the boto3 tests to run, you will need an AWS key.
10790
Refer to the `boto3
10891
documentation <https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/index.html>`__
10992
for how to set this up. I have marked the boto3 tests as optional in
11093
Travis so you don't have to worry about them failing if you submit a
11194
pull request.
11295

113-
Using PyEnv with VCR's test suite
96+
Using Pyenv with VCR's test suite
11497
---------------------------------
11598

116-
PyEnv is a tool for managing multiple installation of python on your system.
99+
Pyenv is a tool for managing multiple installation of python on your system.
117100
See the full documentation at their `github <https://github.com/pyenv/pyenv>`_
118-
but we are also going to use `tox-pyenv <https://pypi.org/project/tox-pyenv/>`_
119101
in this example::
120102

121103
git clone https://github.com/pyenv/pyenv ~/.pyenv
@@ -126,26 +108,21 @@ in this example::
126108
# Setup shim paths
127109
eval "$(pyenv init -)"
128110

129-
# Setup your local system tox tooling
130-
pip3 install tox tox-pyenv
131-
132111
# Install supported versions (at time of writing), this does not activate them
133-
pyenv install 3.8.0 pypy3.8
112+
pyenv install 3.12.0 pypy3.10
134113

135114
# This activates them
136-
pyenv local 3.8.0 pypy3.8
115+
pyenv local 3.12.0 pypy3.10
137116

138117
# Run the whole test suite
139-
tox
140-
141-
# Run the whole test suite or just part of it
142-
tox -e py38-requests
118+
pip install .[test]
119+
./run_tests.sh
143120

144121

145122
Troubleshooting on MacOSX
146123
-------------------------
147124

148-
If you have this kind of error when running tox :
125+
If you have this kind of error when running tests :
149126

150127
.. code:: python
151128

setup.py

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -52,29 +52,34 @@ def run_tests(self):
5252
# so this block and the dependency can be dropped at some point
5353
# in the future. For more Details:
5454
# https://github.com/kevin1024/vcrpy/pull/699#issuecomment-1551439663
55-
"urllib3 <2; python_version <'3.10'",
55+
# "urllib3 <2; python_version <'3.10'",
5656
# https://github.com/kevin1024/vcrpy/pull/775#issuecomment-1847849962
57-
"urllib3 <2; platform_python_implementation =='PyPy'",
57+
# "urllib3 <2; platform_python_implementation =='PyPy'",
5858
]
5959

60-
tests_require = [
61-
"aiohttp",
62-
"boto3",
63-
"httplib2",
64-
"httpx",
65-
"pytest",
66-
"pytest-aiohttp",
67-
"pytest-httpbin",
68-
"requests>=2.16.2",
69-
"tornado",
70-
# Needed to un-break httpbin 0.7.0. For httpbin >=0.7.1 and after,
71-
# this pin and the dependency itself can be removed, provided
72-
# that the related bug in httpbin has been fixed:
73-
# https://github.com/kevin1024/vcrpy/issues/645#issuecomment-1562489489
74-
# https://github.com/postmanlabs/httpbin/issues/673
75-
# https://github.com/postmanlabs/httpbin/pull/674
76-
"Werkzeug==2.0.3",
77-
]
60+
extras_require = {
61+
"tests": [
62+
"aiohttp",
63+
"boto3",
64+
"httplib2",
65+
"httpx",
66+
"pytest-aiohttp",
67+
"pytest-asyncio",
68+
"pytest-cov",
69+
"pytest-httpbin",
70+
"pytest",
71+
"requests>=2.22.0",
72+
"tornado",
73+
"urllib3",
74+
# Needed to un-break httpbin 0.7.0. For httpbin >=0.7.1 and after,
75+
# this pin and the dependency itself can be removed, provided
76+
# that the related bug in httpbin has been fixed:
77+
# https://github.com/kevin1024/vcrpy/issues/645#issuecomment-1562489489
78+
# https://github.com/postmanlabs/httpbin/issues/673
79+
# https://github.com/postmanlabs/httpbin/pull/674
80+
"Werkzeug==2.0.3",
81+
],
82+
}
7883

7984
setup(
8085
name="vcrpy",
@@ -89,7 +94,8 @@ def run_tests(self):
8994
python_requires=">=3.8",
9095
install_requires=install_requires,
9196
license="MIT",
92-
tests_require=tests_require,
97+
extras_require=extras_require,
98+
tests_require=extras_require["tests"],
9399
classifiers=[
94100
"Development Status :: 5 - Production/Stable",
95101
"Environment :: Console",

tests/integration/test_requests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,18 @@ def test_nested_cassettes_with_session_created_before_nesting(httpbin_both, tmpd
265265
def test_post_file(tmpdir, httpbin_both):
266266
"""Ensure that we handle posting a file."""
267267
url = httpbin_both + "/post"
268-
with vcr.use_cassette(str(tmpdir.join("post_file.yaml"))) as cass, open("tox.ini", "rb") as f:
268+
with vcr.use_cassette(str(tmpdir.join("post_file.yaml"))) as cass, open(".editorconfig", "rb") as f:
269269
original_response = requests.post(url, f).content
270270

271271
# This also tests that we do the right thing with matching the body when they are files.
272272
with vcr.use_cassette(
273273
str(tmpdir.join("post_file.yaml")),
274274
match_on=("method", "scheme", "host", "port", "path", "query", "body"),
275275
) as cass:
276-
with open("tox.ini", "rb") as f:
277-
tox_content = f.read()
278-
assert cass.requests[0].body.read() == tox_content
279-
with open("tox.ini", "rb") as f:
276+
with open(".editorconfig", "rb") as f:
277+
editorconfig = f.read()
278+
assert cass.requests[0].body.read() == editorconfig
279+
with open(".editorconfig", "rb") as f:
280280
new_response = requests.post(url, f).content
281281
assert original_response == new_response
282282

tox.ini

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

0 commit comments

Comments
 (0)