-
Notifications
You must be signed in to change notification settings - Fork 17
/
runlint_test.py
executable file
·47 lines (33 loc) · 1.41 KB
/
runlint_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python3
import os
import unittest
import runlint
class TestBlacklist(unittest.TestCase):
_BLACKLIST = 'lint_blacklist_for_testing.txt'
def setUp(self):
# This test only works if we're in the directory we are linting, sigh.
self.addCleanup(lambda d=os.getcwd(): os.chdir(d))
os.chdir(os.path.dirname(__file__))
def assert_in_blacklist(self, fname):
self.assertTrue(runlint._file_in_blacklist(fname, self._BLACKLIST))
def assert_not_in_blacklist(self, fname):
self.assertFalse(runlint._file_in_blacklist(fname, self._BLACKLIST))
def test_simple(self):
self.assert_in_blacklist('main.py')
self.assert_not_in_blacklist('main.p')
self.assert_not_in_blacklist('main.pyy')
def test_directory(self):
self.assert_in_blacklist('vendor')
self.assert_in_blacklist('vendor/baz/bang')
def test_leading_starstar(self):
self.assert_in_blacklist('compressed.js')
self.assert_in_blacklist('foo/compressed.js')
self.assert_in_blacklist('foo/bar/compressed.js')
def test_dir_detection(self):
self.assert_in_blacklist('runlint.py')
self.assert_not_in_blacklist('runlint.py/foo')
self.assert_in_blacklist('main.py')
# This is in the blacklist because main.py does not exist.
self.assert_in_blacklist('main.py/foo')
if __name__ == '__main__':
unittest.main()