Skip to content

Commit

Permalink
pytest.mark.network
Browse files Browse the repository at this point in the history
  • Loading branch information
ross committed Jun 19, 2023
1 parent ffae65a commit 36193c7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_requests_futures.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
pypy_version_info = None
from unittest import TestCase, main, skipIf
import logging
import pytest

from requests import Response, session
from requests.adapters import DEFAULT_POOLSIZE
Expand All @@ -30,6 +31,7 @@ def httpbin(*suffix):


class RequestsTestCase(TestCase):
@pytest.mark.network
def test_futures_session(self):
# basic futures get
sess = FuturesSession()
Expand Down Expand Up @@ -65,6 +67,7 @@ def rasing_cb(s, r):
resp = future.result()
self.assertEqual('boom', cm.exception.args[0])

@pytest.mark.network
def test_supplied_session(self):
"""Tests the `session` keyword argument."""
requests_session = session()
Expand Down Expand Up @@ -112,6 +115,7 @@ def test_adapter_kwargs(self):
)
self.assertEqual(session.get_adapter('http://')._pool_connections, 20)

@pytest.mark.network
def test_redirect(self):
"""Tests for the ability to cleanly handle redirects."""
sess = FuturesSession()
Expand All @@ -125,6 +129,7 @@ def test_redirect(self):
resp = future.result()
self.assertEqual(404, resp.status_code)

@pytest.mark.network
def test_context(self):
class FuturesSessionTestHelper(FuturesSession):
def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -181,15 +186,18 @@ def setUp(self):
self.proc_executor = ProcessPoolExecutor(max_workers=2)
self.session = session()

@pytest.mark.network
@skipIf(session_required, 'not supported in python < 3.5')
def test_futures_session(self):
self._assert_futures_session()

@pytest.mark.network
@skipIf(not session_required, 'fully supported on python >= 3.5')
def test_exception_raised(self):
with self.assertRaises(RuntimeError):
self._assert_futures_session()

@pytest.mark.network
def test_futures_existing_session(self):
self.session.headers['Foo'] = 'bar'
self._assert_futures_session(session=self.session)
Expand Down Expand Up @@ -247,10 +255,12 @@ def _assert_futures_session(self, session=None):
resp = future.result()
self.assertEqual(404, resp.status_code)

@pytest.mark.network
@skipIf(session_required, 'not supported in python < 3.5')
def test_context(self):
self._assert_context()

@pytest.mark.network
def test_context_with_session(self):
self._assert_context(session=self.session)

Expand Down Expand Up @@ -285,6 +295,7 @@ def __exit__(self, *args, **kwargs):

@skipIf(not unsupported_platform, 'Exception raised when unsupported')
class ProcessPoolExceptionRaisedTestCase(TestCase):
@pytest.mark.network
def test_exception_raised(self):
executor = ProcessPoolExecutor(max_workers=2)
sess = FuturesSession(executor=executor, session=session())
Expand Down

0 comments on commit 36193c7

Please sign in to comment.