Skip to content

Commit c895c1d

Browse files
author
Toto Lin
authored
Merge pull request #44 from YanWQ-monad/master
Fix filename bug
2 parents 581b666 + bddea4e commit c895c1d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

cyaron/io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def __init_file(self, f, data_id, file_type):
7272
self.__output_temp = True
7373
else:
7474
# consider ``f`` as filename template
75-
filename = f.format(data_id)
75+
filename = f.format(data_id or '')
7676
if file_type == 'i':
7777
self.input_filename = filename
7878
log.debug("Processing %s" % self.input_filename)

cyaron/tests/io_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ def test_create_files_prefix_id(self):
3030
self.assertTrue(os.path.exists("test_prefix233.inp"))
3131
self.assertTrue(os.path.exists("test_prefix233.ans"))
3232

33+
def test_create_files_without_prefix_id(self):
34+
with captured_output() as (out, err):
35+
IO(file_prefix="test_prefix")
36+
self.assertTrue(os.path.exists("test_prefix.in"))
37+
self.assertTrue(os.path.exists("test_prefix.out"))
38+
3339
def test_write_stuff(self):
3440
with captured_output() as (out, err):
3541
with IO("test_write.in", "test_write.out") as test:

0 commit comments

Comments
 (0)