From de534f85507344e45303c55165cd9723ce474c40 Mon Sep 17 00:00:00 2001 From: KongQun Yang Date: Thu, 31 Jan 2019 18:33:25 -0800 Subject: [PATCH] Make packager_test.py work with python 3.0 Use logging instead of print. Fixes #553. Change-Id: I46b9a5bb9bb5d4cb03ddd94163905aebc4b4e9dd --- packager/app/test/packager_app.py | 3 ++- packager/app/test/packager_test.py | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packager/app/test/packager_app.py b/packager/app/test/packager_app.py index bb909fb124..81da80bcce 100644 --- a/packager/app/test/packager_app.py +++ b/packager/app/test/packager_app.py @@ -7,6 +7,7 @@ # https://developers.google.com/open-source/licenses/bsd """Test wrapper for the sample packager binaries.""" +import logging import os import platform import subprocess @@ -68,7 +69,7 @@ class PackagerApp(object): self.packaging_command_line = ' '.join(["'%s'" % entry for entry in cmd]) packaging_result = subprocess.call(cmd, env=self.GetEnv()) 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 def GetCommandLine(self): diff --git a/packager/app/test/packager_test.py b/packager/app/test/packager_test.py index 8ddcf92852..1759837b66 100755 --- a/packager/app/test/packager_test.py +++ b/packager/app/test/packager_test.py @@ -9,6 +9,7 @@ import filecmp import glob +import logging import os import re import shutil @@ -192,7 +193,7 @@ def _UpdateMpdTimes(mpd_filepath): if m: old = m.group(0) out = str_in.replace(old, new) - print 'Replacing "%s" with "%s"' % (old, new) + logging.info('Replacing "%s" with "%s"', old, new) else: out = str_in @@ -233,6 +234,7 @@ def GetSegmentedExtension(base_extension): class PackagerAppTest(unittest.TestCase): def setUp(self): + super(PackagerAppTest, self).setUp() self.packager = packager_app.PackagerApp() self.tmp_dir = tempfile.mkdtemp() self.test_data_dir = os.path.join(test_env.SRC_DIR, 'packager', 'media', @@ -262,6 +264,7 @@ class PackagerAppTest(unittest.TestCase): def tearDown(self): if test_env.options.remove_temp_files_after_test: shutil.rmtree(self.tmp_dir) + super(PackagerAppTest, self).tearDown() def _GetStream(self, descriptor, @@ -1488,7 +1491,7 @@ class PackagerFunctionalTest(PackagerAppTest): test_files=['bear-1280x720.mp4', 'bear-640x360.mp4', 'bear-320x180.mp4']), flags) with open(self.mpd_output, 'rb') as f: - print f.read() + logging.info(f.read()) # TODO(kqyang): Add some validations. @unittest.skipUnless(test_env.has_aes_flags, 'Requires AES credentials.')