summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/Testlib/TestUtils.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2015-07-22 17:15:07 +0200
committerAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2015-07-22 17:15:07 +0200
commitb54c32c861b517b889b1cd6c0bbe082b8d93e5d2 (patch)
tree0deb7db3dc8c8de428665385086620fd74c1ae02 /testsuite/Testsrc/Testlib/TestUtils.py
parent06a6fce3f2f5c78a12937d4e52de3d824e3dd5e0 (diff)
downloadbcfg2-b54c32c861b517b889b1cd6c0bbe082b8d93e5d2.tar.gz
bcfg2-b54c32c861b517b889b1cd6c0bbe082b8d93e5d2.tar.bz2
bcfg2-b54c32c861b517b889b1cd6c0bbe082b8d93e5d2.zip
tests: is_string is now in Bcfg2.Utils
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestUtils.py')
-rw-r--r--testsuite/Testsrc/Testlib/TestUtils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/testsuite/Testsrc/Testlib/TestUtils.py b/testsuite/Testsrc/Testlib/TestUtils.py
index 4bed67248..a37f2ecbe 100644
--- a/testsuite/Testsrc/Testlib/TestUtils.py
+++ b/testsuite/Testsrc/Testlib/TestUtils.py
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
import os
import sys
from Bcfg2.Utils import *
@@ -42,3 +43,17 @@ class TestPackedDigitRange(Bcfg2TestCase):
for test in exc:
self.assertNotIn(test, rng)
self.assertFalse(rng.includes(test))
+
+
+class TestIsString(Bcfg2TestCase):
+ def test_is_string(self):
+ for char in list(range(8)) + list(range(14, 32)):
+ self.assertFalse(is_string("foo" + chr(char) + "bar", 'UTF-8'))
+ for char in list(range(9, 14)) + list(range(33, 128)):
+ self.assertTrue(is_string("foo" + chr(char) + "bar", 'UTF-8'))
+
+ ustr = 'é'
+ self.assertTrue(is_string(ustr, 'UTF-8'))
+ if not inPy3k:
+ self.assertFalse(is_string("foo" + chr(128) + "bar", 'ascii'))
+ self.assertFalse(is_string(ustr, 'ascii'))