Commit Graph

103128 Commits

Author SHA1 Message Date
Mario Corchero f05df0a4b6 bpo-35330: Don't call the wrapped object if `side_effect` is set (GH10973)
* tests: Further validate `wraps` functionality in `unittest.mock.Mock`

Add more tests to validate how `wraps` interacts with other features of
mocks.

* Don't call the wrapped object if `side_effect` is set

When a object is wrapped using `Mock(wraps=...)`, if an user sets a
`side_effect` in one of their methods, return the value of `side_effect`
and don't call the original object.

* Refactor what to be called on `mock_call`

When a `Mock` is called, it should return looking up in the following
order: `side_effect`, `return_value`, `wraps`. If any of the first two
return `mock.DEFAULT`, lookup in the next option.

It makes no sense to check for `wraps` returning default, as it is
supposed to be the original implementation and there is nothing to
fallback to.
2018-12-08 11:25:02 +00:00
Anirudha Bose 3cf74384b5 bpo-33747: Avoid mutating the global sys.modules dict in unittest.mock tests (GH-8520) 2018-12-07 15:30:42 -08:00
Victor Stinner 028f0ef4f3
bpo-9566: Fix compiler warnings in peephole.c (GH-10652) 2018-12-07 17:54:18 +01:00
Serhiy Storchaka 1133a8c0ef
bpo-22005: Fix condition for unpickling a date object. (GH-11025) 2018-12-07 16:48:21 +02:00
Victor Stinner cb0b78a070
Revert "bpo-34977: Add Windows App Store package (GH-10245)" (GH-11019)
This reverts commit 468a15aaf9.
2018-12-07 12:57:43 +01:00
Serhiy Storchaka 8452ca15f4
bpo-22005: Fixed unpickling instances of datetime classes pickled by Python 2. (GH-11017)
encoding='latin1' should be used for successful decoding.
2018-12-07 13:42:10 +02:00
Zackery Spytz 4c49da0cb7 bpo-35436: Add missing PyErr_NoMemory() calls and other minor bug fixes. (GH-11015)
Set MemoryError when appropriate, add missing failure checks,
and fix some potential leaks.
2018-12-07 12:11:30 +02:00
Victor Stinner 3a521f0b61
bpo-35346, platform: replace os.popen() with subprocess (GH-10786)
Replace os.popen() with subprocess.check_output() in the platform module:

* platform.uname() (its _syscmd_ver() helper function) now redirects
  stderr to DEVNULL.
* Remove platform.DEV_NULL.
* _syscmd_uname() and _syscmd_file() no longer catch AttributeError.
  The "except AttributeError:" was only needed in Python 2, when
  os.popen() was not always available. In Python 3,
  subprocess.check_output() is always available.
