Commits

Jakub Wilk  committed a97e39a

test_examples: port to Python 3.

  • Participants
  • Parent commits aed1d1f

Comments (0)

Files changed (1)

File test_examples.py

 
 import os
 import glob
+import stat
 import tempfile
 import subprocess as ipc
 
 			input_filename = os.devnull
 		output_filename = base_name + '.output'
 		rc, stderr = self._compile(filename)
+		stderr = stderr.decode()
 		assert_equal(stderr, '')
 		assert_equal(rc, 0)
-		with open(input_filename, 'r') as input_file:
+		with open(input_filename, 'rb') as input_file:
 			child = ipc.Popen(self.runner + [self.executable],
 				stdin=input_file,
 				stdout=ipc.PIPE,
 			stdout = child.stdout.read()
 			stderr = child.stderr.read()
 			rc = child.wait()
+		stderr = stderr.decode()
 		assert_equal(stderr, '')
 		assert_equal(rc, 0)
-		with open(output_filename, 'r') as output_file:
+		with open(output_filename, 'rb') as output_file:
 			expected_stdout = output_file.read()
 		assert_equal(stdout, expected_stdout)
 
 		base_name, _ = os.path.splitext(filename)
 		error_filename = base_name + '.error'
 		rc, stderr = self._compile(filename, output_filename=os.devnull)
+		stderr = stderr.decode()
 		assert_not_equal(rc, 0)
 		with open(error_filename, 'r') as error_file:
 			expected_stderr = error_file.read()
 	def setup(self):
 		fd, self.executable = tempfile.mkstemp(prefix='jtc-testsuite.')
 		os.close(fd)
-		os.chmod(self.executable, 0700)
+		os.chmod(self.executable, stat.S_IRWXU)
 
 	def teardown(self):
 		os.unlink(self.executable)