Skip to content

Commit

Permalink
update unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
Cathy0908 committed Dec 24, 2024
1 parent ae28aca commit c526a17
Showing 1 changed file with 27 additions and 14 deletions.
41 changes: 27 additions & 14 deletions tests/tools/test_process_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,33 @@


def run_in_subprocess(cmd):
result = subprocess.run(
cmd,
shell=True,
capture_output=True,
text=True
)

if result.returncode != 0:
print(f"Command failed with return code {result.returncode}")
print(f"Standard Output: {result.stdout}")
print(f"Standard Error: {result.stderr}")
raise subprocess.CalledProcessError(result, cmd)

return result
try:
with subprocess.Popen(
cmd, shell=True, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) as return_info:
while True:
next_line = return_info.stdout.readline()
return_line = next_line.decode('utf-8', 'ignore').strip()
if return_line == '' and return_info.poll() != None:
break
if return_line != '':
print(return_line)

err_lines = ''
while True:
next_line = return_info.stderr.readline()
return_line = next_line.decode('utf-8', 'ignore').strip()
if return_line == '' and return_info.poll() != None:
break
if return_line != '':
print(return_line)
err_lines += return_line + '\n'

return_code = return_info.wait()
if return_code:
raise RuntimeError(err_lines)
except Exception as e:
raise e


class ProcessDataTest(DataJuicerTestCaseBase):
Expand Down

0 comments on commit c526a17

Please sign in to comment.