Skip to content

Add _cached suffix to test cases in fine-grained tests with cache #4558

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 1 commit into from
Feb 9, 2018
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
17 changes: 17 additions & 0 deletions mypy/test/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,9 +598,23 @@ def collect(self) -> Iterator[pytest.Item]: # type: ignore
optional_out=suite.optional_out,
native_sep=suite.native_sep):
if suite.filter(case):
case.name = add_test_name_suffix(case.name, suite.test_name_suffix)
yield MypyDataCase(case.name, self, case)


def add_test_name_suffix(name: str, suffix: str) -> str:
# Find magic suffix of form "-foobar" (used for things like "-skip").
m = re.search(r'-[-A-Za-z0-9]+$', name)
if m:
# Insert suite-specific test name suffix before the magic suffix
# which must be the last thing in the test case name since we
# are using endswith() checks.
magic_suffix = m.group(0)
return name[:-len(magic_suffix)] + suffix + magic_suffix
else:
return name + suffix


def is_incremental(testcase: DataDrivenTestCase) -> bool:
return 'incremental' in testcase.name.lower() or 'incremental' in testcase.file

Expand Down Expand Up @@ -661,6 +675,9 @@ class DataSuite:
base_path = '.'
optional_out = False
native_sep = False
# Name suffix automatically added to each test case in the suite (can be
# used to distinguish test cases in suites that share data files)
test_name_suffix = ''

# Assigned from MypyDataCase.runtest
update_data = False
Expand Down
1 change: 1 addition & 0 deletions mypy/test/testfinegrainedcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@

class FineGrainedCacheSuite(mypy.test.testfinegrained.FineGrainedSuite):
use_cache = True
test_name_suffix = '_cached'