Пример #1
0
 def test_extract_doc_fragments_onecaseperfile_single(self):
     source = read_file("onecaseperfile", "single.py")
     doc_fragment_dict = pysource.extract_doc_fragments(source)
     assert len(doc_fragment_dict) == 1
     doc_fragments = doc_fragment_dict[None]
     assert len(doc_fragments) == 1
     assert doc_fragments.default is None
Пример #2
0
 def test_extract_documents_splitted_nested_withdefault(self):
     source = read_file("multiplecasesperfile",
                        "splitted-nested-default.py")
     doc_fragment_dict = pysource.extract_doc_fragments(source)
     assert len(doc_fragment_dict) == 2
     for doc_id, doc_fragments in doc_fragment_dict.items():
         # default doc is used in the file (for setup and teardown strings)
         assert doc_fragments.default is not None
         assert len(doc_fragments.default) == 2
Пример #3
0
 def _test_extract_document_noerrors(self, testname):
     source = read_file("onecaseperfile", testname)
     expected_result = read_file("onecaseperfile", "rst")
     # extract TestCaseDocFragments from the python source file
     docfr_dict = pysource.extract_doc_fragments(source)
     # there should be just one test case document
     assert len(docfr_dict) == 1
     # this document is without pylatest id
     doc_fr = docfr_dict[None]
     # then build RstTestCaseDoc from TestCaseDocFragments
     doc = doc_fr.build_doc()
     # and finally build the rst source version
     assert doc.build_rst() == expected_result
     # every build should be the same
     assert doc.build_rst() == expected_result
Пример #4
0
 def _test_extract_documents_noerrors(self, doc_num, testname):
     # TODO: needs update to work with new error handling (not yet done)
     source = read_file("multiplecasesperfile", testname)
     # extract TestCaseDocFragments from the python source file
     docfr_dict = pysource.extract_doc_fragments(source)
     assert len(docfr_dict) == doc_num
     for doc_id, doc_fr in docfr_dict.items():
         if doc_id is None:
             doc_id = "none"
         filename = "{}.rst".format(doc_id)
         expected_result = read_file("multiplecasesperfile", filename)
         # build RstTestCaseDoc from TestCaseDocFragments
         doc = doc_fr.build_doc()
         assert doc.build_rst() == expected_result
         # every build should be the same
         assert doc.build_rst() == expected_result
Пример #5
0
 def test_extract_doc_fragments_multiplecasesperfile_splitted_nested(self):
     source = read_file("multiplecasesperfile", "splitted-nested.py")
     doc_fragment_dict = pysource.extract_doc_fragments(source)
     assert len(doc_fragment_dict) == 2
     # number of expected pylatest strings for each pylatest doc id
     expected_fragments = {
         'test01': 9,
         'test02': 7,
     }
     for doc_id, doc_fragments in doc_fragment_dict.items():
         # default doc feature is not used in the file
         assert doc_fragments.default is None
         # check expected number of pylatest strings
         assert len(doc_fragments) == expected_fragments[doc_id]
     # check that some pylatest strings are the same in both doc fragments
     for linenum in (77, 96):
         assert doc_fragment_dict['test01'].docstrings[linenum] == \
                doc_fragment_dict['test02'].docstrings[linenum]
Пример #6
0
    def test_extract_doc_fragments_onecaseperfile_splitted_nested(self):
        source = read_file("onecaseperfile", "splitted-nested.py")
        doc_fragment_dict = pysource.extract_doc_fragments(source)
        # there is just a single test case in the file
        # (as 'onecaseperfile' directory name suggests)
        assert len(doc_fragment_dict) == 1
        # pylatest strings are without pylatest ids
        doc_fragments = doc_fragment_dict[None]
        # there are 9 pylatest strings in given file
        assert len(doc_fragments) == 9
        # the default doc feature is not used in given file
        assert doc_fragments.default is None
        # pylatest string literal which ends on line 95 in splitted-neste.py file
        fragment_line95 = textwrap.dedent('''\
        .. test_step:: 1

            List files in the volume: ``ls -a /mnt/helloworld``''')
        assert doc_fragments.docstrings[95] == fragment_line95
Пример #7
0
 def test_extract_document_null(self):
     source = read_file("onecaseperfile", "null.py")
     docfr_dict = pysource.extract_doc_fragments(source)
     assert docfr_dict == {}
Пример #8
0
 def test_extract_doc_fragments_null_str(self):
     doc_fragment_dict = pysource.extract_doc_fragments("")
     assert len(doc_fragment_dict) == 0
     assert doc_fragment_dict == {}