-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add undocumented methods and make types more specific in 2/unittest #3550
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,11 @@ _FT = TypeVar('_FT') | |
| _ExceptionType = Union[Type[BaseException], Tuple[Type[BaseException], ...]] | ||
| _Regexp = Union[Text, Pattern[Text]] | ||
|
|
||
| _SysExcInfoType = Union[ | ||
| Tuple[Type[BaseException], BaseException, types.TracebackType], | ||
| Tuple[None, None, None], | ||
| ] | ||
|
|
||
| class Testable(metaclass=ABCMeta): | ||
| @abstractmethod | ||
| def run(self, result: TestResult) -> None: ... | ||
|
|
@@ -26,28 +31,28 @@ class Testable(metaclass=ABCMeta): | |
| # TODO ABC for test runners? | ||
|
|
||
| class TestResult: | ||
| errors: List[Tuple[Testable, str]] | ||
| failures: List[Tuple[Testable, str]] | ||
| skipped: List[Tuple[Testable, str]] | ||
| expectedFailures: List[Tuple[Testable, str]] | ||
| unexpectedSuccesses: List[Testable] | ||
| errors: List[Tuple[TestCase, str]] | ||
| failures: List[Tuple[TestCase, str]] | ||
| skipped: List[Tuple[TestCase, str]] | ||
| expectedFailures: List[Tuple[TestCase, str]] | ||
| unexpectedSuccesses: List[TestCase] | ||
| shouldStop: bool | ||
| testsRun: int | ||
| buffer: bool | ||
| failfast: bool | ||
|
|
||
| def wasSuccessful(self) -> bool: ... | ||
| def stop(self) -> None: ... | ||
| def startTest(self, test: Testable) -> None: ... | ||
| def stopTest(self, test: Testable) -> None: ... | ||
| def startTest(self, test: TestCase) -> None: ... | ||
| def stopTest(self, test: TestCase) -> None: ... | ||
| def startTestRun(self) -> None: ... | ||
| def stopTestRun(self) -> None: ... | ||
| def addError(self, test: Testable, err: Tuple[type, Any, Any]) -> None: ... # TODO | ||
| def addFailure(self, test: Testable, err: Tuple[type, Any, Any]) -> None: ... # TODO | ||
| def addSuccess(self, test: Testable) -> None: ... | ||
| def addSkip(self, test: Testable, reason: str) -> None: ... | ||
| def addExpectedFailure(self, test: Testable, err: str) -> None: ... | ||
| def addUnexpectedSuccess(self, test: Testable) -> None: ... | ||
| def addError(self, test: TestCase, err: _SysExcInfoType) -> None: ... | ||
| def addFailure(self, test: TestCase, err: _SysExcInfoType) -> None: ... | ||
| def addSuccess(self, test: TestCase) -> None: ... | ||
| def addSkip(self, test: TestCase, reason: str) -> None: ... | ||
| def addExpectedFailure(self, test: TestCase, err: str) -> None: ... | ||
| def addUnexpectedSuccess(self, test: TestCase) -> None: ... | ||
|
|
||
| class _AssertRaisesBaseContext: | ||
| expected: Any | ||
|
|
@@ -240,12 +245,16 @@ defaultTestLoader: TestLoader | |
|
|
||
| class TextTestResult(TestResult): | ||
| def __init__(self, stream: TextIO, descriptions: bool, verbosity: int) -> None: ... | ||
| def getDescription(self, test: TestCase) -> str: ... # undocumented | ||
| def printErrors(self) -> None: ... # undocumented | ||
| def printErrorList(self, flavour: str, errors: List[Tuple[TestCase, str]]) -> None: ... # undocumented | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looking at the implementation, we can use
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The implementation calls it with |
||
|
|
||
| class TextTestRunner: | ||
| def __init__(self, stream: Optional[TextIO] = ..., descriptions: bool = ..., | ||
| verbosity: int = ..., failfast: bool = ..., buffer: bool = ..., | ||
| resultclass: Optional[Type[TestResult]] = ...) -> None: ... | ||
| def _makeResult(self) -> TestResult: ... | ||
| def run(self, test: Testable) -> TestResult: ... # undocumented | ||
|
|
||
| class SkipTest(Exception): | ||
| ... | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need this class? It does not exist in the implementation and I don't really know what purpose it serves in the stubs, especially now that you removed its uses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It effectively means
Union[TestCase, TestSuite]. I didn't remove all uses, just the ones that I noticed should beTestCaseinstead.It shouldn't be a class, but changing that would take a lot more work.