Ejemplo n.º 1
0
    def test_get_summary_multiline_summary(self) -> None:
        parser = GoogleParser()
        doc = pydoc.getdoc(tests.test_class.correct_class.CorrectTestClass.func_with_multiline_summary)

        summary = parser.get_summary(doc, tests.test_class.correct_class)
        assert summary is not None
        assert len(summary) > 0, f"GoogleParser failed assertion"
        assert(len([x for x in summary if x == '\n']) > 1), f"GoogleParser failed assertion"
Ejemplo n.º 2
0
    def test_func_returns_int(self) -> None:
        parser = GoogleParser()
        doc = pydoc.getdoc(tests.test_class.correct_class.CorrectTestClass.func_returns_int)
        arguments = parser.get_parameters(doc, tests.test_class.correct_class)
        assert len(arguments) == 0, f"GoogleParser failed assertion"

        return_type = parser.get_return_type(doc, tests.test_class.correct_class)
        assert return_type == int, f"GoogleParser failed assertion"
Ejemplo n.º 3
0
    def test_func_with_multiline_summary(self) -> None:
        parser = GoogleParser()
        doc = pydoc.getdoc(tests.test_class.correct_class.CorrectTestClass.func_with_multiline_summary)
        arguments = parser.get_parameters(doc, tests.test_class.correct_class)
        assert len(arguments) == 1, f"GoogleParser failed assertion"
        assert arguments[0].type == int, f"GoogleParser failed assertion"

        return_type = parser.get_return_type(doc, tests.test_class.correct_class)
        assert return_type == int, f"GoogleParser failed assertion"
Ejemplo n.º 4
0
    def test_func_with_raise(self) -> None:
        parser = GoogleParser()
        doc = pydoc.getdoc(tests.test_class.raises_class.RaisesClass.func_with_raise)
        actual_exceptions = parser.get_exceptions_raised(doc)
        expected_exceptions = [ 'RuntimeError', 'ValueError', 'IndexError' ]
        assert len(expected_exceptions) == len(actual_exceptions)

        intersection = set(expected_exceptions) - set(actual_exceptions)
        assert len(intersection) == 0
Ejemplo n.º 5
0
    def test_get_summary_empty_summary(self) -> None:
        parser = GoogleParser()
        doc = pydoc.getdoc(tests.test_class.correct_class.CorrectTestClass.func_no_summary)
        arguments = parser.get_parameters(doc, tests.test_class.correct_class)
        assert len(arguments) == 0, f"GoogleParser failed assertion"

        return_type = parser.get_return_type(doc, tests.test_class.correct_class)
        assert return_type == type(None), f"GoogleParser failed assertion"

        summary = parser.get_summary(doc, tests.test_class.correct_class)
        assert summary is None, f"GoogleParser failed assertion"
Ejemplo n.º 6
0
 def test_get_exceptions_raised(self) -> None:
     parser = GoogleParser()
     doc = pydoc.getdoc(tests.test_class.incorrect_class.IncorrectTestClass.func_parse_exception)
     with pytest.raises(ParseException) as exc_info:
         parser.get_exceptions_raised(doc)