mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 12:12:47 +00:00
add unit test and use print function for python3 compat
Python 3 does not have the print statement, so convert all print statements to print functions and add an ugly duckling unit test to detect regressions.
This commit is contained in:
parent
03255001d6
commit
22896be9ce
6 changed files with 20 additions and 15 deletions
|
@ -224,7 +224,7 @@ class BuilderBase(object):
|
|||
try:
|
||||
output = run_command(cmd)
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
print ""
|
||||
print("")
|
||||
exit(1)
|
||||
except RunCommandException:
|
||||
err = sys.exc_info()[1]
|
||||
|
|
|
@ -351,13 +351,13 @@ def scl_to_rpm_option(scl, silent=None):
|
|||
output = run_command(cmd).rstrip()
|
||||
if scl:
|
||||
if (output != scl) and (output != "%scl") and not silent:
|
||||
print "Warning: Meta package of software collection %s installed, but --scl defines %s" % (output, scl)
|
||||
print " Redefining scl macro to %s for this package." % scl
|
||||
print("Warning: Meta package of software collection %s installed, but --scl defines %s" % (output, scl))
|
||||
print(" Redefining scl macro to %s for this package." % scl)
|
||||
rpm_options += " --define 'scl %s'" % scl
|
||||
else:
|
||||
if (output != "%scl") and (not silent):
|
||||
print "Warning: Meta package of software collection %s installed, but --scl is not present." % output
|
||||
print " Undefining scl macro for this package."
|
||||
print("Warning: Meta package of software collection %s installed, but --scl is not present." % output)
|
||||
print(" Undefining scl macro for this package.")
|
||||
# can be replaced by "--undefined scl" when el6 and fc17 is retired
|
||||
rpm_options += " --eval '%undefine scl'"
|
||||
return rpm_options
|
||||
|
|
|
@ -66,8 +66,8 @@ class CoprReleaser(KojiReleaser):
|
|||
self.print_dry_run_warning(cmd_submit)
|
||||
return
|
||||
if not self.srpm_submitted:
|
||||
print "Uploading src.rpm."
|
||||
print run_command(cmd_upload)
|
||||
print("Uploading src.rpm.")
|
||||
print(run_command(cmd_upload))
|
||||
self.srpm_submitted = srpm_location
|
||||
print "Submiting build into %s." % self.NAME
|
||||
print run_command(cmd_submit)
|
||||
print("Submiting build into %s." % self.NAME)
|
||||
print(run_command(cmd_submit))
|
||||
|
|
|
@ -83,7 +83,7 @@ class ObsReleaser(Releaser):
|
|||
os.lseek(fd, 0, 0)
|
||||
commit_file = os.fdopen(fd)
|
||||
for line in commit_file.readlines():
|
||||
print line
|
||||
print(line)
|
||||
commit_file.close()
|
||||
|
||||
print("")
|
||||
|
@ -133,7 +133,7 @@ class ObsReleaser(Releaser):
|
|||
else:
|
||||
print("Proceeding with commit.")
|
||||
os.chdir(self.package_workdir)
|
||||
print run_command(cmd)
|
||||
print(run_command(cmd))
|
||||
|
||||
os.unlink(commit_msg_file)
|
||||
|
||||
|
|
|
@ -470,7 +470,7 @@ class YumRepoReleaser(RsyncReleaser):
|
|||
hdr = self._read_rpm_header(rpm_ts, full_path)
|
||||
except rpm.error:
|
||||
e = sys.exc_info()[1]
|
||||
print "error reading rpm header in '%s': %s" % (full_path, e)
|
||||
print("error reading rpm header in '%s': %s" % (full_path, e))
|
||||
continue
|
||||
if hdr['name'] in self.new_rpm_dep_sets:
|
||||
dep_set = hdr.dsOfHeader()
|
||||
|
@ -559,7 +559,7 @@ class FedoraGitReleaser(Releaser):
|
|||
os.lseek(fd, 0, 0)
|
||||
file = os.fdopen(fd)
|
||||
for line in file.readlines():
|
||||
print line
|
||||
print(line)
|
||||
file.close()
|
||||
|
||||
print("")
|
||||
|
@ -692,7 +692,7 @@ class FedoraGitReleaser(Releaser):
|
|||
|
||||
# Print the task ID and URL:
|
||||
for line in extract_task_info(output):
|
||||
print line
|
||||
print(line)
|
||||
|
||||
def _git_upload_sources(self, project_checkout):
|
||||
"""
|
||||
|
@ -942,7 +942,7 @@ class CvsReleaser(Releaser):
|
|||
os.lseek(fd, 0, 0)
|
||||
file = os.fdopen(fd)
|
||||
for line in file.readlines():
|
||||
print line
|
||||
print(line)
|
||||
file.close()
|
||||
|
||||
print("")
|
||||
|
|
|
@ -89,3 +89,8 @@ class UglyHackishTest(TitoUnitTestFixture):
|
|||
cmd = "find . -type f -regex '.*\.py$' -exec egrep '^(import|from) commands\.' {} + | grep -v 'compat\.py' | wc -l"
|
||||
result = int(getoutput(cmd))
|
||||
self.assertEqual(result, 0, "Found commands module (not supported in Python 3)")
|
||||
|
||||
def test_print_function(self):
|
||||
cmd = "find . -type f -regex '.*\.py$' -exec grep '^[[:space:]]*print .*' {} + | wc -l"
|
||||
result = int(getoutput(cmd))
|
||||
self.assertEqual(result, 0, "Found print statement (not supported in Python 3)")
|
||||
|
|
Loading…
Add table
Reference in a new issue