Backed out 2 changesets (bug 1943998) for causing wd failures @ phases.py CLOSED...
[gecko.git] / tools / lint / test / test_black.py
blobdf0e792e68ae8c69beeec0cf62075d1a69935f3b
1 # -*- coding: utf-8 -*-
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 import mozunit
9 LINTER = "black"
10 fixed = 0
13 def test_lint_fix(lint, create_temp_file):
14 contents = """def is_unique(
17 s = list(s
19 s.sort()
22 for i in range(len(s) - 1):
23 if s[i] == s[i + 1]:
24 return 0
25 else:
26 return 1
29 if __name__ == "__main__":
30 print(
31 is_unique(input())
32 ) """
34 path = create_temp_file(contents, "bad.py")
35 lint([path], fix=True)
36 assert fixed == 1
39 def test_lint_black(lint, paths):
40 results = lint(paths())
41 assert len(results) == 2
43 assert results[0].level == "error"
44 assert results[0].relpath == "bad.py"
46 assert "EOF" in results[1].message
47 assert results[1].level == "error"
48 assert results[1].relpath == "invalid.py"
51 if __name__ == "__main__":
52 mozunit.main()