Skip to content

Commit

Permalink
testing: making tests portable between python2 and python3
Browse files Browse the repository at this point in the history
  • Loading branch information
jbohren committed Sep 23, 2014
1 parent fc8a3cd commit 262a8ac
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion catkin_tools/runner/run_unix.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
def process_incomming_lines(lines, left_over):
if not lines:
return None, left_over
if lines[-1].endswith('\n'):
if lines[-1].rstrip() != lines[-1]:
data = b''.join(lines)
left_over = b''
else:
Expand Down
2 changes: 1 addition & 1 deletion catkin_tools/verbs/catkin_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def get_ready_packages(packages, running_jobs, completed):
ready_packages = []
workspace_packages = [(path, pkg) for path, pkg in packages]
for path, package in packages:
if package.name in (running_jobs.keys() + completed):
if package.name in (list(running_jobs.keys()) + completed):
continue
# Collect build and buildtool depends, plus recursive build, buildtool, and run depends,
# Excluding depends which are not in the workspace or which are completed
Expand Down
5 changes: 3 additions & 2 deletions catkin_tools/verbs/catkin_create/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def prepare_arguments(parser):
help='The name of one or more packages to create. This name should be '
'completely lower-case with individual words separated by undercores.')

add('-p', '--path', required=False, default=None,
add('-p', '--path', action='store', default=os.getcwd(),
help='The path into which the package should be generated.')

# TODO: Make this possible
Expand Down Expand Up @@ -115,7 +115,8 @@ def prepare_arguments(parser):
def main(opts):

try:
package_dest_path = opts.path or os.getcwd()
package_dest_path = opts.path
print('path: '+str(opts.path))
for package_name in opts.name:
print('Creating package "%s" in "%s"...' % (package_name, package_dest_path))
target_path = os.path.join(package_dest_path, package_name)
Expand Down
2 changes: 1 addition & 1 deletion tests/integrated/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_build_auto_init_one_pkg():
print("Creating source directory: %s" % source_space)
os.mkdir(source_space)
assert_cmd_success(['catkin', 'create', 'pkg', '--rosdistro', 'hydro', '-p', source_space, 'pkg_a'])
out = assert_cmd_success(['catkin', 'build'])
out = assert_cmd_success(['catkin', 'build', '--no-notify'])
assert_no_warnings(out)
assert_workspace_initialized('.')

4 changes: 2 additions & 2 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,15 @@ def run(args, **kwargs):
Call to Popen, returns (errcode, stdout, stderr)
"""
print("run:", args)
with tempfile.TemporaryFile(mode='w+b') as temp_buffer:
with tempfile.NamedTemporaryFile(mode='w+b') as temp_buffer:
p = subprocess.Popen(
args,
bufsize=1,
stdout=temp_buffer,
stderr=subprocess.STDOUT,
universal_newlines=True,
cwd=kwargs.get('cwd', os.getcwd()))
print("P==", p.__dict__)
print("Dumping stdout to: "+ temp_buffer.name)
p.wait()
temp_buffer.seek(0)
stdout = temp_buffer.read()
Expand Down

0 comments on commit 262a8ac

Please sign in to comment.