Example #1
0
 def test_get_doc_id_list_someids(self):
     docstring = """@pylatest foo bar 1234
     And now something completelly different.
     """
     is_pylatest_str, doc_id_list, _ = pysource.classify_docstring(docstring)
     self.assertTrue(is_pylatest_str)
     self.assertEqual(doc_id_list, ['foo', 'bar', '1234'])
Example #2
0
 def test_get_docstring_content(self):
     docstring = """@pylatest foo bar 1234
     Bicycle Repair Man.
     """
     is_pylatest_str, _, content = pysource.classify_docstring(docstring)
     self.assertTrue(is_pylatest_str)
     self.assertEqual(content, "        Bicycle Repair Man.\n        ")
Example #3
0
    def test_is_pylatest_docstring_falsepositive(self):
        docstring1 = "This is just a string "
        docstring2 = """
        Main function of py2pylatest cli tool.
        """
        docstring3 = """
        Generators have a ``Yields`` section instead of a ``Returns`` section.

        Args:
            n (int): The upper limit of the range to generate, from 0 to `n` - 1.

        Yields:
            int: The next number in the range of 0 to `n` - 1.

        Examples:
            Examples should be written in doctest format, and should illustrate how
            to use the function.

            >>> print([i for i in example_generator(4)])
            [0, 1, 2, 3]
        """
        examples = [docstring1, docstring2, docstring3]
        for docstring in examples:
            is_pylatest_str, _, _ = pysource.classify_docstring(docstring)
            self.assertFalse(is_pylatest_str)
Example #4
0
 def test_get_doc_id_list_noid(self):
     docstring = """@pylatest  
     And now something completelly different.
     """
     is_pylatest_str, doc_id_list, _ = pysource.classify_docstring(docstring)
     self.assertTrue(is_pylatest_str)
     self.assertEqual(doc_id_list, [])
Example #5
0
 def test_get_docstring_content(self):
     docstring = """@pylatest foo bar 1234
     Bicycle Repair Man.
     """
     is_pylatest_str, _, content = pysource.classify_docstring(docstring)
     assert is_pylatest_str
     assert content == "        Bicycle Repair Man.\n        "
Example #6
0
    def test_is_pylatest_docstring_falsepositive(self):
        docstring1 = "This is just a string "
        docstring2 = """
        Main function of py2pylatest cli tool.
        """
        docstring3 = """
        Generators have a ``Yields`` section instead of a ``Returns`` section.

        Args:
            n (int): The upper limit of the range to generate, from 0 to `n` - 1.

        Yields:
            int: The next number in the range of 0 to `n` - 1.

        Examples:
            Examples should be written in doctest format, and should illustrate how
            to use the function.

            >>> print([i for i in example_generator(4)])
            [0, 1, 2, 3]
        """
        examples = [docstring1, docstring2, docstring3]
        for docstring in examples:
            is_pylatest_str, _, _ = pysource.classify_docstring(docstring)
            assert not is_pylatest_str
Example #7
0
 def test_get_doc_id_list_someids(self):
     docstring = """@pylatest foo bar 1234
     And now something completelly different.
     """
     is_pylatest_str, doc_id_list, _ = pysource.classify_docstring(
         docstring)
     assert is_pylatest_str
     assert doc_id_list == ['foo', 'bar', '1234']
Example #8
0
 def test_get_doc_id_list_noid(self):
     docstring = """@pylatest  
     And now something completelly different.
     """
     is_pylatest_str, doc_id_list, _ = pysource.classify_docstring(
         docstring)
     assert is_pylatest_str
     assert doc_id_list == []
Example #9
0
    def test_is_pylatest_docstring_teardownsection(self):
        docstring = """@pylatest
        Teardown
        ========

        #. Lorem ipsum dolor sit amet: ``rm -rf /mnt/helloworld``.

        #. Umount and remove ``lv_helloword`` volume.

        #. The end.
        """
        is_pylatest_str, _, _ = pysource.classify_docstring(docstring)
        self.assertTrue(is_pylatest_str)
Example #10
0
    def test_is_pylatest_docstring_teardownsection(self):
        docstring = """@pylatest
        Teardown
        ========

        #. Lorem ipsum dolor sit amet: ``rm -rf /mnt/helloworld``.

        #. Umount and remove ``lv_helloword`` volume.

        #. The end.
        """
        is_pylatest_str, _, _ = pysource.classify_docstring(docstring)
        assert is_pylatest_str
Example #11
0
 def test_is_pylatest_docstring_verysimple(self):
     docstring = """@pylatest
     And now something completelly different.
     """
     is_pylatest_str, _, _ = pysource.classify_docstring(docstring)
     self.assertTrue(is_pylatest_str)
Example #12
0
 def test_is_pylatest_docstring_verysimple_withidlist(self):
     docstring = """@pylatest foobar 123
     And now something completelly different.
     """
     is_pylatest_str, _, _ = pysource.classify_docstring(docstring)
     assert is_pylatest_str