Commit Graph

163 Commits

Author SHA1 Message Date
Baptiste Mispelon 91acfc3514 Fixed #33264 -- Made test runner return non-zero error code for unexpected successes. 2021-11-08 20:19:21 +01:00
Chris Jerdonek b263f4b69d Fixed #32552 -- Added logger argument to DiscoverRunner. 2021-08-24 09:23:01 +02:00
Mariusz Felisiak 36714be874 Refs #31621 -- Fixed handling --parallel option in test management command and runtests.py.
Regression in ae89daf46f.
Thanks Tim Graham for the report.
2021-08-19 09:18:32 +02:00
Mariusz Felisiak c2a5735d86 Refs #31621 -- Added more tests for test --parallel option. 2021-08-19 09:18:32 +02:00
Mariusz Felisiak ab16507f19
Fixed #32988 -- Prevented creation of more test databases than TestCases.
DiscoverRunner.parallel is used in setup_databases() and
teardown_databases() to control the number of test databases.

Regression in cb6c19749d.
2021-08-05 05:55:35 +02:00
Adam Johnson ae89daf46f Fixed #31621 -- Added support for '--parallel auto' to test management command. 2021-08-03 09:57:04 +02:00
Adam Johnson 7e38a8d66f Refs #31621 -- Added more tests for test --parallel option. 2021-08-03 09:57:04 +02:00
Jacob Walls 56f9579105 Fixed #32655 -- Deprecated extra_tests argument for DiscoverRunner.build_suite()/run_tests(). 2021-07-16 20:46:41 +02:00
Chris Jerdonek 5848b3a1d7 Fixed #32914 -- Prevented test --shuffle from skipping test methods.
"test --shuffle" skipped test methods when test classes were mixed.
This changes runner.py's reorder_tests() to group by TestCase class.

Regression in 90ba716bf0.
2021-07-12 06:36:12 +02:00
Chris Jerdonek 90ba716bf0 Fixed #24522 -- Added a --shuffle option to DiscoverRunner. 2021-07-08 07:29:04 +02:00
Mads Jensen c51bf80d56 Used more specific unittest assertions in tests. 2021-07-07 10:51:38 +02:00
Chris Jerdonek 8bca838f4a Refs #32655 -- Improved error if iter_test_cases() is passed a string. 2021-06-29 20:41:40 +02:00
Chris Jerdonek de4f620183 Fixed #32609 -- Updated runtests.py to support directory path test labels.
For example, with this change, the following now works from the tests
directory:

    $ ./runtests.py view_tests/tests/
2021-06-10 20:19:30 +02:00
Mariusz Felisiak 8b4983cfd4
Fixed typo in tests/test_runner/test_discover_runner.py. 2021-06-10 13:25:05 +02:00
Ceesjan Luiten cb6c19749d Refs #27734 -- Prevented creation of more parallel workers than TestCases.
The parallel test runner uses multiple workers to distribute the
workload. These workers are assigned a worker ID using a globally
incremented variable, which determines what test database to connect
to. When the worker ID surpasses the test database IDs Django will
crash.

This reduce likelihood of crashing parallel tests because
ParallelTestSuite will no longer create more workers than TestCases.

