Tests: clean Python code, add linting to CI

This commit is contained in:
Pierre Lalet 2021-12-09 12:08:19 +01:00
parent f397198d75
commit 70eae9bc0c
4 changed files with 636 additions and 243 deletions

View file

@ -72,7 +72,16 @@ jobs:
python-version: 3.9 python-version: 3.9
- name: Install dependencies - name: Install dependencies
run: sudo pip install -r test/requirements.txt run: sudo pip install -U -r test/requirements.txt
- name: Install linting tools
run: sudo pip install -U flake8 black
- name: Run black
run: black -t py36 --check test/test_masscanned.py test/src/
- name: Run flake8
run: flake8 --ignore=E266,E501,W503 test/test_masscanned.py test/src/all.py
- name: Run tests - name: Run tests
run: sudo python test/test_masscanned.py run: sudo python test/test_masscanned.py

File diff suppressed because it is too large Load diff

View file

@ -16,5 +16,5 @@
IPV4_ADDR = "192.0.0.1" IPV4_ADDR = "192.0.0.1"
IPV6_ADDR = "2001:41d0::ab32:bdb8" IPV6_ADDR = "2001:41d0::ab32:bdb8"
MAC_ADDR = "52:1c:4e:c2:a4:1f" MAC_ADDR = "52:1c:4e:c2:a4:1f"
OUTDIR = "test/res/" OUTDIR = "test/res/"

View file

@ -28,7 +28,8 @@ from scapy.interfaces import resolve_iface
from scapy.layers.tuntap import TunTapInterface from scapy.layers.tuntap import TunTapInterface
from src.all import test_all from src.all import test_all
from src.conf import * from src.conf import IPV4_ADDR, IPV6_ADDR, MAC_ADDR, OUTDIR
def setup_logs(): def setup_logs():
ch = logging.StreamHandler() ch = logging.StreamHandler()
@ -39,6 +40,7 @@ def setup_logs():
log.addHandler(ch) log.addHandler(ch)
return log return log
LOG = setup_logs() LOG = setup_logs()
IFACE = "tap0" IFACE = "tap0"
conf.verb = 0 conf.verb = 0