File: test_compile_errors.py

package info (click to toggle)
python-cpuinfo 9.0.0%2Bgit20221119-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 892 kB
  • sloc: python: 11,917; makefile: 74
file content (34 lines) | stat: -rw-r--r-- 866 bytes parent folder | download
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)