Skip to content

Commit 4a1be41

Browse files
committed
test error function
1 parent 80d001b commit 4a1be41

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

tests/test_standalone_error.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import os
2+
import unittest
3+
from executorlib.standalone.error import backend_write_error_file
4+
5+
6+
class TestErrorWriter(unittest.TestCase):
7+
def test_backend_write_error_file(self):
8+
backend_write_error_file(
9+
error=ValueError(),
10+
apply_dict={
11+
"error_log_file": "error.out",
12+
"fn": 1,
13+
"args": (1, 2, 3),
14+
"kwargs": {"a": 1, "b": 2, "c": 3},
15+
}
16+
)
17+
error_file_content = [
18+
'function: 1\n',
19+
'args: (1, 2, 3)\n',
20+
"kwargs: {'a': 1, 'b': 2, 'c': 3}\n",
21+
'ValueError\n'
22+
]
23+
with open("error.out", "r") as f:
24+
content = f.readlines()
25+
self.assertEqual(error_file_content, content)
26+
27+
def tearDown(self):
28+
if os.path.exists("error.out"):
29+
os.remove("error.out")

0 commit comments

Comments
 (0)