mirror of
https://github.com/rpm-software-management/tito.git
synced 2025-02-23 20:22:46 +00:00
resolve another use of commands module for python3 compat
03255001d6
moved commands module to src/tito/compat.py to handle
differences between python2 and python3, but missed a bit that
did not show up in unit or functional tests.
Fix those occurences and add unit test to detect the regression.
This commit is contained in:
parent
0e218077b3
commit
a0d0f859c7
3 changed files with 8 additions and 6 deletions
|
@ -144,7 +144,7 @@ class BuilderBase(object):
|
|||
"""
|
||||
if not self.no_cleanup:
|
||||
debug("Cleaning up [%s]" % self.rpmbuild_dir)
|
||||
commands.getoutput("rm -rf %s" % self.rpmbuild_dir)
|
||||
getoutput("rm -rf %s" % self.rpmbuild_dir)
|
||||
else:
|
||||
print("WARNING: Leaving rpmbuild files in: %s" % self.rpmbuild_dir)
|
||||
|
||||
|
@ -165,7 +165,7 @@ class BuilderBase(object):
|
|||
"""
|
||||
Create the build directories. Can safely be called multiple times.
|
||||
"""
|
||||
commands.getoutput("mkdir -p %s %s %s %s" % (
|
||||
getoutput("mkdir -p %s %s %s %s" % (
|
||||
self.rpmbuild_basedir, self.rpmbuild_dir,
|
||||
self.rpmbuild_sourcedir, self.rpmbuild_builddir))
|
||||
self._check_build_dirs_access()
|
||||
|
|
|
@ -43,7 +43,4 @@ def getoutput(cmd):
|
|||
Returns output of executing cmd in a shell.
|
||||
Supports Python 2.4 and 3.x.
|
||||
"""
|
||||
if PY2:
|
||||
return commands.getoutput(cmd)
|
||||
else:
|
||||
return subprocess.getoutput(cmd)
|
||||
return getstatusoutput(cmd)[1]
|
||||
|
|
|
@ -90,6 +90,11 @@ class UglyHackishTest(TitoUnitTestFixture):
|
|||
result = int(getoutput(cmd))
|
||||
self.assertEqual(result, 0, "Found commands module (not supported in Python 3)")
|
||||
|
||||
def test_use_commands(self):
|
||||
cmd = "find . -type f -regex '.*\.py$' -exec egrep '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))
|
||||
|
|
Loading…
Add table
Reference in a new issue