Debian Codegraph @

tests/test_compile_errors.py

raw
1
2
3 import sys
4 import unittest
5 import helpers
6
7
8 class TestCompileErrors(unittest.TestCase):
9 def test_all(self):
10 self.maxDiff = None
11
12 import os
13 from subprocess import Popen, PIPE
14
15 # Find all the python files
16 py_files = []
17 for root, dirs, files in os.walk("."):
18 for file in files:
19 if file.lower().endswith(".py"):
20 py_files.append(os.path.join(root, file).lstrip(".\\").lstrip('/'))
21
22
23 # Compile the files and check for errors
24 command = sys.executable + " -Wall -m py_compile " + ' '.join(py_files)
25 p1 = Popen(command.split(' '), stdout=PIPE, stderr=PIPE, stdin=PIPE)
26 p1_stdout, p1_stderr = p1.communicate()
27
28 p1_stdout = p1_stdout.decode(encoding='UTF-8')
29 p1_stderr = p1_stderr.decode(encoding='UTF-8')
30
31 # Check for no errors
32 self.assertEqual("", p1_stderr)
33 self.assertEqual("", p1_stdout)
34 self.assertEqual(0, p1.returncode)