Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 351e90e

Browse files
authored
Merge pull request #56 from SublimeLinter/testable
2 parents e082a29 + aa9892e commit 351e90e

3 files changed

Lines changed: 35 additions & 23 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,14 @@ jobs:
1919
- uses: actions/checkout@v3
2020
- run: pip install "flake8<6.0.0"
2121
- uses: TrueBrain/actions-flake8@v2
22+
23+
run-tests:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: SublimeText/UnitTesting/actions/setup@v1
28+
with:
29+
sublime-text-version: 4
30+
extra-packages:
31+
SublimeLinter/SublimeLinter
32+
- uses: SublimeText/UnitTesting/actions/run-tests@v1

mypy.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ check_untyped_defs = True
33
warn_redundant_casts = True
44
warn_unused_ignores = True
55
mypy_path =
6-
../
6+
:$MYPY_CONFIG_FILE_DIR/../
7+
:$MYPY_CONFIG_FILE_DIR/../SublimeLinter/stubs
78
sqlite_cache = True
89

910
[mypy-package_control]

tests/test_regex.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,48 @@
33
import re
44
import importlib
55

6-
# Damn you dash separated module names!!!
6+
import sublime
7+
78
LinterModule = importlib.import_module('SublimeLinter-mypy.linter')
89
Linter = LinterModule.Mypy
9-
regex = Linter.regex
1010

1111

1212
class TestRegex(unittest.TestCase):
13-
1413
def assertMatch(self, string, expected):
15-
match = re.match(regex, string)
16-
self.assertIsNotNone(match)
17-
self.assertEqual(match.groupdict(), expected)
14+
linter = Linter(sublime.View(0), {})
15+
actual = list(linter.find_errors(string))[0]
16+
# `find_errors` fills out more information we don't want to write down
17+
# in the examples
18+
self.assertEqual({k: actual[k] for k in expected.keys()}, expected)
1819

19-
def assertMatchIsNone(self, string):
20-
self.assertIsNone(re.match(regex, string))
20+
def assertNoMatch(self, string):
21+
linter = Linter(sublime.View(0), {})
22+
actual = list(linter.find_errors(string))
23+
self.assertFalse(actual)
2124

2225
def test_no_matches(self):
23-
self.assertMatchIsNone('')
24-
self.assertMatchIsNone('foo')
26+
self.assertNoMatch('')
27+
self.assertNoMatch('foo')
2528

2629
def test_matches(self):
2730
self.assertMatch(
2831
'/path/to/package/module.py:18:4: error: No return value expected', {
29-
'error': 'error',
30-
'line': '18',
31-
'col': '4',
32-
'warning': None,
32+
'error_type': 'error',
33+
'line': 17,
34+
'col': 3,
3335
'message': 'No return value expected'})
3436

3537
self.assertMatch(
3638
'/path/to/package/module.py:40: error: "dict" is not subscriptable, use "typing.Dict" instead', {
37-
'error': 'error',
38-
'line': '40',
39+
'error_type': 'error',
40+
'line': 39,
3941
'col': None,
40-
'warning': None,
4142
'message': '"dict" is not subscriptable, use "typing.Dict" instead'})
4243

4344
def test_tmp_files_that_have_no_file_extension(self):
4445
self.assertMatch(
45-
'/tmp/yoeai32h2:6:0: error: Cannot find module named \'PackageName.lib\'', {
46-
'error': 'error',
47-
'line': '6',
48-
'col': '0',
49-
'warning': None,
46+
'/tmp/yoeai32h2:6:1: error: Cannot find module named \'PackageName.lib\'', {
47+
'error_type': 'error',
48+
'line': 5,
49+
'col': 0,
5050
'message': 'Cannot find module named \'PackageName.lib\''})

0 commit comments

Comments
 (0)