utils_test.py 720 B

123456789101112131415161718192021222324
  1. """Test functions in grass.script.utils"""
  2. import grass.script as gs
  3. def test_named_separators():
  4. """Check that named separtors are recognized and correctly evaluated"""
  5. assert gs.separator("pipe") == "|"
  6. assert gs.separator("comma") == ","
  7. assert gs.separator("space") == " "
  8. assert gs.separator("tab") == "\t"
  9. assert gs.separator("newline") == "\n"
  10. def test_backslash_separators():
  11. """Check that separtors specified as an escape sequence are correctly evaluated"""
  12. assert gs.separator(r"\t") == "\t"
  13. assert gs.separator(r"\n") == "\n"
  14. def test_unrecognized_separator():
  15. """Check that unknown strings are just passed through"""
  16. assert gs.separator("apple") == "apple"