示例#1
0
文件: test_tincmm.py 项目: 50wu/gpdb
 def test_generate_new_docstring(self):
     test_file_handle = PythonFileHandler(os.path.join(os.path.dirname(__file__), 'sample_tests.py'))
     metadata_dictionary = test_file_handle.get_metadata_dictionary(class_name = 'SampleSQLTests', method_name = 'test_explicit_2')
     metadata_dictionary['__changed__'] = True
     
     original_docstring = ''
     for my_tuple in test_file_handle.docstring_tuples:
         if my_tuple.class_name == 'SampleSQLTests' and my_tuple.method_name == 'test_explicit_2':
             original_docstring = my_tuple.original_docstring
             offset = my_tuple.offset
             break
     
     new_docstring = test_file_handle.generate_new_docstring(original_docstring, metadata_dictionary, offset)
     self.assertEquals(new_docstring.strip('\n'), original_docstring)
     
     # Original tags is explicit. Change it to blah
     metadata_dictionary['tags'] = "blah"
     new_docstring = test_file_handle.generate_new_docstring(original_docstring, metadata_dictionary, offset)
     self.assertTrue("@tags blah" in new_docstring)
     self.assertTrue("@tags test_explicit_2" not in new_docstring)
     
     # Add something to metadata_dictionary that wasn't there before
     metadata_dictionary['author'] = 'mel'
     new_docstring = test_file_handle.generate_new_docstring(original_docstring, metadata_dictionary, offset)
     self.assertTrue("@author mel" in new_docstring)
示例#2
0
    def test_generate_new_docstring(self):
        test_file_handle = PythonFileHandler(
            os.path.join(os.path.dirname(__file__), 'sample_tests.py'))
        metadata_dictionary = test_file_handle.get_metadata_dictionary(
            class_name='SampleSQLTests', method_name='test_explicit_2')
        metadata_dictionary['__changed__'] = True

        original_docstring = ''
        for my_tuple in test_file_handle.docstring_tuples:
            if my_tuple.class_name == 'SampleSQLTests' and my_tuple.method_name == 'test_explicit_2':
                original_docstring = my_tuple.original_docstring
                offset = my_tuple.offset
                break

        new_docstring = test_file_handle.generate_new_docstring(
            original_docstring, metadata_dictionary, offset)
        self.assertEquals(new_docstring.strip('\n'), original_docstring)

        # Original tags is explicit. Change it to blah
        metadata_dictionary['tags'] = "blah"
        new_docstring = test_file_handle.generate_new_docstring(
            original_docstring, metadata_dictionary, offset)
        self.assertTrue("@tags blah" in new_docstring)
        self.assertTrue("@tags test_explicit_2" not in new_docstring)

        # Add something to metadata_dictionary that wasn't there before
        metadata_dictionary['author'] = 'mel'
        new_docstring = test_file_handle.generate_new_docstring(
            original_docstring, metadata_dictionary, offset)
        self.assertTrue("@author mel" in new_docstring)
示例#3
0
文件: test_tincmm.py 项目: 50wu/gpdb
 def test_generate_new_docstring_complicated(self):
     # Work with more complicated docstring: SampleSQLTests
     test_file_handle = PythonFileHandler(os.path.join(os.path.dirname(__file__), 'sample_tests.py'))
     metadata_dictionary = test_file_handle.get_metadata_dictionary(class_name = 'SampleSQLTests', method_name = None)
     metadata_dictionary['__changed__'] = True
     
     original_docstring = ''
     for my_tuple in test_file_handle.docstring_tuples:
         if my_tuple.class_name == 'SampleSQLTests' and my_tuple.method_name == None:
             original_docstring = my_tuple.original_docstring
             offset = my_tuple.offset
             break
     
     new_docstring = test_file_handle.generate_new_docstring(original_docstring, metadata_dictionary, offset)
     self.assertEquals(new_docstring.strip('\n'), original_docstring)
     
     # Original author is sql_author. Change it to blah
     metadata_dictionary['author'] = "blah"
     new_docstring = test_file_handle.generate_new_docstring(original_docstring, metadata_dictionary, offset)
     self.assertTrue("@author blah" in new_docstring)
     self.assertTrue("@author sql_author" not in new_docstring)
     
     # Verify that the comment is still there
     self.assertTrue("Comment here" in new_docstring)
     self.assertTrue("Some space above" in new_docstring)
     
     # Add something to metadata_dictionary that wasn't there before
     metadata_dictionary['bugs'] = 'mpp-1'
     new_docstring = test_file_handle.generate_new_docstring(original_docstring, metadata_dictionary, offset)
     self.assertTrue("@bugs mpp-1" in new_docstring)
示例#4
0
    def test_generate_new_docstring_complicated(self):
        # Work with more complicated docstring: SampleSQLTests
        test_file_handle = PythonFileHandler(
            os.path.join(os.path.dirname(__file__), 'sample_tests.py'))
        metadata_dictionary = test_file_handle.get_metadata_dictionary(
            class_name='SampleSQLTests', method_name=None)
        metadata_dictionary['__changed__'] = True

        original_docstring = ''
        for my_tuple in test_file_handle.docstring_tuples:
            if my_tuple.class_name == 'SampleSQLTests' and my_tuple.method_name == None:
                original_docstring = my_tuple.original_docstring
                offset = my_tuple.offset
                break

        new_docstring = test_file_handle.generate_new_docstring(
            original_docstring, metadata_dictionary, offset)
        self.assertEquals(new_docstring.strip('\n'), original_docstring)

        # Original author is sql_author. Change it to blah
        metadata_dictionary['author'] = "blah"
        new_docstring = test_file_handle.generate_new_docstring(
            original_docstring, metadata_dictionary, offset)
        self.assertTrue("@author blah" in new_docstring)
        self.assertTrue("@author sql_author" not in new_docstring)

        # Verify that the comment is still there
        self.assertTrue("Comment here" in new_docstring)
        self.assertTrue("Some space above" in new_docstring)

        # Add something to metadata_dictionary that wasn't there before
        metadata_dictionary['bugs'] = 'mpp-1'
        new_docstring = test_file_handle.generate_new_docstring(
            original_docstring, metadata_dictionary, offset)
        self.assertTrue("@bugs mpp-1" in new_docstring)