diff options
author | 2022-11-28 10:33:07 +0800 | |
---|---|---|
committer | 2022-11-28 10:33:07 +0800 | |
commit | 407e6b2079ea9f73f52e4972147620d765d96349 (patch) | |
tree | e8cd821ad27212178337611df05bba30e65160ba /tests/test_nsjail.py | |
parent | Add assertions for test_unmount_flags (diff) |
Refactor FileAttachment as non generic
Diffstat (limited to 'tests/test_nsjail.py')
-rw-r--r-- | tests/test_nsjail.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_nsjail.py b/tests/test_nsjail.py index ccbca56..839d3ec 100644 --- a/tests/test_nsjail.py +++ b/tests/test_nsjail.py @@ -26,7 +26,7 @@ class NsJailTests(unittest.TestCase): return self.nsjail.python3(["-c", code]) def eval_file(self, code: str, name: str = "test.py", **kwargs): - file = FileAttachment(name, code) + file = FileAttachment(name, code.encode()) return self.nsjail.python3([name], [file], **kwargs) def test_print_returns_0(self): @@ -59,8 +59,8 @@ class NsJailTests(unittest.TestCase): def test_multi_files(self): files = [ - FileAttachment("main.py", "import lib; print(lib.x)"), - FileAttachment("lib.py", "x = 'hello'"), + FileAttachment("main.py", "import lib; print(lib.x)".encode()), + FileAttachment("lib.py", "x = 'hello'".encode()), ] result = self.nsjail.python3(["main.py"], files) @@ -209,7 +209,7 @@ class NsJailTests(unittest.TestCase): def test_file_write_error(self): """Test errors during file write.""" - result = self.nsjail.python3([""], [FileAttachment("output", "hello")]) + result = self.nsjail.python3([""], [FileAttachment("output", "hello".encode())]) self.assertEqual(result.returncode, None) self.assertEqual(result.stdout, "IsADirectoryError: Failed to create file 'output'.") |