|
4 | 4 | import textwrap
|
5 | 5 | import pytest
|
6 | 6 | import numpy as np
|
| 7 | +import pandas |
| 8 | + |
7 | 9 | import validate_docstrings
|
8 | 10 | validate_one = validate_docstrings.validate_one
|
9 | 11 |
|
@@ -1004,6 +1006,30 @@ def test_item_subsection(self, idx, subsection):
|
1004 | 1006 | assert result[idx][3] == subsection
|
1005 | 1007 |
|
1006 | 1008 |
|
| 1009 | +class TestDocstringClass(object): |
| 1010 | + @pytest.mark.parametrize('name_and_expected_obj', |
| 1011 | + [('pandas.isnull', pandas.isnull), |
| 1012 | + ('pandas.DataFrame', pandas.DataFrame), |
| 1013 | + ('pandas.Series.sum', pandas.Series.sum)]) |
| 1014 | + def test_resolves_class_name(self, name_and_expected_obj): |
| 1015 | + name, expected_obj = name_and_expected_obj |
| 1016 | + d = validate_docstrings.Docstring(name) |
| 1017 | + assert d.obj is expected_obj |
| 1018 | + |
| 1019 | + @pytest.mark.parametrize('invalid_name', ['panda', 'panda.DataFrame']) |
| 1020 | + def test_raises_for_invalid_module_name(self, invalid_name): |
| 1021 | + # Note that the module names in this test are misspelled. |
| 1022 | + with pytest.raises(ImportError): |
| 1023 | + validate_docstrings.Docstring(invalid_name) |
| 1024 | + |
| 1025 | + @pytest.mark.parametrize('invalid_name', |
| 1026 | + ['pandas.BadClassName', |
| 1027 | + 'pandas.Series.bad_method_name']) |
| 1028 | + def test_raises_for_invalid_attribute_name(self, invalid_name): |
| 1029 | + with pytest.raises(AttributeError): |
| 1030 | + validate_docstrings.Docstring(invalid_name) |
| 1031 | + |
| 1032 | + |
1007 | 1033 | class TestMainFunction(object):
|
1008 | 1034 | def test_exit_status_for_validate_one(self, monkeypatch):
|
1009 | 1035 | monkeypatch.setattr(
|
|
0 commit comments