|
8 | 8 | from executorlib.shared.spawner import MpiExecSpawner
|
9 | 9 |
|
10 | 10 |
|
11 |
| -def submit_shell_command(command: list, universal_newlines: bool = True, shell: bool = False): |
12 |
| - return subprocess.check_output(command, universal_newlines=universal_newlines, shell=shell) |
| 11 | +def submit_shell_command( |
| 12 | + command: list, universal_newlines: bool = True, shell: bool = False |
| 13 | +): |
| 14 | + return subprocess.check_output( |
| 15 | + command, universal_newlines=universal_newlines, shell=shell |
| 16 | + ) |
13 | 17 |
|
14 | 18 |
|
15 | 19 | class SubprocessExecutorTest(unittest.TestCase):
|
@@ -77,31 +81,51 @@ def test_broken_executable(self):
|
77 | 81 |
|
78 | 82 | def test_shell_static_executor_args(self):
|
79 | 83 | with Executor(max_workers=1) as exe:
|
80 |
| - future = exe.submit(submit_shell_command, ["echo", "test"], universal_newlines=True, shell=False) |
| 84 | + future = exe.submit( |
| 85 | + submit_shell_command, |
| 86 | + ["echo", "test"], |
| 87 | + universal_newlines=True, |
| 88 | + shell=False, |
| 89 | + ) |
81 | 90 | self.assertFalse(future.done())
|
82 | 91 | self.assertEqual("test\n", future.result())
|
83 | 92 | self.assertTrue(future.done())
|
84 | 93 |
|
85 | 94 | def test_shell_static_executor_binary(self):
|
86 | 95 | with Executor(max_workers=1) as exe:
|
87 |
| - future = exe.submit(submit_shell_command, ["echo", "test"], universal_newlines=False, shell=False) |
| 96 | + future = exe.submit( |
| 97 | + submit_shell_command, |
| 98 | + ["echo", "test"], |
| 99 | + universal_newlines=False, |
| 100 | + shell=False, |
| 101 | + ) |
88 | 102 | self.assertFalse(future.done())
|
89 | 103 | self.assertEqual(b"test\n", future.result())
|
90 | 104 | self.assertTrue(future.done())
|
91 | 105 |
|
92 | 106 | def test_shell_static_executor_shell(self):
|
93 | 107 | with Executor(max_workers=1) as exe:
|
94 |
| - future = exe.submit(submit_shell_command, "echo test", universal_newlines=True, shell=True) |
| 108 | + future = exe.submit( |
| 109 | + submit_shell_command, "echo test", universal_newlines=True, shell=True |
| 110 | + ) |
95 | 111 | self.assertFalse(future.done())
|
96 | 112 | self.assertEqual("test\n", future.result())
|
97 | 113 | self.assertTrue(future.done())
|
98 | 114 |
|
99 | 115 | def test_shell_executor(self):
|
100 | 116 | with Executor(max_workers=2) as exe:
|
101 |
| - f_1 = exe.submit(submit_shell_command, ["echo", "test_1"], universal_newlines=True) |
102 |
| - f_2 = exe.submit(submit_shell_command, ["echo", "test_2"], universal_newlines=True) |
103 |
| - f_3 = exe.submit(submit_shell_command, ["echo", "test_3"], universal_newlines=True) |
104 |
| - f_4 = exe.submit(submit_shell_command, ["echo", "test_4"], universal_newlines=True) |
| 117 | + f_1 = exe.submit( |
| 118 | + submit_shell_command, ["echo", "test_1"], universal_newlines=True |
| 119 | + ) |
| 120 | + f_2 = exe.submit( |
| 121 | + submit_shell_command, ["echo", "test_2"], universal_newlines=True |
| 122 | + ) |
| 123 | + f_3 = exe.submit( |
| 124 | + submit_shell_command, ["echo", "test_3"], universal_newlines=True |
| 125 | + ) |
| 126 | + f_4 = exe.submit( |
| 127 | + submit_shell_command, ["echo", "test_4"], universal_newlines=True |
| 128 | + ) |
105 | 129 | self.assertFalse(f_1.done())
|
106 | 130 | self.assertFalse(f_2.done())
|
107 | 131 | self.assertFalse(f_3.done())
|
|
0 commit comments