From 61939fd50a8134f96481a253cd41f3ba45cf3954 Mon Sep 17 00:00:00 2001 From: Tamas Kiss <kiss.tamas@kszk.bme.hu> Date: Tue, 8 Mar 2022 04:04:45 +0100 Subject: [PATCH] test: added mypy to linting tests --- requirements-test.txt | 3 +++ tests/test_lint.py | 26 ++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/requirements-test.txt b/requirements-test.txt index 5a23072..1e70d16 100644 --- a/requirements-test.txt +++ b/requirements-test.txt @@ -1,6 +1,9 @@ -r requirements.txt mock==4.0.3 +types-mock==4.0.3 + pytest==6.2.2 pylint==2.7.1 coverage==5.5 +mypy==0.931 diff --git a/tests/test_lint.py b/tests/test_lint.py index 712c4c3..2f0d9bf 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -1,16 +1,34 @@ from unittest import TestCase #pylint: disable=missing-class-docstring,missing-function-docstring import pathlib -from pylint import epylint - +from pylint import epylint # type: ignored class CodeQualityCase(TestCase): def setUp(self): self.vcsroot = pathlib.Path(__file__).parent.parent.absolute() self.rcfile = self.vcsroot.joinpath('.pylintrc') + self.module_source_dir = "mattermost_matchmaker" + self.test_source_dir = "tests" + def test_source_quality(self): - self.assertEqual(0, epylint.lint("mattermost_matchmaker", ["--fail-under=9.5", f"--rcfile={self.rcfile}"])) + self.assertEqual(0, epylint.lint(self.module_source_dir, ["--fail-under=9.5", f"--rcfile={self.rcfile}"])) def test_test_quality(self): - self.assertEqual(0, epylint.lint("tests", ["--fail-under=9.5", f"--rcfile={self.rcfile}"])) + self.assertEqual(0, epylint.lint(self.test_source_dir, ["--fail-under=9.5", f"--rcfile={self.rcfile}"])) + + def test_source_types(self): + #pylint: disable=import-outside-toplevel,no-name-in-module + from mypy.build import build as mypy_build + from mypy.options import Options as Mypy_Options + from mypy.find_sources import create_source_list as mypy_source_list + + options = Mypy_Options() + options.config_file=str(self.vcsroot.joinpath("mypy.ini")) + + res = mypy_build( + sources=mypy_source_list([str(self.vcsroot.joinpath(self.module_source_dir))], options=options), + options=options, + ) + + self.assertCountEqual(res.errors, []) -- GitLab