def test_should_not_format_whitespace(self): formatter = GeneralFormatter() formattedText = formatter.format(' ', '\t') expect(formattedText).to_equal(None)
def test_should_identify_and_unindent_basic_xml(self): formatter = GeneralFormatter() formattedText = formatter.unindent( '<root>\n\t<child\na="123"></child>\n</root>') expect(formattedText).to_equal('<root><child a="123"></child></root>')
def test_should_identify_and_format_basic_json_with_leading_spaces(self): formatter = GeneralFormatter() formattedText = formatter.format(' {"hello":"world" ,"value":123}', '\t') expect(formattedText).to_equal( '{\n\t"hello": "world",\n\t"value": 123\n}')
def test_should_not_format_null_input(self): formatter = GeneralFormatter() formattedText = formatter.format(None, '\t') expect(formattedText).to_equal(None)
def format(self, text, options): formatter = GeneralFormatter() formattedText = formatter.format(text, options['indent_character']) return formattedText
def test_should_identify_and_format_basic_xml(self): formatter = GeneralFormatter() formattedText = formatter.format('<root><child></child></root>', '\t') expect(formattedText).to_equal('<root>\n\t<child></child>\n</root>')
def result_resolver(input): formatter = GeneralFormatter() return formatter.format(input, '\t')
def test_should_identify_and_unindent_basic_xml(self): formatter = GeneralFormatter() formattedText = formatter.unindent('<root>\n\t<child\na="123"></child>\n</root>') expect(formattedText).to_equal('<root><child a="123"></child></root>')
def test_should_identify_and_unindent_basic_json(self): formatter = GeneralFormatter() formattedText = formatter.unindent('{\n\t"hello": "world",\n\t"value": 123\n}') expect(formattedText).to_equal('{"hello":"world","value":123}')
def test_should_identify_and_format_basic_json_with_leading_spaces(self): formatter = GeneralFormatter() formattedText = formatter.format(' {"hello":"world" ,"value":123}', '\t') expect(formattedText).to_equal('{\n\t"hello": "world",\n\t"value": 123\n}')
def test_should_identify_and_unindent_basic_json(self): formatter = GeneralFormatter() formattedText = formatter.unindent( '{\n\t"hello": "world",\n\t"value": 123\n}') expect(formattedText).to_equal('{"hello":"world","value":123}')
def format(self, text, options): formatter = GeneralFormatter() formattedText = formatter.unindent(text) return formattedText