Skip to content

Move test data out of mypy/ #1667

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

Merged
merged 3 commits into from
Jun 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,10 @@ def build(sources: List[BuildSource],

if TEST_BUILTINS in flags:
# Use stub builtins (to speed up test cases and to make them easier to
# debug).
lib_path.insert(0, os.path.join(os.path.dirname(__file__), 'test', 'data', 'lib-stub'))
# debug). This is a test-only feature, so assume our files are laid out
# as in the source tree.
root_dir = os.path.dirname(os.path.dirname(__file__))
lib_path.insert(0, os.path.join(root_dir, 'test-data', 'unit', 'lib-stub'))
else:
for source in sources:
if source.path:
Expand Down
5 changes: 3 additions & 2 deletions mypy/test/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
import typing


PREFIX = ''
this_file_dir = os.path.dirname(os.path.realpath(__file__))
PREFIX = os.path.dirname(os.path.dirname(this_file_dir))

# Location of test data files such as test case descriptions.
test_data_prefix = os.path.join(PREFIX, 'mypy', 'test', 'data')
test_data_prefix = os.path.join(PREFIX, 'test-data', 'unit')

assert os.path.isdir(test_data_prefix), \
'Test data prefix ({}) not set correctly'.format(test_data_prefix)
Expand Down
3 changes: 1 addition & 2 deletions mypy/test/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from mypy import defaults
from mypy.myunit import AssertionFailure
from mypy.test import config
from mypy.test.data import DataDrivenTestCase


Expand Down Expand Up @@ -191,7 +190,7 @@ def clean_up(a: List[str]) -> List[str]:
"""
res = []
for s in a:
prefix = config.PREFIX + os.sep
prefix = os.sep
ss = s
for p in prefix, prefix.replace(os.sep, '/'):
if p != '/' and p != '//' and p != '\\' and p != '\\\\':
Expand Down
4 changes: 1 addition & 3 deletions mypy/test/testparse.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""Tests for the mypy parser

Test case descriptions are in files test/data/parse[-errors].test."""
"""Tests for the mypy parser."""

import os.path

Expand Down
8 changes: 3 additions & 5 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def add_basic(driver: Driver) -> None:
driver.add_mypy('legacy myunit script', 'scripts/myunit')
driver.add_flake8('legacy myunit script', 'scripts/myunit')
# needs typed_ast installed:
driver.add_mypy('fast-parse', '--fast-parse', 'samples/hello.py')
driver.add_mypy('fast-parse', '--fast-parse', 'test-data/samples/hello.py')


def add_selftypecheck(driver: Driver) -> None:
Expand All @@ -182,8 +182,6 @@ def add_imports(driver: Driver) -> None:
# because of *implicit* imports from other modules.
for f in find_files('mypy', suffix='.py'):
mod = file_to_module(f)
if '.test.data.' in mod:
continue
if not mod.endswith('.__main__'):
driver.add_python_string('import %s' % mod, 'import %s' % mod)
driver.add_flake8('module %s' % mod, f)
Expand Down Expand Up @@ -235,7 +233,7 @@ def add_stubs(driver: Driver) -> None:
def add_stdlibsamples(driver: Driver) -> None:
seen = set() # type: Set[str]
for version in driver.versions:
stdlibsamples_dir = join(driver.cwd, 'stdlib-samples', version)
stdlibsamples_dir = join(driver.cwd, 'test-data', 'stdlib-samples', version)
modules = [] # type: List[str]
for f in find_files(stdlibsamples_dir, prefix='test_', suffix='.py'):
module = file_to_module(f[len(stdlibsamples_dir) + 1:])
Expand All @@ -248,7 +246,7 @@ def add_stdlibsamples(driver: Driver) -> None:


def add_samples(driver: Driver) -> None:
for f in find_files('samples', suffix='.py'):
for f in find_files(os.path.join('test-data', 'samples'), suffix='.py'):
if 'codec' in f:
cwd, bf = os.path.dirname(f), os.path.basename(f)
bf = bf[:-len('.py')]
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[flake8]
max-line-length = 99
exclude = mypy/codec/*,mypy/test/data/lib-stub/*,mypy/test/data/fixtures/*
exclude = mypy/codec/*
# Thing to ignore:
# E251: spaces around default arg value (against our style)
# E128: continuation line under-indented (too noisy)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.