-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pysqa command which raises an exception (#465)
* Add pysqa command which raises an exception * fix type hints * fix tests * another test * more fixes * add shell option
- Loading branch information
1 parent
b41acba
commit c65100b
Showing
2 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import unittest | ||
|
||
try: | ||
from executorlib.standalone.cache.queue import _pysqa_execute_command | ||
|
||
skip_pysqa_test = False | ||
except ImportError: | ||
skip_pysqa_test = True | ||
|
||
|
||
@unittest.skipIf( | ||
skip_pysqa_test, "pysqa is not installed, so the pysqa tests are skipped." | ||
) | ||
class TestPysqaExecuteCommand(unittest.TestCase): | ||
def test_pysqa_execute_command_list(self): | ||
out = _pysqa_execute_command( | ||
commands=["echo", "test"], | ||
working_directory=None, | ||
split_output=True, | ||
shell=True, | ||
error_filename="pysqa.err", | ||
) | ||
self.assertEqual(len(out), 2) | ||
self.assertEqual("test", out[0]) | ||
|
||
def test_pysqa_execute_command_string(self): | ||
out = _pysqa_execute_command( | ||
commands="echo test", | ||
working_directory=None, | ||
split_output=False, | ||
shell=False, | ||
error_filename="pysqa.err", | ||
) | ||
self.assertEqual(len(out), 5) | ||
self.assertEqual("test\n", out) | ||
|
||
def test_pysqa_execute_command_fail(self): | ||
with self.assertRaises(FileNotFoundError): | ||
_pysqa_execute_command( | ||
commands=["no/executable/available"], | ||
working_directory=None, | ||
split_output=True, | ||
shell=False, | ||
error_filename="pysqa.err", | ||
) |