-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert argument to str in
aiida.common.escaping.escape_for_bash
Without conversion to string, any non-string type will cause the function to raise an `AttributeError` since it won't have the method `str_replace`.
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 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,18 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Tests for the :mod:`aiida.common.escaping`.""" | ||
from aiida.common.escaping import escape_for_bash | ||
|
||
|
||
def test_escape_for_bash(): | ||
"""Tests various inputs for `aiida.common.escaping.escape_for_bash`.""" | ||
tests = ( | ||
[None, ''], | ||
['string', "'string'"], | ||
['string with space', "'string with space'"], | ||
["string with a ' single quote", """'string with a '"'"' single quote'"""], | ||
[1, "'1'"], | ||
[2.0, "'2.0'"], | ||
) | ||
|
||
for string_input, string_escaped in tests: | ||
assert escape_for_bash(string_input) == string_escaped |