Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add unit tests for participants_file and append_list_as_row #254

Merged
merged 13 commits into from
Jun 19, 2020
13 changes: 12 additions & 1 deletion phys2bids/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import json
import os

from csv import reader
from phys2bids import utils


Expand Down Expand Up @@ -95,3 +95,14 @@ def test_load_heuristics():
test_heuristic = 'heur_test_acq'
heuristic_output_filename = utils.load_heuristic(test_heuristic).filename
assert test_heuristic in heuristic_output_filename


# Test writing rows util
def append_list_as_row():
eurunuela marked this conversation as resolved.
Show resolved Hide resolved
file_name = 'test_row.tsv'
list_of_elem = ["01", 32, 'some_info', 182.98, 'M']
utils.append_list_as_row(file_name, list_of_elem)
with open(file_name, mode='r') as tsv:
tsv_read = reader(tsv, delimiter="\t")
for row in tsv_read:
assert len(row) == len(list_of_elem)
eurunuela marked this conversation as resolved.
Show resolved Hide resolved