It won't eliminate the problem completely though because there are
other circumstances in which new workers can be created which can then
be assigned an "illegal" worker ID.
2021-06-10 07:32:15 +02:00
Mariusz Felisiak 62e8f369c3
Fixed #32808 -- Prevented DiscoverRunner.build_suite() from mutating test loader patterns.
Thanks Chris Jerdonek for the report and reviews.
2021-06-03 08:59:37 +02:00
Chris Jerdonek 1b4d1675b2
Refs #32641 -- Made DiscoverRunner's "Found X tests" message work for finding one test.
This also removes passing level to log() as logging.INFO is the default.
2021-06-02 12:53:09 +02:00
Daniyal a0410ffe8f Refs #32552 -- Added DiscoverRunner.log() to allow customization.
Thanks Carlton Gibson, Chris Jerdonek, and David Smith for reviews.
2021-06-01 13:31:44 +02:00
girishsontakke a815a6a315 Fixed #32641 -- Made DiscoverRunner print the number of found tests.
Thanks Chris Jerdonek for reviews.
2021-04-15 11:42:46 +02:00
Chris Jerdonek a89e975caf Fixed #32532 -- Made DiscoverRunner raise RuntimeError when a test label is a file path. 2021-04-02 12:54:08 +02:00
Chris Jerdonek 038940cf55 Fixed #29127 -- Prevented DiscoverRunner from hiding tagged test with syntax errors.
This mades _FailedTest objects always match tags in DiscoverRunner.
2021-03-30 10:26:20 +02:00
Chris Jerdonek dcb06c2c68 Fixed #32591 -- Made DiscoverRunner order _FailedTest objects first.
Failures detected when loading tests are ordered before all of the
above for quicker feedback. This includes things like test modules that
couldn't be found or that couldn't be loaded due to syntax errors.
2021-03-26 12:18:27 +01:00
Mariusz Felisiak 5b618f239c
Fixed RemoteTestResultTest tests without tblib.
Follow up to e3bca22e7e.
2021-03-25 10:33:54 +01:00
Adam Johnson f6713cda89 Fixed #31370 -- Added support for parallel tests with --buffer. 2021-03-18 15:30:47 +01:00
Adam Johnson e3bca22e7e Refs #31370 -- Made RemoteTestResult subclass unittest.TestResult. 2021-03-18 15:30:47 +01:00
Adam Johnson 92975bcd5f Refs #31370 -- Added test for pickling RemoteTestResult. 2021-03-18 15:30:47 +01:00
Chris Jerdonek d828beb68f Fixed #32529 -- Delayed creating a test suite in build_suite(). 2021-03-11 10:02:06 +01:00
Chris Jerdonek d8a4bcffdb Refs #32489 -- Doc'd and tested iter_test_cases() support for an iterable of tests. 2021-03-11 09:23:33 +01:00
Chris Jerdonek 77e0a35a10 Fixed #32516 -- Fixed reorder_suite() with duplicates and reverse=True. 2021-03-09 13:30:51 +01:00
Chris Jerdonek 22c9af0eae Fixed #32489 -- Added iter_test_cases() to iterate over a TestSuite.
This also makes partition_suite_by_type(), partition_suite_by_case(),
filter_tests_by_tags(), and DiscoverRunner._get_databases() to use
iter_test_cases().
2021-03-05 13:04:07 +01:00
Simon Charette 3089018e95 Fixed #32446 -- Deprecated SERIALIZE test database setting.
Whether or not the state of a test database should be serialized can be
inferred from the set of databases allowed to be access from discovered
TestCase/TransactionTestCase enabling the serialized_rollback feature
which makes this setting unnecessary.

This should make a significant test suite bootstraping time difference
on large projects that didn't explicitly disable test database
serialization.
2021-02-24 20:31:11 +01:00
Harm Geerts 06e5f7ae16 Fixed #29052 -- Made test database creation preserve alias order and prefer the "default" database.
This fixes flushing test databases when two aliases point to the same
database.

Use a list() to store the test database aliases so the order remains
stable by following the order of the connections. Also, always use the
"default" database alias as the first alias to accommodate `migrate`.

Previously `migrate` could be executed on a secondary alias which
caused truncating the "default" database.
2021-02-16 10:25:34 +01:00
Mariusz Felisiak ec0ff40631 Fixed #32355 -- Dropped support for Python 3.6 and 3.7 2021-02-10 10:20:54 +01:00
Mariusz Felisiak 00a1d42bf0
Fixed isolation of test_runner.EmptyDefaultDatabaseTest.
This fixes test_runner.test_debug_sql.TestDebugSQL.
test_setupclass_exception when run in reverse.
2020-12-10 18:48:07 +01:00
Adam Johnson b9fd09d21b Fixed #32227 -- Prevented crash when setUpTestData() errors with --debug-sql.
Thanks Mariusz Felisiak for the report.
2020-11-28 12:22:59 +01:00
Ahmad A. Hussein 61a0ba43cf Refs #31811 -- Added optional timing outputs to the test runner. 2020-08-13 17:17:15 +02:00
ovkulkarni b7a438c7e2 Fixed #31509 -- Made DiscoverRunner enable faulthandler by default. 2020-07-10 18:55:50 +02:00
Matthijs Kooijman 2a2ea4ee18 Refs #31117 -- Made various tests properly handle unexpected databases aliases.
- Used selected "databases" instead of django.db.connections.
- Made routers in tests.migrations skip migrations on unexpected
  databases.
- Added DiscoverRunnerGetDatabasesTests.assertSkippedDatabases() hook
  which properly asserts messages about skipped databases.
2020-01-20 14:39:02 +01:00
Baptiste Mispelon 9e565386d3 Fixed #27430 -- Added -b/--buffer option to DiscoverRunner. 2019-12-09 13:47:12 +01:00
Mariusz Felisiak f464526388
Refs #30676 -- Added test for invalid --pdb and --parallel usage in DiscoverRunner. 2019-12-09 11:12:06 +01:00
Mariusz Felisiak 25903e41fb Refs #29926 -- Bumped minimum tblib version to 1.5.0 in test requirements. 2019-10-23 15:26:04 +02:00
Mariusz Felisiak 2847d2c760
Refs #29926 -- Skipped RemoteTestResultTest.test_add_failing_subtests() on Python 3.8+ and tblib <= 1.4.0. 2019-10-22 15:34:19 +02:00
Min ho Kim 65e86948b8 Corrected several typos in string literals and test names. 2019-08-07 11:23:14 +02:00
François Freitag 568eed9e79 Fixed #30245 -- Added -k option to DiscoverRunner. 2019-04-30 16:20:51 +02:00
Jon Dufresne 487d904bf2 Simplified temporary directory handling in AdminScriptTestCase.
Use tempfile.TemporaryDirectory() in AdminScriptTestCase.setUp()
to create and destroy a temporary directory for each test. It removes
the need for individual tests to delete files.

For test classes that don't use the temporary directory, inherit from
SimpleTestCase.
2019-02-05 12:11:54 -05:00
Simon Charette 41e73de39d Fixed #28478 -- Make DiscoverRunner skip creating unused test databases.
SimpleTestCase.databases makes it possible to determine the set of
databases required to run the discovered tests.
2019-01-10 19:11:21 -05:00
Simon Charette 8c775391b7 Refs #28478 -- Deprecated TestCase's allow_database_queries and multi_db in favor of databases. 2019-01-10 19:11:21 -05:00
Simon Charette f6d8b0c47e Refs #26840 -- Corrected SQLite connection mocking in a setup_databases() test.
The test was expecting connections used by DiscoverRunner.setup_databases()
to be the ones defined in django.test.runner but this doesn't hold true
since this method was made a proxy of django.test.utils.setup_databases.

This broke the TransactionTestCase.serialized_rollback feature in the test
suite because calls to create_db_test() cleared the test data persisted on
connections objects.

Added an assertions to prevent this from happening again.
2018-12-24 15:32:27 -05:00
Nick Pope e626a3f993 Renamed Sqlite and Sqlite3 references to SQLite. 2018-12-22 18:52:54 -05:00
Simon Charette 315357ad25 Fixed #30023 -- Prevented SQLite schema alterations while foreign key checks are enabled.
Prior to this change foreign key constraint references could be left pointing
at tables dropped during operations simulating unsupported table alterations
because of an unexpected failure to disable foreign key constraint checks.

SQLite3 does not allow disabling such checks while in a transaction so they
must be disabled beforehand.

Thanks ezaquarii for the report and Carlton and Tim for the review.
2018-12-15 18:51:59 -05:00