Beispiel #1
0
    def test_user_forget_space_for_continuation_line(self):
        text_input = '''
about_resource: jquery.js
name: jQuery
version: 1.2.3
notes: this is the first line.
this is the second.
 this is the third.
date: 2013-01-02
'''

        expected = '''about_resource: jquery.js
name: jQuery
version: 1.2.3
notes: this is the first line.
date: 2013-01-02
'''

        expected_warnings = [(IGNORED, 'this is the second.\n'),
                             (IGNORED, ' this is the third.\n')]
        about_obj = AboutFile()
        result, warn = AboutFile.pre_process(about_obj, StringIO(text_input))
        self.assertEqual(expected, result.read())
        for i, w in enumerate(warn):
            self.assertEqual(expected_warnings[i][0], w.code)
            self.assertEqual(expected_warnings[i][1], w.field_value)
Beispiel #2
0
    def test_pre_process_with_spaces_left_of_colon(self):
        text_input = '''
about_resource   : jquery.js
name: jQuery
version: 1.2.3
'''
        expected = '''about_resource: jquery.js
name: jQuery
version: 1.2.3
'''
        about_obj = AboutFile()
        result, _warn = AboutFile.pre_process(about_obj,
                                                    StringIO(text_input))
        self.assertEqual(expected, result.read())
Beispiel #3
0
    def test_pre_process_with_invalid_chars_in_field_name(self):
        text_input = '''
about_resource: jquery.js
name: jQuery
vers|ion: 1.2.3
'''
        expected = '''about_resource: jquery.js
name: jQuery
'''
        about_obj = AboutFile()
        result, warn = AboutFile.pre_process(about_obj, StringIO(text_input))
        self.assertEqual(IGNORED, warn[0].code)
        self.assertEqual('vers|ion', warn[0].field_name)
        self.assertEqual(expected, result.read())
Beispiel #4
0
    def test_remove_blank_lines_and_field_spaces(self):
        text_input = '''
name: test space
version: 0.7.0
about_resource: about.py
field with spaces: This is a test case for field with spaces
'''
        expected = '''name: test space
version: 0.7.0
about_resource: about.py
'''

        msg = 'field with spaces: This is a test case for field with spaces\n'
        expected_warnings = [(IGNORED, msg)]
        about_obj = AboutFile()
        result, warn = AboutFile.pre_process(about_obj,
                                                   StringIO(text_input))
        self.assertEqual(expected, result.read())
        for i, w in enumerate(warn):
            self.assertEqual(expected_warnings[i][0], w.code)
            self.assertEqual(expected_warnings[i][1], w.field_value)
Beispiel #5
0
    def test_remove_blank_lines_and_no_colon_fields(self):
        text_input = '''
name: no colon test
test
version: 0.7.0
about_resource: about.py
test with no colon
'''
        expected = '''name: no colon test
version: 0.7.0
about_resource: about.py
'''

        expected_warnings = [(IGNORED, 'test\n'),
                             (IGNORED, 'test with no colon\n')]
        about_obj = AboutFile()
        result, warn = AboutFile.pre_process(about_obj, StringIO(text_input))

        self.assertEqual(expected, result.read())
        for i, w in enumerate(warn):
            self.assertEqual(expected_warnings[i][0], w.code)
            self.assertEqual(expected_warnings[i][1], w.field_value)