This commit is contained in:
Joshua Oreman 2022-01-13 03:21:24 -07:00
parent 0187c89611
commit 2c782b9619
4 changed files with 14 additions and 13 deletions

View File

@ -25,8 +25,6 @@ jobs:
check_lint: ['0']
extra_name: ['']
include:
- python: '2.7'
extra_name: ', build only'
- python: '3.9'
check_lint: '1'
extra_name: ', check lint'

6
ci.sh
View File

@ -13,12 +13,6 @@ python setup.py sdist --formats=zip
pip uninstall -y cython
pip install dist/*.zip
if python --version 2>&1 | fgrep -q "Python 2.7"; then
# The testsuite doesn't run on 2.7, so do just a basic smoke test.
unshare -Urn python -c "from netfilterqueue import NetfilterQueue as NFQ; NFQ()"
exit $?
fi
pip install -Ur test-requirements.txt
if [ "$CHECK_LINT" = "1" ]; then

View File

@ -20,7 +20,9 @@ except ImportError:
# We're being run by pip to figure out what we need. Request cython in
# setup_requires below.
setup_requires = ["cython"]
elif not os.path.exists(os.path.join(os.path.dirname(__file__), "netfilterqueue.c")):
elif not os.path.exists(
os.path.join(os.path.dirname(__file__), "netfilterqueue.c")
):
sys.stderr.write(
"You must have Cython installed (`pip install cython`) to build this "
"package from source.\nIf you're receiving this error when installing from "
@ -35,6 +37,7 @@ except ImportError:
setup(
ext_modules=ext_modules,
setup_requires=setup_requires,
python_requires=">=3.6",
name="NetfilterQueue",
version=VERSION,
license="MIT",

View File

@ -103,11 +103,15 @@ async def test_errors(harness):
async def test_unretained(harness):
# Capture packets without retaining -> can't access payload
async with harness.capture_packets_to(2, trio.MemorySendChannel.send_nowait) as chan:
async with harness.capture_packets_to(
2, trio.MemorySendChannel.send_nowait
) as chan:
await harness.send(2, b"one", b"two")
accept = True
async for p in chan:
with pytest.raises(RuntimeError, match="Payload data is no longer available"):
with pytest.raises(
RuntimeError, match="Payload data is no longer available"
):
p.get_payload()
# Can still issue verdicts though
if accept:
@ -166,7 +170,7 @@ async def test_cb_exception_during_unbind(harness, capsys):
@contextmanager
def catch_unraisable_exception():
pass
yield
with catch_unraisable_exception() as unraise, trio.CancelScope() as cscope:
async with harness.capture_packets_to(2, cb):
@ -188,7 +192,9 @@ async def test_cb_exception_during_unbind(harness, capsys):
assert str(unraise.unraisable.exc_value) == "test"
if not unraise:
assert "Exception ignored in: 'netfilterqueue callback" in capsys.readouterr().err
assert (
"Exception ignored in: 'netfilterqueue callback" in capsys.readouterr().err
)
with pytest.raises(RuntimeError, match="Payload data is no longer available"):
pkt.get_payload()