From b54c32c861b517b889b1cd6c0bbe082b8d93e5d2 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 22 Jul 2015 17:15:07 +0200 Subject: tests: is_string is now in Bcfg2.Utils --- testsuite/Testsrc/Testlib/TestUtils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'testsuite/Testsrc/Testlib/TestUtils.py') 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')) -- cgit v1.2.3-1-g7c22