Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove verbose flag from tests #95

Merged
merged 1 commit into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions tests/test_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def test_that_a_coroutine_runs(self):
async def test_inet_is_blocked(self):
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose", "--disable-socket", "--allow-unix-socket")
result = testdir.runpytest("--disable-socket", "--allow-unix-socket")
result.assert_outcomes(passed=1, skipped=0, failed=1)


Expand All @@ -53,7 +53,7 @@ def test_app():
response = client.get('/')
assert response.status_code == 200
""")
result = testdir.runpytest("--verbose", "--disable-socket", "--allow-unix-socket")
result = testdir.runpytest("--disable-socket", "--allow-unix-socket")
result.assert_outcomes(passed=1, skipped=0, failed=0)


Expand All @@ -72,5 +72,5 @@ async def test_httpx():
async with httpx.AsyncClient() as client:
await client.get("http://www.example.com/")
""")
result = testdir.runpytest("--verbose", "--disable-socket", "--allow-unix-socket")
result = testdir.runpytest("--disable-socket", "--allow-unix-socket")
assert_socket_blocked(result)
12 changes: 6 additions & 6 deletions tests/test_restrict_hosts.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def assert_socket_connect(should_pass, **kwargs):
testdir.makepyfile(code)

if cli_arg:
result = testdir.runpytest("--verbose", '--allow-hosts={0}'.format(cli_arg))
result = testdir.runpytest('--allow-hosts={0}'.format(cli_arg))
else:
result = testdir.runpytest("--verbose")
result = testdir.runpytest()

if should_pass:
result.assert_outcomes(1, 0, 0)
Expand Down Expand Up @@ -177,7 +177,7 @@ def test_global_restrict_via_config_fail():
[pytest]
addopts = --allow-hosts=2.2.2.2
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(0, 0, 1)
assert_host_blocked(result, '127.0.0.1')

Expand All @@ -194,7 +194,7 @@ def test_global_restrict_via_config_pass():
[pytest]
addopts = --allow-hosts={0}
""".format(test_url.hostname))
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(1, 0, 0)


Expand All @@ -215,7 +215,7 @@ def test_fail():
def test_pass_2():
socket.socket().connect(('{0}', {1}))
""".format(test_url.hostname, test_url.port))
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(2, 0, 1)
assert_host_blocked(result, test_url.hostname)

Expand All @@ -237,7 +237,7 @@ def test_fail():
def test_fail_2():
socket.socket().connect(('2.2.2.2', {1}))
""".format(test_url.hostname, test_url.port))
result = testdir.runpytest("--verbose", '--allow-hosts=1.2.3.4')
result = testdir.runpytest('--allow-hosts=1.2.3.4')
result.assert_outcomes(1, 0, 2)
assert_host_blocked(result, '2.2.2.2')
assert_host_blocked(result, test_url.hostname)
30 changes: 15 additions & 15 deletions tests/test_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def assert_socket_blocked(result):
)
def test_socket_enabled_by_default(testdir, pyfile):
testdir.makepyfile(pyfile)
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(1, 0, 0)
with pytest.raises(BaseException):
assert_socket_blocked(result)
Expand All @@ -63,7 +63,7 @@ def disable_socket_for_all():
def test_socket():
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
assert_socket_blocked(result)


Expand All @@ -77,7 +77,7 @@ def test_socket():
)
def test_global_disable_via_cli_flag(testdir, pyfile):
testdir.makepyfile(pyfile)
result = testdir.runpytest("--verbose", "--disable-socket")
result = testdir.runpytest("--disable-socket")
assert_socket_blocked(result)


Expand Down Expand Up @@ -105,7 +105,7 @@ def test_global_disable_via_config(testdir, pyfile):
[pytest]
addopts = --disable-socket
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
assert_socket_blocked(result)


Expand All @@ -118,7 +118,7 @@ def test_disable_socket_marker(testdir):
def test_socket():
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
assert_socket_blocked(result)


Expand All @@ -131,7 +131,7 @@ def test_enable_socket_marker(testdir):
def test_socket():
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose", "--disable-socket")
result = testdir.runpytest("--disable-socket")
result.assert_outcomes(1, 0, 0)
with pytest.raises(BaseException):
assert_socket_blocked(result)
Expand All @@ -147,7 +147,7 @@ def test_urllib_succeeds_by_default(testdir):
def test_disable_socket_urllib():
assert urlopen('http://httpbin.org/get').getcode() == 200
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(1, 0, 0)
with pytest.raises(BaseException):
assert_socket_blocked(result)
Expand All @@ -166,7 +166,7 @@ def test_enabled_urllib_succeeds(testdir):
def test_disable_socket_urllib():
assert urlopen('http://httpbin.org/get').getcode() == 200
""")
result = testdir.runpytest("--verbose", "--disable-socket")
result = testdir.runpytest("--disable-socket")
result.assert_outcomes(1, 0, 0)
with pytest.raises(BaseException):
assert_socket_blocked(result)
Expand All @@ -184,7 +184,7 @@ def test_disabled_urllib_fails(testdir):
def test_disable_socket_urllib():
assert urlopen('http://httpbin.org/get').getcode() == 200
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
assert_socket_blocked(result)


Expand All @@ -210,7 +210,7 @@ def test_disable_enable():
pytest_socket.enable_socket()
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(3, 0, 0)
with pytest.raises(BaseException):
assert_socket_blocked(result)
Expand All @@ -222,7 +222,7 @@ def test_socket_enabled_fixture(testdir, socket_enabled):
def test_socket_enabled(socket_enabled):
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
result.assert_outcomes(1, 0, 0)
with pytest.raises(BaseException):
assert_socket_blocked(result)
Expand All @@ -239,7 +239,7 @@ def test_socket_enabled(socket_enabled):
def test_socket2():
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose", "--disable-socket")
result = testdir.runpytest("--disable-socket")
result.assert_outcomes(1, 0, 2)


Expand All @@ -257,7 +257,7 @@ class MySocket(socket.socket):

MySocket(socket.AF_INET, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose")
result = testdir.runpytest()
assert_socket_blocked(result)


Expand All @@ -269,7 +269,7 @@ def test_unix_domain_sockets_blocked_with_disable_socket(testdir):
def test_unix_socket():
socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose", "--disable-socket")
result = testdir.runpytest("--disable-socket")
assert_socket_blocked(result)


Expand All @@ -283,5 +283,5 @@ def test_inet():
def test_unix_socket():
socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
""")
result = testdir.runpytest("--verbose", "--disable-socket", "--allow-unix-socket")
result = testdir.runpytest("--disable-socket", "--allow-unix-socket")
result.assert_outcomes(passed=1, skipped=0, failed=1)