def test_utf8_with_ascii_only_constructor(self): """ Check that the single argument constructor of UnitLabel sets an appropriate UTF-8 string when a non-ascii string is passed. """ microseconds = u"\u00B5s" label = UnitLabel(microseconds) self.assertEqual(microseconds, label.utf8())
def test_unicode_function_produces_unicode_string_from_label_py2(self): if sys.version_info[0] < 3: label = UnitLabel("MyLabel", u"\u03bcs","\mu s") self.assertTrue(isinstance(unicode(label), six.text_type)) self.assertEquals(u"\u03bcs", unicode(label)) else: pass
def test_str_function_produces_ascii_string_from_label(self): label = UnitLabel("MyLabel", u"\u03bcs","\mu s") self.assertTrue(isinstance(str(label), six.string_types)) self.assertEquals("MyLabel", str(label))
def test_UnitLabel_can_be_built_simple_string_and_unicode_object(self): label = UnitLabel("MyLabel", u"\u03bcs","\mu s") self.assertEquals("MyLabel", label.ascii()) self.assertEquals(u"\u03bcs", label.utf8()) self.assertEquals("\mu s", label.latex())
def test_UnitLabel_can_be_built_from_simple_string(self): label = UnitLabel("MyLabel") self.assertEquals("MyLabel", label.ascii())
def test_unicode_function_produces_unicode_string_from_label(self): label = UnitLabel("MyLabel", u"\u03bcs", "\mu s") self.assertTrue(isinstance(unicode(label), types.UnicodeType)) self.assertEquals(u"\u03bcs", unicode(label))