Skip to content
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

support for PyCharm test debugging, and add tox environment setup #5189

Merged
merged 8 commits into from
Jun 14, 2018
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dmypy.json
# Packages
*.egg
*.egg-info
*.eggs

# IDEs
.idea
Expand All @@ -33,3 +34,5 @@ htmlcov

# pytest cache
.pytest_cache/

.tox
7 changes: 7 additions & 0 deletions mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ def test_python_cmdline(testcase: DataDrivenTestCase) -> None:
outb = process.stdout.read()
# Split output into lines.
out = [s.rstrip('\n\r') for s in str(outb, 'utf8').splitlines()]

if "PYCHARM_HOSTED" in os.environ:
pos = next((p for p, i in enumerate(out) if i.startswith('pydev debugger: ')), None)
if pos is not None:
del out[pos] # the attaching debugger message itself
del out[pos] # plus the extra new line added
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code looks quite fragile (what if the debugger output format changes?). Is it possible to configure the debugger to just not print these lines?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please don't rebase your PR, merge when needed, otherwise it is hard to follow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll need to follow up then and amend it; I haven't found a way to disable it sadly 😢

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.


result = process.wait()
# Remove temp file.
os.remove(program_path)
Expand Down
3 changes: 2 additions & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ python_classes =
python_functions =

# always run in parallel (requires pytest-xdist, see test-requirements.txt)
addopts = -nauto --cov-append --cov-report=
addopts = -nauto

3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ exclude =
typeshed/*,
# during runtests.py flake8 might be started when there's still examples in the temp dir
tmp-test-dirs/*

.tox
.eggs

# Things to ignore:
# E251: spaces around default arg value (against our style)
Expand Down
40 changes: 40 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[tox]
minversion = 2.9.1
skip_missing_interpreters = true
envlist = py34,
py35,
py36,
py37,
lint,
type,
docs

[testenv]
description = run the test driver with {basepython}
deps = -rtest-requirements.txt
commands = python runtests.py -x lint -x self-check {posargs}

[testenv:lint]
description = check the code style
basepython = python3.6
commands = python runtests.py lint {posargs}

[testenv:type]
description = type check ourselves
basepython = python3.6
commands = python runtests.py self-check -p '-n0' -p '-v'

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
basepython = python3.6
deps = -rdocs/requirements-docs.txt
commands = sphinx-build -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}

[testenv:dev]
description = generate a DEV environment, that has all project libraries
usedevelop = True
basepython = python3.6
deps = -rtest-requirements.txt
-rdocs/requirements-docs.txt
commands = python -m pip list --format=columns
python -c 'import sys; print(sys.executable)'