Skip to content

Commit

Permalink
chore: remove verbose flag from tests (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
miketheman authored Dec 23, 2021
1 parent 35aeb88 commit 6acba7c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 24 deletions.
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("https://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('https://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('https://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('https://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)

0 comments on commit 6acba7c

Please sign in to comment.