diff options
author | Ran Benita <ran@unusedvar.com> | 2020-05-01 14:40:16 +0300 |
---|---|---|
committer | Ran Benita <ran@unusedvar.com> | 2020-06-05 11:34:19 +0300 |
commit | e68a26199cb2bae0f001ab495232525f38227ad9 (patch) | |
tree | 5b947348ce125273d850a700309d7a68f83009f7 /src/_pytest/stepwise.py | |
parent | d95132178c073debcb687075f0f986d7d0322e9d (diff) | |
download | pytest-e68a26199cb2bae0f001ab495232525f38227ad9.tar.gz |
Type annotate misc functions
Diffstat (limited to 'src/_pytest/stepwise.py')
-rw-r--r-- | src/_pytest/stepwise.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/_pytest/stepwise.py b/src/_pytest/stepwise.py index 1921245dc..85cbe2931 100644 --- a/src/_pytest/stepwise.py +++ b/src/_pytest/stepwise.py @@ -1,4 +1,8 @@ +from typing import List +from typing import Optional + import pytest +from _pytest import nodes from _pytest.config import Config from _pytest.config.argparsing import Parser from _pytest.main import Session @@ -28,20 +32,23 @@ def pytest_configure(config: Config) -> None: class StepwisePlugin: - def __init__(self, config): + def __init__(self, config: Config) -> None: self.config = config self.active = config.getvalue("stepwise") - self.session = None + self.session = None # type: Optional[Session] self.report_status = "" if self.active: + assert config.cache is not None self.lastfailed = config.cache.get("cache/stepwise", None) self.skip = config.getvalue("stepwise_skip") def pytest_sessionstart(self, session: Session) -> None: self.session = session - def pytest_collection_modifyitems(self, session, config, items): + def pytest_collection_modifyitems( + self, session: Session, config: Config, items: List[nodes.Item] + ) -> None: if not self.active: return if not self.lastfailed: @@ -89,6 +96,7 @@ class StepwisePlugin: else: # Mark test as the last failing and interrupt the test session. self.lastfailed = report.nodeid + assert self.session is not None self.session.shouldstop = ( "Test failed, continuing from this test next run." ) @@ -100,11 +108,13 @@ class StepwisePlugin: if report.nodeid == self.lastfailed: self.lastfailed = None - def pytest_report_collectionfinish(self): + def pytest_report_collectionfinish(self) -> Optional[str]: if self.active and self.config.getoption("verbose") >= 0 and self.report_status: return "stepwise: %s" % self.report_status + return None def pytest_sessionfinish(self, session: Session) -> None: + assert self.config.cache is not None if self.active: self.config.cache.set("cache/stepwise", self.lastfailed) else: |