Commit Graph

17 Commits

Author SHA1 Message Date
Roy Williams
452c1e1d78 Fix patch.object to return a _patch context manager. (#1142)
* Fix patch.object to return a _patch context manager.

This should fix https://github.com/python/typeshed/issues/914

* Prefer None over ... to be consistent with the rest of the file.
2017-04-06 18:47:28 -07:00
Guido van Rossum
1ea3d2de57 Make all single-constraint TypeVars use bound= insteads (plus hack) (#1118)
Another attempt for #804, to unblock python/mypy#2626.
There's a work-around here for python/mypy#1551.
2017-03-29 14:59:24 -07:00
jkleint
433b1b2ebc TestCase.assertSetEqual() should accept frozenset (#1063)
This declares the method to take the union of Set and FrozenSet
rather than AbstractSet since that is where `difference()`
(used by `assertSetEqual()`) is defined.
2017-03-21 23:10:19 -07:00
Jukka Lehtosalo
f296b37e80 Fixes to unittest stubs (#1024)
* Fixes to unittest stubs

* Make types more precise
2017-03-18 14:35:33 -07:00
jkleint
17be26165d Relax type of TestCase.assertCountEqual() params from Sequence to Iterable (#1006)
The stubs for `unittest.TestCase.assertCountEqual()` specify the parameters are Sequences; in fact the method works fine with Iterables, as the first thing the method does is convert them to lists.  [1]  The docs do say sequences, but it appears there is no reason they cannot be Iterables.

[1]: https://github.com/python/cpython/blob/master/Lib/unittest/case.py#L1156
2017-03-15 22:25:20 -07:00
Sebastian Meßmer
85866fe1b9 Fix unittest/mock.pyi (#973)
* Fix unittest/mock.pyi

Add a lot of missing types

* Fix formatting

* Make two and from_kall bool

* Further style fixes

* style fixes
2017-03-08 06:50:28 -08:00
Eric Moyer
62e57618d9 Match assertIsInstance signature with isinstance (#802) 2017-01-09 09:23:46 -08:00
Guido van Rossum
b78eb48b26 Make unittest.removeHandler() an overloaded function.
See https://docs.python.org/3/library/unittest.html#unittest.removeHandler

- Without args it removes the signal handler.
- With a function arg it is a test decorator that temporarily removes
  the handler while the test is running.
2017-01-03 10:15:30 -08:00
Guido van Rossum
94641f5a84 Revert "Make all single-constraint TypeVars to use bounds" (#806)
Reverts python/typeshed#804.

Reason: until python/mypy#1551 is fixed this gives an error whenever @skip() is used.

Specifically see https://github.com/python/typeshed/pull/804#issuecomment-269926655.
2017-01-01 16:35:50 -08:00
Michael Lee
b46366e77d Make all single-constraint TypeVars to use bounds
According to the documentation in the typing module, TypeVars cannot
have only a single constraint. Attempting to do so will actually result
in an exception at runtime. (However, this error is currently ignored
by mypy -- see https://github.com/python/mypy/pull/2626 for a related
pending pull request).

This commit changes all instances of TypeVars using a single constraint
(e.g. `T = TypeVar('T', Foo)`) to use bounds instead (e.g.
`T = TypeVar('T', bound=Foo)`.

This seems to be the correct fix for plistlib after reading the module
docs, but it's less obvious this is correct for unittest. The unittest
module originally had `_FT = TypeVar('_FT', Callable[[Any], Any])` -- an
alternative fix would have been to do `_FT = Callable[[Any], Any]`.

Although I'm not entirely sure what it means to have a bound be a
Callable, I decided to make the assumption that the original authors
probably meant to use TypeVars instead of type aliases for a reason
(possibly to handle classes implementing `__call__`?)
2017-01-01 11:34:19 -08:00
Lukasz Langa
bacd6c0aed Add missing Set imports. 2016-12-21 01:17:55 -08:00
Lukasz Langa
c0c982ada5 Add missing Dict imports. 2016-12-21 01:15:26 -08:00
Lukasz Langa
5b6a9937b2 Fixing flake8 E266 errors 2016-12-20 00:06:36 -08:00
Lukasz Langa
6b5c6626d6 Fixing flake8 E121, E122, E123, E124, E125, E126 errors 2016-12-19 23:53:19 -08:00
Lukasz Langa
fe0e3744cc Fixing flake8 E261 errors 2016-12-19 22:09:35 -08:00
Reverb Chu
a6ecab3fe7 correct return value type TestRunner.run 2016-12-19 20:28:34 -08:00
Jon Dufresne
2b022d18a4 Add stub for unittest.mock (#731)
Stub generated by stubgen.

Fixes #372
2016-12-07 08:05:01 -08:00