Make packager_test.py work with python 3.0

Use logging instead of print.

Fixes #553.

Change-Id: I46b9a5bb9bb5d4cb03ddd94163905aebc4b4e9dd
This commit is contained in:
KongQun Yang 2019-01-31 18:33:25 -08:00
parent 72c4797a59
commit de534f8550
2 changed files with 7 additions and 3 deletions

View File

@ -7,6 +7,7 @@
# https://developers.google.com/open-source/licenses/bsd # https://developers.google.com/open-source/licenses/bsd
"""Test wrapper for the sample packager binaries.""" """Test wrapper for the sample packager binaries."""
import logging
import os import os
import platform import platform
import subprocess import subprocess
@ -68,7 +69,7 @@ class PackagerApp(object):
self.packaging_command_line = ' '.join(["'%s'" % entry for entry in cmd]) self.packaging_command_line = ' '.join(["'%s'" % entry for entry in cmd])
packaging_result = subprocess.call(cmd, env=self.GetEnv()) packaging_result = subprocess.call(cmd, env=self.GetEnv())
if packaging_result != 0: if packaging_result != 0:
print '%s returned non-0 status' % self.packaging_command_line logging.error('%s returned non-0 status', self.packaging_command_line)
return packaging_result return packaging_result
def GetCommandLine(self): def GetCommandLine(self):

View File

@ -9,6 +9,7 @@
import filecmp import filecmp
import glob import glob
import logging
import os import os
import re import re
import shutil import shutil
@ -192,7 +193,7 @@ def _UpdateMpdTimes(mpd_filepath):
if m: if m:
old = m.group(0) old = m.group(0)
out = str_in.replace(old, new) out = str_in.replace(old, new)
print 'Replacing "%s" with "%s"' % (old, new) logging.info('Replacing "%s" with "%s"', old, new)
else: else:
out = str_in out = str_in
@ -233,6 +234,7 @@ def GetSegmentedExtension(base_extension):
class PackagerAppTest(unittest.TestCase): class PackagerAppTest(unittest.TestCase):
def setUp(self): def setUp(self):
super(PackagerAppTest, self).setUp()
self.packager = packager_app.PackagerApp() self.packager = packager_app.PackagerApp()
self.tmp_dir = tempfile.mkdtemp() self.tmp_dir = tempfile.mkdtemp()
self.test_data_dir = os.path.join(test_env.SRC_DIR, 'packager', 'media', self.test_data_dir = os.path.join(test_env.SRC_DIR, 'packager', 'media',
@ -262,6 +264,7 @@ class PackagerAppTest(unittest.TestCase):
def tearDown(self): def tearDown(self):
if test_env.options.remove_temp_files_after_test: if test_env.options.remove_temp_files_after_test:
shutil.rmtree(self.tmp_dir) shutil.rmtree(self.tmp_dir)
super(PackagerAppTest, self).tearDown()
def _GetStream(self, def _GetStream(self,
descriptor, descriptor,
@ -1488,7 +1491,7 @@ class PackagerFunctionalTest(PackagerAppTest):
test_files=['bear-1280x720.mp4', 'bear-640x360.mp4', test_files=['bear-1280x720.mp4', 'bear-640x360.mp4',
'bear-320x180.mp4']), flags) 'bear-320x180.mp4']), flags)
with open(self.mpd_output, 'rb') as f: with open(self.mpd_output, 'rb') as f:
print f.read() logging.info(f.read())
# TODO(kqyang): Add some validations. # TODO(kqyang): Add some validations.
@unittest.skipUnless(test_env.has_aes_flags, 'Requires AES credentials.') @unittest.skipUnless(test_env.has_aes_flags, 'Requires AES credentials.')