diff --git a/.bandit b/.bandit index 2f0b94e..638be11 100644 --- a/.bandit +++ b/.bandit @@ -1,3 +1,5 @@ [bandit] # B101: assert_used skips = B101 + +exclude = test_init.py diff --git a/Dockerfile b/Dockerfile index 77f5350..d2f03d4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,7 +23,7 @@ RUN apt-get update && \ # Set workdir WORKDIR /app -COPY requirements.txt ./ +COPY requirements.txt pytest.ini ./ COPY sedr/ ./sedr/ RUN python3 -m venv ./venv && \ ./venv/bin/pip install -r /app/requirements.txt diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..e57f862 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,4 @@ +[pytest] +filterwarnings = + ignore::DeprecationWarning + ignore::pytest.PytestAssertRewriteWarning \ No newline at end of file diff --git a/sedr/test_init.py b/sedr/test_init.py index 7bd63fe..245b40f 100644 --- a/sedr/test_init.py +++ b/sedr/test_init.py @@ -4,18 +4,34 @@ import subprocess import sys + class TestInit(unittest.TestCase): def test_version(self): - result = subprocess.run([sys.executable, "./__init__.py", "--version"], capture_output=True, text=True) + result = subprocess.run( + [sys.executable, "./__init__.py", "--version"], + capture_output=True, + text=True, + ) self.assertIn("v", result.stdout) def test_help(self): - result = subprocess.run([sys.executable, "./__init__.py", "--help"], capture_output=True, text=True) + result = subprocess.run( + [sys.executable, "./__init__.py", "--help"], capture_output=True, text=True + ) self.assertIn("usage:", result.stdout) def test_run(self): - result = subprocess.run([sys.executable, "./__init__.py", "--url", "https://edrisobaric.k8s.met.no"], capture_output=True, text=True) + result = subprocess.run( + [ + sys.executable, + "./__init__.py", + "--url", + "https://edrisobaric.k8s.met.no", + ], + capture_output=True, + text=True, + ) self.assertEqual(0, result.returncode) diff --git a/sedr/util.py b/sedr/util.py index 1413724..e51007a 100644 --- a/sedr/util.py +++ b/sedr/util.py @@ -12,6 +12,8 @@ __license__ = "GPL-3.0" edr_version = "1.1" +args = logger = None + def parse_args(version: str = "") -> argparse.Namespace: """Parse arguments.""" @@ -29,8 +31,8 @@ def parse_args(version: str = "") -> argparse.Namespace: parser.add_argument( "--iterations", type=int, - default=50, - help="Amount of examples to generate, per test. Default 50. Increase for local, developer testing.", + default=10, + help="Amount of examples to generate, per test. Default 10. Increase for local, developer testing.", ) parser.add_argument( "--log-file", @@ -174,10 +176,3 @@ def locate_openapi_url(url: str) -> str: # Yaml # Xml return "" - - -args = logger = None - -if __name__ == "__main__": - args = parse_args() - logger = set_up_logging(args=args, logfile=args.log_file) diff --git a/tox.ini b/tox.ini index 1eaa42e..7d8688a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = unittest, py{310,312}, black, prospector, bandit +envlist = unittest, black, prospector, bandit, py312 # Tell tox to not require a setup.py file skipsdist = True