Skip to content

Update setup_databases call to handle >3.1 #859

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

Closed
wants to merge 1 commit into from
Closed

Update setup_databases call to handle >3.1 #859

wants to merge 1 commit into from

Conversation

hugorodgerbrown
Copy link

Fixes #858


A breaking change in the current master on Django has added a mandatory time_keeper kwarg to the django.test.utils.setup_databases function signature. This is a TimeKeeper object which is used to record how long it takes to setup test databases. It is used internally by the Django tests themselves. A NullTimeKeeper object is available if timings are not required. I have used the NullTimeKeeper in this PR (as I don't think setup timing is a core pytest requirement?)

There are no additional tests for this change, as its main impact is in fixing the existing test suite. There should be a reduction in the number of current failures on py*_djmaster builds. I currently get these failures when running make test locally against the latest master of Django:

================================================================================================================= short test summary info =================================================================================================================
ERROR tests/test_asserts.py::test_sanity - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_transactions_disabled - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_django_db_reset_sequences_fixture - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixturesAllOrder::test_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_access - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_clean_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_transactions_disabled - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_transactions_disabled_explicit - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_reset_sequences_disabled - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_reset_sequences_enabled - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::TestDirectAccessWorksForDjangoTestCase::test_one - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::TestDirectAccessWorksForDjangoTestCase::test_two - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_database_rollback - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_database_rollback_again - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_database_name - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_clear_site_cache[site1] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_clear_site_cache[site2] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_clear_site_cache_check_site_cache_size[site1] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_environment.py::test_clear_site_cache_check_site_cache_size[site2] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_admin_client - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_admin_client_no_db_marker - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_admin_user - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_admin_user_no_db_marker - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_django_assert_num_queries_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_django_assert_max_num_queries_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_django_assert_num_queries_db_connection - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_django_assert_num_queries_output_info - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_fixture_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_item_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::Test_django_db_blocker::test_block_manually - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::Test_django_db_blocker::test_block_with_block - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestFixtures::test_fixtures - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestFixtures::test_fixtures_again - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestSetup::test_count - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestSetup::test_count_again - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestFixturesWithSetup::test_count - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestFixturesWithSetup::test_count_again - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestCaseWithDbFixture::test_simple - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_unittest.py::TestCaseWithTrDbFixture::test_simple - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_transactions_enabled - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixturesAllOrder::test_trans - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixturesAllOrder::test_db_trans - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixturesAllOrder::test_trans_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixturesAllOrder::test_reset_sequences - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseMarker::test_transactions_enabled - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::test_django_assert_num_queries_transactional_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_fixture_transactional_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_item_transactional_db - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_access[db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_access[transactional_db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_access[django_db_reset_sequences] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_clean_db[db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_clean_db[transactional_db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_clean_db[django_db_reset_sequences] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_transactions_enabled_via_reset_seq - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_mydb[db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_mydb[transactional_db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_mydb[django_db_reset_sequences] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_fixture_clean[db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_fixture_clean[transactional_db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_fixture_clean[django_db_reset_sequences] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_fin[db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_fin[transactional_db] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_database.py::TestDatabaseFixtures::test_fin[django_db_reset_sequences] - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_url - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_change_settings - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_transactions - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_db_changes_visibility - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_item - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'
ERROR tests/test_fixtures.py::TestLiveServer::test_serve_static_dj17_without_staticfiles_app - TypeError: setup_databases() missing 1 required keyword-only argument: 'time_keeper'

@hugorodgerbrown hugorodgerbrown changed the title Update setup_databases call to handle 3.1+ Update setup_databases call to handle >3.1 Aug 15, 2020
@hugorodgerbrown
Copy link
Author

Existing tests are failing (unrelated to this PR):

FAILED tests/test_db_setup.py::test_xdist_with_reuse - assert <ExitCode.TESTS_FAILED: 1> == 0
FAILED tests/test_db_setup.py::TestSqliteWithMultipleDbsAndXdist::test_sqlite_database_renamed - assert <ExitCode.TESTS_FAILED: 1> == 0
FAILED tests/test_db_setup.py::TestSqliteWithToxAndXdist::test_db_with_tox_suffix - assert <ExitCode.TESTS_FAILED: 1> == 0

@hugorodgerbrown
Copy link
Author

Further investigation of the test failures - I've rolled back through from HEAD to v.3.6.0 and can't get any clear test runs working on the three failures. They are related to naming of test databases when using xdist - the _gw* suffix isn't being used. No idea why not, or whether it's a problem.

@bluetech
Copy link
Member

Thanks @hugorodgerbrown, this was handled by #857 which took a similar approach.

@bluetech bluetech closed this Aug 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Django setup_databases call signature change post 3.1 causes test setup to fail
2 participants