Skip to content
This repository has been archived by the owner on Apr 14, 2022. It is now read-only.

Commit

Permalink
Run test_redirect in sync mode using unasync (#208)
Browse files Browse the repository at this point in the history
* Run test_redirect in sync mode using unasync

* Fix unasync call

* Fix test_sync_backend fixture

For some reason, the previous reason worked with recent pytest versions.
  • Loading branch information
pquentin committed May 4, 2020
1 parent c7c523a commit f483f82
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
run: |
python3.7 -m pip install --upgrade nox
python3.7 -m pip install nox unasync
- name: Run Tests
run: |
nox -s test-${{ matrix.python-version }}
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
run: |
# Work around https://github.com/theacodes/nox/issues/250
Remove-Item C:\ProgramData\Chocolatey\bin\python2.7.exe
py -3.7 -m pip install nox
py -3.7 -m pip install nox unasync
- name: Run Tests
run: |
nox -s test-${{ matrix.python-version }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Project-specific generated files
docs/build/
src/hip/_sync/
test/with_dummyserver/sync/

bench/results/
bench/env/
Expand Down
4 changes: 2 additions & 2 deletions _travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ set -exo pipefail
if ! python3 -m pip --version; then
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python3 get-pip.py
sudo python3 -m pip install nox
sudo python3 -m pip install nox unasync
else
# We're not in "dual Python" mode, so we can just install Nox normally.
python3 -m pip install nox
python3 -m pip install nox unasync
fi
20 changes: 20 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ def tests_impl(session, extras="socks,secure,brotli"):
if session.python != "pypy" and session.python != "2.7":
session.posargs.extend(["--random-order"])

# Only require unasync to run tests
import unasync # please install unasync alongside nox to run tests

unasync.unasync_files(
[
"test/with_dummyserver/async/__init__.py",
"test/with_dummyserver/async/test_poolmanager.py",
],
rules=[
unasync.Rule(
"test/with_dummyserver/async",
"test/with_dummyserver/sync",
additional_replacements={
"AsyncPoolManager": "PoolManager",
"test_all_backends": "test_sync_backend",
},
)
],
)

session.run(
"pytest",
"-r",
Expand Down
Empty file.
3 changes: 3 additions & 0 deletions test/with_dummyserver/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
)


test_sync_backend = pytest.mark.parametrize("backend, anyio_backend", [("sync", None)])


@contextlib.contextmanager
def run_server_in_thread(scheme, host, ca_certs, server_certs):
def _run_server_in_thread():
Expand Down

0 comments on commit f483f82

Please sign in to comment.