Commit Graph

16 Commits

Author SHA1 Message Date
Anselm Kruis 61bd4d2e63 [2.7] bpo-30028: make test.support.temp_cwd() fork-safe (GH-1066) (GH-5825)
Make test.support.temp_cwd() fork-safe. The context manager test.support.temp_cwd() no longer removes the temporary directory when executing in a process other than the parent it entered from.
If a forked child exits the context manager it won't do the cleanup..
(cherry picked from commit 33dddac00b)

Co-authored-by: Anselm Kruis <a.kruis@science-computing.de>
2018-02-23 08:27:28 -08:00
Serhiy Storchaka 65d1887170
[2.7] bpo-10544: Deprecate "yield" in comprehensions and generator expressions in Py3k mode. (GH-4579) (#4676) 2017-12-02 21:00:09 +02:00
Victor Stinner 35d99830f1
bpo-31324: Optimize support._match_test() (#4523) (#4524)
* bpo-31324: Optimize support._match_test() (#4421)

* Rename support._match_test() to support.match_test(): make it
  public
* Remove support.match_tests global variable. It is replaced with a
  new support.set_match_tests() function, so match_test() doesn't
  have to check each time if patterns were modified.
* Rewrite match_test(): use different code paths depending on the
  kind of patterns for best performances.

Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
(cherry picked from commit 803ddd8ce2)

* bpo-31324: Fix test.support.set_match_tests(None) (#4505)

(cherry picked from commit bb11c3c967)
(cherry picked from commit 70b2f87971)
2017-11-23 18:34:59 +01:00
Victor Stinner 1d481822a6
bpo-31629: Add support.SaveSignals (#4183) (#4188)
test_curses now saves/restores signals. On FreeBSD, the curses module
sets handlers of some signals, but don't restore old handlers when
the module is deinitialized.

(cherry picked from commit 19f68301a1)
2017-10-31 03:44:55 -07:00
Victor Stinner 7b4ba62e38 [2.7] bpo-31692: Add PYTHONSHOWALLOCCOUNT env var (GH-3927)
bpo-31692, bpo-19527:

* Add a new PYTHONSHOWALLOCCOUNT environment variable, similar to
  the Python 3 "-X showalloccount" option
* When Python is compiled with COUNT_ALLOCS, the new
  PYTHONSHOWALLOCCOUNT environment variable now has to be set to dump
  allocation counts into stderr on shutdown. Moreover, allocations
  statistics are now dumped into stderr rather than stdout.
* Add @test.support.requires_type_collecting decorator: skip test if
  COUNT_ALLOCS is defined
* Fix tests for COUNT_ALLOCS: decorate some methods with
  @requires_type_collecting
* test_sys.test_objecttypes(): update object type when COUNT_ALLOCS
  is defined
2017-10-17 02:25:23 -07:00
Victor Stinner cc4b6f1c62 bpo-31719: Fix test_regrtest.test_crashed() on s390x (#3912)
Add a new _testcapi._read_null() function to crash Python in a
reliable way on s390x.

On s390x, ctypes.string_at(0) returns an empty string rather than
crashing.
2017-10-09 00:52:06 -07:00
Victor Stinner fd93f37f0d bpo-30448: Fix support.SuppressCrashReport on macOS (#2515)
Add missing "import subprocess".
2017-07-01 01:01:28 +02:00
Victor Stinner fea98bfcff [2.7] bpo-30523, bpo-30764, bpo-30776: Sync regrtest from master (#2444)
* bpo-30523: regrtest --list-cases --match (#2401)

* regrtest --list-cases now supports --match and --match-file options.
  Example: ./python -m test --list-cases -m FileTests test_os
* --list-cases now also sets support.verbose to False to prevent
  messages to stdout when loading test modules.
* Add support._match_test() private function.
(cherry picked from commit ace56d5836)

(cherry picked from commit 36946c06a3)

* bpo-30764: regrtest: add --fail-env-changed option (#2402)

* bpo-30764: regrtest: change exit code on failure

* Exit code 2 if failed tests ("bad")
* Exit code 3 if interrupted

* bpo-30764: regrtest: add --fail-env-changed option

If the option is set, mark a test as failed if it alters the
environment, for example if it creates a file without removing it.

(cherry picked from commit 63f54c6893)
(cherry picked from commit 1f33857a36)

* bpo-30776: reduce regrtest -R false positives (#2422)

* Change the regrtest --huntrleaks checker to decide if a test file
  leaks or not. Require that each run leaks at least 1 reference.
* Warmup runs are now completely ignored: ignored in the checker test
  and not used anymore to compute the sum.
* Add an unit test for a reference leak.

Example of reference differences previously considered a failure
(leak) and now considered as success (success, no leak):

    [3, 0, 0]
    [0, 1, 0]
    [8, -8, 1]
(cherry picked from commit 48b5c422ff)

(cherry picked from commit e0f8b43a46)
2017-06-27 16:56:43 +02:00
Victor Stinner 2d775589d9 bpo-30705: Fix test_regrtest.test_crashed() (#2439)
* Add test.support._crash_python() which triggers a crash but uses
  test.support.SuppressCrashReport() to prevent a crash report from
  popping up.
* Modify test_child_terminated_in_stopped_state() of test_subprocess
  and test_crashed() of test_regrtest to use _crash_python().
2017-06-27 15:37:19 +02:00
Victor Stinner 95a91df036 bpo-30764: Windows support.SuppressCrashReport (#2423)
* Add Windows support to test.support.SuppressCrashReport: call
  SetErrorMode() and CrtSetReportMode().
* _testcapi: add CrtSetReportMode() and CrtSetReportFile() functions
  and CRT_xxx and CRTDBG_xxx constants needed by SuppressCrashReport.
2017-06-27 14:31:40 +02:00
Victor Stinner 2097b9e0ef [2.7] bpo-30764: test_subprocess uses SuppressCrashReport (#2405) (#2412)
* bpo-30764: Backport support.SuppressCrashReport

Backport test.support.SuppressCrashReport context-manager from
master. Drop the Windows implementation since it depends on
msvcrt.CrtSetReportMode() which isn't available on Python 2.7.

* bpo-30764: test_subprocess uses SuppressCrashReport (#2405)

bpo-30764, bpo-29335: test_child_terminated_in_stopped_state() of
test_subprocess now uses support.SuppressCrashReport() to prevent the
creation of a core dump on FreeBSD.
(cherry picked from commit cdee3f14f7)
2017-06-27 00:00:51 +02:00
Victor Stinner 24c2c20873 bpo-30540, bpo-30523: Add --matchfile and --list-cases options to regrtest (#2249)
[2.7] bpo-30540, bpo-30523: Add --matchfile and --list-cases options to regrtest
2017-06-16 17:30:03 +02:00
Serhiy Storchaka eb66897e87 [2.7] bpo-30366: Backport tests for test.support. (#1582)
Also backport new functions temp_dir() and python_is_optimized().
temp_cwd() now accepts None as a name (means using tempfile.mkdtemp).
check_syntax_error() now accepts arguments lineno and offset.
Use more specific error messages in get_attribute().
2017-05-15 11:59:35 +03:00
Victor Stinner 03b278895f bpo-30265: support.unlink() don't catch any OSError (#1456)
support.unlink() now only ignores ENOENT and ENOTDIR, instead of
ignoring any OSError exception.
2017-05-05 10:27:34 +02:00
Serhiy Storchaka 74f0db885f [2.7] bpo-30236: Backported regrtest options -m and -G. (#1394) 2017-05-04 00:23:50 +03:00
Serhiy Storchaka a694e092f6 bpo-30207: Rename test.test_support to test.support. (#1353)
To simplify backports from Python 3, the test.test_support module
was converted into a package and renamed to test.support.  The
test.script_helper module was moved into the test.support package.
Names test.test_support and test.script_helper are left as aliases to
test.support and test.support.script_helper.
2017-04-30 11:36:58 +03:00