Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit 62610d6

Browse files
committed
Named module (-m) support (for Python >= 2.7).
1 parent 807e79f commit 62610d6

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed
File renamed without changes.

src/tests/test_integration.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from __future__ import with_statement
66
from collections import namedtuple
77

8-
import sys
98
import os
9+
import sys
1010
import mock
1111
import shlex
1212
import shutil
@@ -179,6 +179,27 @@ def function_with_bad_docstring(foo):
179179
assert error_codes == expected_error_codes - ignored
180180

181181

182+
def test_run_as_named_module():
183+
"""Test that pydocstyle can be run as a "named module".
184+
185+
This means that the following should run pydocstyle:
186+
187+
python -m pydocstyle
188+
189+
"""
190+
# Running a package with "-m" is not supported in Python 2.6
191+
if sys.version_info[0:2] == (2, 6):
192+
return
193+
# Add --match='' so that no files are actually checked (to make sure that
194+
# the return code is 0 and to reduce execution time).
195+
cmd = shlex.split("python -m pydocstyle --match=''")
196+
p = subprocess.Popen(cmd,
197+
stdout=subprocess.PIPE,
198+
stderr=subprocess.PIPE)
199+
out, err = p.communicate()
200+
assert p.returncode == 0, out.decode('utf-8') + err.decode('utf-8')
201+
202+
182203
def test_config_file(env):
183204
"""Test that options are correctly loaded from a config file.
184205

0 commit comments

Comments
 (0)