Update dependency flake8 to v7.2.0 (#330)
* Update dependency flake8 to v7.2.0 * Flake8: ignore F821 errors, due of False Positives # cleanup some unit tests --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Stefan Allius <stefan.allius@t-online.de>
This commit is contained in:
2
.github/workflows/python-app.yml
vendored
2
.github/workflows/python-app.yml
vendored
@@ -49,7 +49,7 @@ jobs:
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||
flake8 . --count --select=E9,F63,F7,F82 --ignore=F821 --show-source --statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
flake8 --exit-zero --ignore=C901,E121,E123,E126,E133,E226,E241,E242,E704,W503,W504,W505 --format=pylint --output-file=output_flake.txt --exclude=*.pyc app/src/
|
||||
- name: Test with pytest
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
flake8==7.1.2
|
||||
flake8==7.2.0
|
||||
pytest==8.3.5
|
||||
pytest-asyncio==0.26.0
|
||||
pytest-cov==6.1.0
|
||||
|
||||
@@ -84,7 +84,10 @@ async def test_close_cb():
|
||||
return 0.1
|
||||
def closed():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
# The callback will be called after the AsyncStreamServer
|
||||
# constructer has finished and so ifc must be defined in the
|
||||
# upper scope
|
||||
assert "ifc" in locals()
|
||||
ifc.close() # clears the closed callback
|
||||
cnt += 1
|
||||
|
||||
@@ -113,7 +116,6 @@ async def test_close_cb():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_read():
|
||||
global test
|
||||
assert asyncio.get_running_loop()
|
||||
reader = FakeReader()
|
||||
reader.test = FakeReader.RD_TEST_13_BYTES
|
||||
@@ -124,11 +126,13 @@ async def test_read():
|
||||
return 1
|
||||
def closed():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
# The callback will be called after the AsyncStreamServer
|
||||
# constructer has finished and so ifc must be defined in the
|
||||
# upper scope
|
||||
assert "ifc" in locals()
|
||||
ifc.close() # clears the closed callback
|
||||
cnt += 1
|
||||
def app_read():
|
||||
nonlocal ifc
|
||||
ifc.proc_start -= 3
|
||||
return 0.01 # async wait of 0.01
|
||||
cnt = 0
|
||||
@@ -151,7 +155,6 @@ async def test_read():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_write():
|
||||
global test
|
||||
assert asyncio.get_running_loop()
|
||||
reader = FakeReader()
|
||||
reader.test = FakeReader.RD_TEST_13_BYTES
|
||||
@@ -162,11 +165,13 @@ async def test_write():
|
||||
return 1
|
||||
def closed():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
# The callback will be called after the AsyncStreamServer
|
||||
# constructer has finished and so ifc must be defined in the
|
||||
# upper scope
|
||||
assert "ifc" in locals()
|
||||
ifc.close() # clears the closed callback
|
||||
cnt += 1
|
||||
def app_read():
|
||||
nonlocal ifc
|
||||
ifc.proc_start -= 3
|
||||
return 0.01 # async wait of 0.01
|
||||
|
||||
@@ -203,7 +208,6 @@ async def test_publ_mqtt_cb():
|
||||
return 0.1
|
||||
async def publ_mqtt():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
cnt += 1
|
||||
|
||||
cnt = 0
|
||||
@@ -233,7 +237,10 @@ async def test_create_remote_cb():
|
||||
return 0.1
|
||||
async def create_remote():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
# The callback will be called after the AsyncStreamServer
|
||||
# constructer has finished and so ifc must be defined in the
|
||||
# upper scope
|
||||
assert "ifc" in locals()
|
||||
ifc.close() # clears the closed callback
|
||||
cnt += 1
|
||||
|
||||
@@ -255,7 +262,6 @@ async def test_create_remote_cb():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_sw_exception():
|
||||
global test
|
||||
assert asyncio.get_running_loop()
|
||||
reader = FakeReader()
|
||||
reader.test = FakeReader.RD_TEST_SW_EXCEPT
|
||||
@@ -266,7 +272,10 @@ async def test_sw_exception():
|
||||
return 1
|
||||
def closed():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
# The callback will be called after the AsyncStreamServer
|
||||
# constructer has finished and so ifc must be defined in the
|
||||
# upper scope
|
||||
assert "ifc" in locals()
|
||||
ifc.close() # clears the closed callback
|
||||
cnt += 1
|
||||
cnt = 0
|
||||
@@ -285,7 +294,6 @@ async def test_sw_exception():
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_os_error():
|
||||
global test
|
||||
assert asyncio.get_running_loop()
|
||||
reader = FakeReader()
|
||||
reader.test = FakeReader.RD_TEST_OS_ERROR
|
||||
@@ -293,12 +301,11 @@ async def test_os_error():
|
||||
reader.on_recv.set()
|
||||
writer = FakeWriter()
|
||||
cnt = 0
|
||||
|
||||
def timeout():
|
||||
return 1
|
||||
def closed():
|
||||
nonlocal cnt
|
||||
nonlocal ifc
|
||||
ifc.close() # clears the closed callback
|
||||
cnt += 1
|
||||
cnt = 0
|
||||
ifc = AsyncStreamClient(reader, writer, None, closed)
|
||||
@@ -361,10 +368,13 @@ async def test_forward():
|
||||
assert asyncio.get_running_loop()
|
||||
remote = StreamPtr(None)
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote, ifc
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_NO_EXCPT)
|
||||
# The callback will be called after the AsyncStreamServer
|
||||
# constructer has finished and so ifc must be defined in the
|
||||
# upper scope
|
||||
assert "ifc" in locals()
|
||||
ifc.fwd_add(b'test-forward_msg2 ')
|
||||
cnt += 1
|
||||
|
||||
@@ -382,7 +392,7 @@ async def test_forward_with_conn():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote, ifc
|
||||
nonlocal cnt
|
||||
cnt += 1
|
||||
|
||||
cnt = 0
|
||||
@@ -417,7 +427,7 @@ async def test_forward_sw_except():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_SW_EXCPT)
|
||||
cnt += 1
|
||||
|
||||
@@ -435,7 +445,7 @@ async def test_forward_os_error():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_OS_ERROR)
|
||||
cnt += 1
|
||||
|
||||
@@ -453,7 +463,7 @@ async def test_forward_os_error2():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_OS_ERROR, True)
|
||||
cnt += 1
|
||||
|
||||
@@ -471,7 +481,7 @@ async def test_forward_os_error3():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_OS_ERROR_NO_STREAM)
|
||||
cnt += 1
|
||||
|
||||
@@ -489,7 +499,7 @@ async def test_forward_runtime_error():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_RUNTIME_ERROR)
|
||||
cnt += 1
|
||||
|
||||
@@ -507,7 +517,7 @@ async def test_forward_runtime_error2():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_RUNTIME_ERROR, True)
|
||||
cnt += 1
|
||||
|
||||
@@ -525,7 +535,7 @@ async def test_forward_runtime_error3():
|
||||
cnt = 0
|
||||
|
||||
async def _create_remote():
|
||||
nonlocal cnt, remote
|
||||
nonlocal cnt
|
||||
create_remote(remote, TestType.FWD_RUNTIME_ERROR_NO_STREAM, True)
|
||||
cnt += 1
|
||||
|
||||
@@ -543,7 +553,7 @@ async def test_forward_resp():
|
||||
cnt = 0
|
||||
|
||||
def _close_cb():
|
||||
nonlocal cnt, remote, ifc
|
||||
nonlocal cnt
|
||||
cnt += 1
|
||||
|
||||
cnt = 0
|
||||
@@ -559,9 +569,8 @@ async def test_forward_resp2():
|
||||
assert asyncio.get_running_loop()
|
||||
remote = StreamPtr(None)
|
||||
cnt = 0
|
||||
|
||||
def _close_cb():
|
||||
nonlocal cnt, remote, ifc
|
||||
nonlocal cnt
|
||||
cnt += 1
|
||||
|
||||
cnt = 0
|
||||
@@ -571,3 +580,4 @@ async def test_forward_resp2():
|
||||
await ifc.client_loop('')
|
||||
assert cnt == 1
|
||||
del ifc
|
||||
|
||||
@@ -85,7 +85,6 @@ def patch_open_connection():
|
||||
return FakeReader(), FakeWriter()
|
||||
|
||||
def new_open(host: str, port: int):
|
||||
global test
|
||||
if test == MockType.RD_TEST_TIMEOUT:
|
||||
raise ConnectionRefusedError
|
||||
elif test == MockType.RD_TEST_EXCEPT:
|
||||
@@ -318,7 +317,7 @@ async def test_remote_conn_to_loopback(config_conn, patch_open_connection):
|
||||
assert cnt == 0
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_remote_conn_to_None(config_conn, patch_open_connection):
|
||||
async def test_remote_conn_to_none(config_conn, patch_open_connection):
|
||||
'''check if get_extra_info() return None in case of an error'''
|
||||
_ = config_conn
|
||||
_ = patch_open_connection
|
||||
|
||||
@@ -85,7 +85,6 @@ def patch_open_connection():
|
||||
return FakeReader(), FakeWriter()
|
||||
|
||||
def new_open(host: str, port: int):
|
||||
global test
|
||||
if test == MockType.RD_TEST_TIMEOUT:
|
||||
raise ConnectionRefusedError
|
||||
elif test == MockType.RD_TEST_EXCEPT:
|
||||
|
||||
@@ -84,7 +84,6 @@ def patch_open_connection():
|
||||
return FakeReader(), FakeWriter()
|
||||
|
||||
def new_open(host: str, port: int):
|
||||
global test
|
||||
if test == MockType.RD_TEST_TIMEOUT:
|
||||
raise ConnectionRefusedError
|
||||
elif test == MockType.RD_TEST_EXCEPT:
|
||||
|
||||
@@ -96,7 +96,6 @@ def test_native_client(test_hostname, test_port):
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_mqtt_connection(config_mqtt_conn):
|
||||
global NO_MOSQUITTO_TEST
|
||||
if NO_MOSQUITTO_TEST:
|
||||
pytest.skip('skipping, since Mosquitto is not reliable at the moment')
|
||||
|
||||
@@ -122,7 +121,6 @@ async def test_mqtt_connection(config_mqtt_conn):
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_ha_reconnect(config_mqtt_conn):
|
||||
global NO_MOSQUITTO_TEST
|
||||
if NO_MOSQUITTO_TEST:
|
||||
pytest.skip('skipping, since Mosquitto is not reliable at the moment')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user