Skip to content

DOC: Add test for encoding of docstring validation for Windows #26084

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
9 changes: 7 additions & 2 deletions scripts/tests/test_validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pandas as pd

import validate_docstrings
from scripts import validate_docstrings
validate_one = validate_docstrings.validate_one


Expand Down Expand Up @@ -1052,6 +1052,11 @@ def test_raises_for_invalid_attribute_name(self, invalid_name):
with pytest.raises(AttributeError, match=msg):
validate_docstrings.Docstring(invalid_name)

@pytest.mark.parametrize('name', ['pandas.Series.str.isdecimal'])
def test_encode_content_write_to_file(self, name):
docstr = validate_docstrings.Docstring(name).validate_pep8()
assert len(list(docstr)) == 0


class TestMainFunction(object):
def test_exit_status_for_validate_one(self, monkeypatch):
Expand Down Expand Up @@ -1149,4 +1154,4 @@ def test_errors_param_filters_errors(self, monkeypatch):
errors=['ER03'],
output_format='default',
ignore_deprecated=False)
assert exit_status == 1
assert exit_status == 1
4 changes: 2 additions & 2 deletions scripts/validate_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,8 @@ def validate_pep8(self):
application = flake8.main.application.Application()
application.initialize(["--quiet"])

with tempfile.NamedTemporaryFile(mode='w') as file:
file.write(content)
with tempfile.NamedTemporaryFile(mode='wb') as file:
file.write(content.encode("utf-8"))
file.flush()
application.run_checks([file.name])

Expand Down