2020-10-17 15:08:45 +02:00
|
|
|
import logging
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_which(caplog):
|
|
|
|
|
caplog.set_level(logging.INFO)
|
|
|
|
|
caplog.set_level(logging.DEBUG, logger="cryptoadvance.specter")
|
|
|
|
|
import cryptoadvance.specter.util.shell as helpers
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
helpers.which("some_non_existing_binary")
|
|
|
|
|
assert False, "Should raise an Exception"
|
|
|
|
|
except:
|
|
|
|
|
pass
|
|
|
|
|
assert (
|
|
|
|
|
helpers.which("date") == "/bin/date" or helpers.which("date") == "/usr/bin/date"
|
|
|
|
|
) # travis-CI has it on /bin/date
|
2021-03-26 12:21:26 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_last_lines(caplog):
|
|
|
|
|
from cryptoadvance.specter.util.shell import get_last_lines_from_file
|
|
|
|
|
|
|
|
|
|
lines = get_last_lines_from_file("LICENSE", 30)
|
|
|
|
|
assert lines[-2].startswith("OUT OF OR IN CONNECTION WITH THE SOFTWARE ")
|
2022-03-21 13:57:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_grep():
|
|
|
|
|
from cryptoadvance.specter.util.shell import grep
|
|
|
|
|
|
2023-02-15 14:58:33 +01:00
|
|
|
assert grep("./pyproject.toml", 'name = "cryptoadvance.specter"')
|