2018-12-07 11:10:33 +01:00
Tal Einat 9ebe8794f0 bpo-34864: warn if "Prefer tabs when opening documents" set to "Always" (#10464)
* bpo-34864: warn if "Prefer tabs when opening documents" set to "Always"

* add NEWS entry

* address code review comments

* address second code review comments

* Add entry for idlelib/NEWS.txt.
2018-12-07 01:32:21 -05:00
Mariatta 16501b7082 bpo-35434 Fix wrong issue number in what's new in 3.8 (GH-11012)
https://bugs.python.org/issue35434
2018-12-06 21:59:42 -08:00
Steve Dower 468a15aaf9
bpo-34977: Add Windows App Store package (GH-10245) 2018-12-06 21:09:20 -08:00
Andre Delfino c9566b8c45 Add missing period in distutils.dep_util.newer_group doc (GH-11003) 2018-12-06 13:06:55 -08:00
Gregory P. Smith 91f259b478
Clarify expectedFailure in the unittest docs. (#10953) 2018-12-06 12:56:24 -08:00
Serhiy Storchaka 42b1d6127b
bpo-33023: Fix NotImplemented to NotImplementedError. (GH-10934) 2018-12-06 22:36:55 +02:00
Mario Corchero 20428527a7 Remove unused function in `testmock/support.py` (GH-10975)
The function is never imported and the implementation is actually buggy.
As `warnings.catch_warnings` is not imported here.
2018-12-06 17:05:46 +00:00
Victor Stinner 0644b33821
bpo-35363: test_eintr uses print(flush=True) (GH-10990) 2018-12-06 14:16:21 +01:00
Victor Stinner 388c8c208d
bpo-35424: test_multiprocessing: join 3 pools (GH-10986)
Join 3 pools in these tests:

* test.test_multiprocessing_spawn.WithProcessesTestPool.test_context
* test.test_multiprocessing_spawn.WithProcessesTestPool.test_traceback
2018-12-06 11:56:52 +01:00
Serhiy Storchaka 3ffa8b9ba1
bpo-35384: The repr of ctypes.CArgObject no longer fails for non-ascii character. (GH-10863) 2018-12-06 11:16:24 +02:00
Victor Stinner 9dfc754d61
Revert "bpo-34172: multiprocessing.Pool leaks resources after being deleted (GH-8450)" (GH-10971)
This reverts commit 97bfe8d3eb.
2018-12-06 08:51:47 +01:00
native-api 8752dfbd1f bpo-33709: test_ntpath and test_posixpath fail in Windows with ACP!=1252. (GH-7278) 2018-12-06 09:04:35 +02:00
Terry Jan Reedy 6ea9d54dea
bpo-34162: Update idlelib NEWS to 2018-12-05. (GH-10964) 2018-12-06 00:46:22 -05:00
Victor Stinner aa8ae904ad
bpo-35363: test_eintr runs eintr_tester.py in verbose mode (GH-10965)
Moreover, "python3 -m test test_eintr -v" now avoids redirecting
stdout/stderr to a pipe, the child process inherits stdout/stderr
from the parent.
2018-12-06 00:18:30 +01:00
Victor Stinner 848acf7249
bpo-35389: test.pythoninfo logs platform.libc_ver (GH-10951) 2018-12-05 23:21:54 +01:00
E Kawashima 2d8f976cde Fix typo in xml.dom.minidom documentation (GH-10956)
Escape the \t and \n.
Follow up from https://github.com/python/cpython/pull/10814.
2018-12-05 14:15:42 -08:00
Victor Stinner ea0ca218b0
bpo-35344: platform.platform() uses mac_ver() on macOS (GH-10780)
On macOS, platform.platform() now uses mac_ver(), if it returns a
non-empty release string, to get the macOS version rather than darwin
version.
2018-12-05 22:41:52 +01:00
Matt Wheeler 40a61da40d Fix typos in concurrent.Futures documentation (GH-10920)
Add a missing word `as` in `as well as an`.
Linkify `threading.Thread`.
2018-12-05 13:41:20 -08:00
Oran Avraham 7f52415a6d bpo-35310: Clear select() lists before returning upon EINTR (GH-10877)
select() calls are retried on EINTR (per PEP 475).  However, if a
timeout was provided and the deadline has passed after running the
signal handlers, rlist, wlist and xlist should be cleared since select(2)
left them unmodified.
2018-12-05 21:36:03 +01:00
Serhiy Storchaka 67a93b3a0b
bpo-34738: Add directory entries in ZIP files created by distutils. (GH-9419) 2018-12-05 21:46:25 +02:00
Andre Delfino 55f41e45b4 Correct a couple of unbalanced parenthesis. (GH-10779) 2018-12-05 21:45:30 +02:00
Andre Delfino 1ce853f377 Move __missing__ after __delitem__ in Data model. (GH-10923) 2018-12-05 21:42:44 +02:00
Alex H 54fd45505b bpo-34185: Fix test module collision in test_bdb when ran as script. (GH-8537)
When running test_bdb.py as a script, `import test_module` would be
importing the existing Lib/test/test_modules.py instead of the
tempcwd/test_module.py module which was dynamically created by
test_bdb.py itself.
2018-12-05 21:32:16 +02:00
William Grzybowski 34c7f0c04e bpo-34604: Use %R because of invisible characters or trailing whitespaces. (GH-9165) 2018-12-05 21:10:18 +02:00
Zackery Spytz 25d389789c bpo-34987: Fix a possible null pointer dereference in _pickle.c's save_reduce(). (GH-9886) 2018-12-05 20:29:20 +02:00
Sergey Fedoseev 5b25f1d031 bpo-34052: Prevent SQLite functions from setting callbacks on exceptions. (GH-8113) 2018-12-05 19:50:26 +02:00
Victor Stinner f2f4555d82
bpo-10496: posixpath.expanduser() catchs pwd.getpwuid() error (GH-10919)
* posixpath.expanduser() now returns the input path unchanged if
  the HOME environment variable is not set and pwd.getpwuid() raises
  KeyError (the current user identifier doesn't exist in the password
  database).
* Add test_no_home_directory() to test_site.
2018-12-05 16:49:35 +01:00
Serhiy Storchaka 398bd27967
bpo-32787: Better error handling in ctypes. (#3727)
* bpo-31572: Get rid of PyObject_HasAttrString() in ctypes.

* Fix error handling for _pack_.

* Don't silence errors when look up in a dict.

* Use _PyObject_LookupAttrId().

* More changes.
2018-12-05 16:44:14 +02:00
Victor Stinner 476b113ed8
bpo-35389: platform.libc_ver() uses os.confstr() (GH-10891)
platform.libc_ver() now uses os.confstr('CS_GNU_LIBC_VERSION') if
available and the *executable* parameter is not set. The default
value of the libc_ver() *executable* parameter becomes None.

Quick benchmark on Fedora 29:

python3 -m perf command ./python -S -c 'import platform; platform.libc_ver()'
94.9 ms +- 4.3 ms -> 33.2 ms +- 1.4 ms: 2.86x faster (-65%)
2018-12-05 14:04:52 +01:00
Zackery Spytz 2a893430c9 bpo-35414: Add a missing Py_INCREF(Py_None) in PyState_RemoveModule(). (GH-10914) 2018-12-05 09:14:00 +02:00
Victor Stinner c11b3b19a5
bpo-35411: Skip test_urllib2net FTP tests on Travis CI (GH-10907)
On Travis CI, FTP tests of test_urllib2net randomly fail with "425
Security: Bad IP connecting".

test.pythoninfo now also logs TRAVIS environment variable.
2018-12-05 01:58:31 +01:00
Raymond Hettinger 09473ac063
Remove unnecessary and over-restrictive type check (GH-10905) 2018-12-04 14:53:14 -08:00
Victor Stinner b8e689a6e8
bpo-35346, platform: import subprocess in _syscmd_file() (GH-10892)
Only platform._syscmd_file() uses subprocess. Move subprocess import
inside this function to reduce the number of imports at Python
startup.

Remove also warnings import which is no longer needed.
2018-12-04 17:18:12 +01:00
Victor Stinner 4752e65250
bpo-35363, test_eintr: skip test_open() on macOS (GH-10896) 2018-12-04 17:13:33 +01:00
stratakis f92c7aa1ae bpo-35351: Pass link time optimization flags to CFLAGS_NODIST (GH-10797)
When using link time optimizations, the -flto flag is passed to
BASECFLAGS, which makes it propagate to distutils. Those flags
should be reserved for the interpreter and the stdlib extension
modules only, thus moving those flags to CFLAGS_NODIST.
2018-12-04 15:54:01 +01:00
Andrew Dunai e63e617ebb bpo-35357: Add _mock_ prefix to name/parent/from_kall attributes of _Call/_MagicProxy. (#10873)
Fix minor typo in test function name.
2018-12-04 09:08:45 +00:00
Serhiy Storchaka eeb719eac6
bpo-35365: Use a wchar_t* buffer in the code page decoder. (GH-10837) 2018-12-04 10:25:50 +02:00
Raymond Hettinger 7fc633f5a5 Add comments regarding speed/space/entropy trade-offs (GH-10885) 2018-12-04 00:13:38 -08:00
Naglis 1747334794 bpo-35395: fix typos in asyncio eventloop documentation (GH-10880)
Fixes `loop.add_writer` and `loop.add_signal_handler` method documentation to correctly reference the callback parameter from method signature.


https://bugs.python.org/issue35395
2018-12-03 23:31:15 -08:00
Chris Withers 8ca0fa9d2f
bpo-35226: Fix equality for nested unittest.mock.call objects. (#10555)
Also refactor the call recording imolementation and add some notes
about its limitations.
2018-12-03 21:31:37 +00:00
Andrew Svetlov 3bc0ebab17
bpo-35380: Enable TCP_NODELAY for proactor event loop (#10867) 2018-12-03 21:08:13 +02:00
Victor Stinner 3bb150d814
bpo-35373: Fix PyInit_time() error handling (GH-10865)
* PyInit_time() now returns NULL if an exception is raised.
* Rename PyInit_timezone() to init_timezone(). "PyInit_" prefix is
  a special prefix for function initializing a module.
  init_timezone() doesn't initialize a module and the function is not
  exported.
2018-12-03 13:45:38 +01:00