Skip to content
Snippets Groups Projects
Commit 61939fd5 authored by Tamas Kiss's avatar Tamas Kiss
Browse files

test: added mypy to linting tests

parent 021af9e3
No related branches found
No related tags found
No related merge requests found
-r requirements.txt -r requirements.txt
mock==4.0.3 mock==4.0.3
types-mock==4.0.3
pytest==6.2.2 pytest==6.2.2
pylint==2.7.1 pylint==2.7.1
coverage==5.5 coverage==5.5
mypy==0.931
from unittest import TestCase from unittest import TestCase
#pylint: disable=missing-class-docstring,missing-function-docstring #pylint: disable=missing-class-docstring,missing-function-docstring
import pathlib import pathlib
from pylint import epylint from pylint import epylint # type: ignored
class CodeQualityCase(TestCase): class CodeQualityCase(TestCase):
def setUp(self): def setUp(self):
self.vcsroot = pathlib.Path(__file__).parent.parent.absolute() self.vcsroot = pathlib.Path(__file__).parent.parent.absolute()
self.rcfile = self.vcsroot.joinpath('.pylintrc') self.rcfile = self.vcsroot.joinpath('.pylintrc')
self.module_source_dir = "mattermost_matchmaker"
self.test_source_dir = "tests"
def test_source_quality(self): 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): 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, [])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment