Skip to content

Use pytest Node.from_parent if available #9263

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 5 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Use pytest Node.from_parent unconditionally (requires pytest 5.4+)
  • Loading branch information
llchan committed Aug 4, 2020
commit 1fde3b8746d0d8ca9412c7a5cdb88488ea4e3bf1
24 changes: 3 additions & 21 deletions mypy/test/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,7 @@
import sys

import pytest # type: ignore # no pytest in typeshed
from typing import (
Any,
Callable,
Dict,
Iterator,
List,
NamedTuple,
Optional,
Set,
Tuple,
Union,
)
from typing import List, Tuple, Set, Optional, Iterator, Any, Dict, NamedTuple, Union

from mypy.test.config import test_data_prefix, test_temp_dir, PREFIX

Expand Down Expand Up @@ -521,10 +510,7 @@ def pytest_pycollect_makeitem(collector: Any, name: str,
# Non-None result means this obj is a test case.
# The collect method of the returned DataSuiteCollector instance will be called later,
# with self.obj being obj.
if hasattr(DataSuiteCollector, 'from_parent'):
return DataSuiteCollector.from_parent(parent=collector, name=name)
else:
return DataSuiteCollector(name=name, parent=collector)
return DataSuiteCollector.from_parent(parent=collector, name=name)
return None


Expand All @@ -549,11 +535,7 @@ def split_test_cases(parent: 'DataSuiteCollector', suite: 'DataSuite',
for i in range(1, len(cases), 6):
name, writescache, only_when, platform_flag, skip, data = cases[i:i + 6]
platform = platform_flag[1:] if platform_flag else None
if hasattr(DataDrivenTestCase, 'from_parent'):
creator = DataDrivenTestCase.from_parent # type: Callable[..., DataDrivenTestCase]
else:
creator = DataDrivenTestCase
yield creator(
yield DataDrivenTestCase.from_parent(
parent=parent,
suite=suite,
file=file,
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[pytest]
# testpaths is new in 2.8
minversion = 2.8
minversion = 5.4

testpaths = mypy/test mypyc/test

Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy