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
|
import sys
import unittest
import helpers
class TestCompileErrors(unittest.TestCase):
def test_all(self):
self.maxDiff = None
import os
from subprocess import Popen, PIPE
# Find all the python files
py_files = []
for root, dirs, files in os.walk("."):
for file in files:
if file.lower().endswith(".py"):
py_files.append(os.path.join(root, file).lstrip(".\\").lstrip('/'))
# Compile the files and check for errors
command = sys.executable + " -Wall -m py_compile " + ' '.join(py_files)
p1 = Popen(command.split(' '), stdout=PIPE, stderr=PIPE, stdin=PIPE)
p1_stdout, p1_stderr = p1.communicate()
p1_stdout = p1_stdout.decode(encoding='UTF-8')
p1_stderr = p1_stderr.decode(encoding='UTF-8')
# Check for no errors
self.assertEqual("", p1_stderr)
self.assertEqual("", p1_stdout)
self.assertEqual(0, p1.returncode)
|