Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_FT_subcomponent_escape(self):
ft = FT('&subcomponent&')
self.assertEqual(ft.to_er7(), '\\T\\subcomponent\\T\\')
def test_FT_maxlength(self):
ft_str = 'a' * (FT(' ').max_length + 1)
FT(ft_str) # no exception is raised here
def test_FT_repetition_escape(self):
ft = FT('~repetition~')
self.assertEqual(ft.to_er7(), '\\R\\repetition\\R\\')
def test_FT(self):
text = 'This is a FT datatype text'
ft = FT(text)
self.assertEqual(ft.classname, 'FT')
self.assertEqual(ft.to_er7(), text)
def test_FT_field_escaping(self):
ft = FT('|field|')
self.assertEqual(ft.to_er7(), '\\F\\field\\F\\')
def test_FT_maxlength_strict(self):
ft = 'a' * (FT(' ').max_length + 1)
self.assertRaises(MaxLengthReached, FT, ft, validation_level=VALIDATION_LEVEL.STRICT)
def test_FT_component_escape(self):
ft = FT('^component^')
self.assertEqual(ft.to_er7(), '\\S\\component\\S\\')
def test_FT_invalid_highlight_range(self):
ft = FT('HIGHLIGHTEDTEXTIMPORTANT', highlights=((0, 11), (4, 24)))
self.assertRaises(InvalidHighlightRange, ft.to_er7)
ft = FT('HIGHLIGHTEDTEXTIMPORTANT', highlights=((4, 24), (0, 11)))
self.assertRaises(InvalidHighlightRange, ft.to_er7)
ft = FT('HIGHLIGHTEDTEXTIMPORTANT', highlights=((5, 11), (0, 11)))
self.assertRaises(InvalidHighlightRange, ft.to_er7)
ft = FT('HIGHLIGHTEDTEXTIMPORTANT', highlights=((0, 11), (0, 4)))
self.assertRaises(InvalidHighlightRange, ft.to_er7)
def __init__(self, value, highlights=None,
validation_level=None):
super(FT, self).__init__(value, 65536, highlights, validation_level)