You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2023/03/09 17:22:51 UTC

[impala] 02/06: IMPALA-11973: Add absolute_import, division to all eligible Python files

This is an automated email from the ASF dual-hosted git repository.

joemcdonnell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 82bd087fb1dcd2685ad1994364dd41182dcf840f
Author: Joe McDonnell <jo...@cloudera.com>
AuthorDate: Wed Mar 1 16:03:34 2023 -0800

    IMPALA-11973: Add absolute_import, division to all eligible Python files
    
    This takes steps to make Python 2 behave like Python 3 as
    a way to flush out issues with running on Python 3. Specifically,
    it handles two main differences:
     1. Python 3 requires absolute imports within packages. This
        can be emulated via "from __future__ import absolute_import"
     2. Python 3 changed division to "true" division that doesn't
        round to an integer. This can be emulated via
        "from __future__ import division"
    
    This changes all Python files to add imports for absolute_import
    and division. For completeness, this also includes print_function in the
    import.
    
    I scrutinized each old-division location and converted some locations
    to use the integer division '//' operator if it needed an integer
    result (e.g. for indices, counts of records, etc). Some code was also using
    relative imports and needed to be adjusted to handle absolute_import.
    This fixes all Pylint warnings about no-absolute-import and old-division,
    and these warnings are now banned.
    
    Testing:
     - Ran core tests
    
    Change-Id: Idb0fcbd11f3e8791f5951c4944be44fb580e576b
    Reviewed-on: http://gerrit.cloudera.org:8080/19588
    Reviewed-by: Joe McDonnell <jo...@cloudera.com>
    Tested-by: Joe McDonnell <jo...@cloudera.com>
---
 bin/banned_py3k_warnings.txt                                   |  2 ++
 bin/dump_breakpad_symbols.py                                   |  1 +
 bin/generate_minidump_collection_testdata.py                   |  1 +
 bin/get_code_size.py                                           |  2 +-
 bin/inline_pom.py                                              |  2 +-
 bin/load-data.py                                               |  2 +-
 bin/parse-thrift-profile.py                                    |  2 +-
 bin/run-workload.py                                            |  2 +-
 bin/single_node_perf_run.py                                    |  2 +-
 bin/start-impala-cluster.py                                    |  3 ++-
 docker/setup_build_context.py                                  |  1 +
 infra/python/bootstrap_virtualenv.py                           |  2 +-
 lib/python/impala_py_lib/gdb/impala-gdb.py                     |  2 +-
 lib/python/impala_py_lib/helpers.py                            |  1 +
 lib/python/impala_py_lib/profiles.py                           |  2 +-
 testdata/bin/check-hbase-nodes.py                              |  3 ++-
 testdata/bin/generate-schema-statements.py                     |  2 +-
 testdata/bin/generate-test-vectors.py                          |  2 +-
 testdata/bin/load-tpc-kudu.py                                  |  2 +-
 testdata/bin/load_nested.py                                    |  1 +
 testdata/bin/random_avro_schema.py                             |  1 +
 testdata/bin/rewrite-iceberg-metadata.py                       |  2 +-
 testdata/bin/wait-for-hiveserver2.py                           |  2 +-
 testdata/bin/wait-for-metastore.py                             |  2 +-
 testdata/common/cgroups.py                                     |  2 +-
 testdata/common/text_delims_table.py                           |  4 ++--
 testdata/common/widetable.py                                   |  4 ++--
 tests/authorization/test_authorization.py                      |  1 +
 tests/authorization/test_authorized_proxy.py                   |  1 +
 tests/authorization/test_provider.py                           |  1 +
 tests/authorization/test_ranger.py                             |  1 +
 tests/beeswax/impala_beeswax.py                                |  3 ++-
 tests/benchmark/plugins/clear_buffer_cache.py                  |  1 +
 tests/benchmark/plugins/vtune_plugin.py                        |  1 +
 tests/benchmark/report_benchmark_results.py                    |  3 +--
 tests/catalog_service/test_catalog_service_client.py           |  1 +
 tests/catalog_service/test_large_num_partitions.py             |  1 +
 tests/common/base_test_suite.py                                |  1 +
 tests/common/custom_cluster_test_suite.py                      |  1 +
 tests/common/environ.py                                        |  1 +
 tests/common/file_utils.py                                     |  1 +
 tests/common/iceberg_test_suite.py                             |  1 +
 tests/common/impala_cluster.py                                 |  2 +-
 tests/common/impala_connection.py                              |  1 +
 tests/common/impala_service.py                                 |  1 +
 tests/common/impala_test_suite.py                              |  2 +-
 tests/common/kudu_test_suite.py                                |  1 +
 tests/common/network.py                                        |  1 +
 tests/common/parametrize.py                                    |  1 +
 tests/common/patterns.py                                       |  1 +
 tests/common/resource_pool_config.py                           |  2 +-
 tests/common/skip.py                                           |  1 +
 tests/common/test_dimensions.py                                |  1 +
 tests/common/test_result_verifier.py                           |  1 +
 tests/common/test_vector.py                                    |  1 +
 tests/comparison/cli_options.py                                |  1 +
 tests/comparison/cluster.py                                    | 10 +++++-----
 tests/comparison/common.py                                     |  1 +
 tests/comparison/compat.py                                     |  1 +
 tests/comparison/data_generator.py                             |  5 +++--
 tests/comparison/data_generator_mapred_common.py               |  5 +++--
 tests/comparison/db_connection.py                              |  2 +-
 tests/comparison/db_types.py                                   |  3 ++-
 tests/comparison/discrepancy_searcher.py                       |  8 ++++----
 tests/comparison/funcs.py                                      |  1 +
 tests/comparison/leopard/controller.py                         |  3 ++-
 tests/comparison/leopard/front_end.py                          |  5 +++--
 tests/comparison/leopard/impala_docker_env.py                  |  2 +-
 tests/comparison/leopard/job.py                                |  4 ++--
 tests/comparison/leopard/report.py                             |  1 +
 tests/comparison/leopard/schedule_item.py                      |  1 +
 tests/comparison/model_translator.py                           |  1 +
 tests/comparison/query.py                                      |  1 +
 tests/comparison/query_flattener.py                            |  1 +
 tests/comparison/query_generator.py                            |  2 +-
 tests/comparison/query_profile.py                              |  1 +
 tests/comparison/random_val_generator.py                       |  1 +
 tests/comparison/statement_generator.py                        |  1 +
 tests/comparison/tests/conftest.py                             |  1 +
 tests/comparison/tests/fake_query.py                           |  1 +
 .../tests/hive/test_hive_create_agg_or_analytic_tree.py        |  1 +
 .../tests/hive/test_hive_create_relational_join_condition.py   |  1 +
 tests/comparison/tests/query_object_testdata.py                |  1 +
 tests/comparison/tests/test_cluster.py                         |  1 +
 tests/comparison/tests/test_cursor.py                          |  1 +
 tests/comparison/tests/test_query_generator.py                 |  3 ++-
 tests/comparison/tests/test_query_objects.py                   |  1 +
 tests/comparison/tests/test_use_nested_with.py                 |  1 +
 tests/comparison/util/verify-oracle-connection.py              |  2 +-
 tests/conftest.py                                              |  4 ++--
 tests/custom_cluster/test_admission_controller.py              |  5 +++--
 tests/custom_cluster/test_alloc_fail.py                        |  1 +
 tests/custom_cluster/test_always_false_filter.py               |  1 +
 tests/custom_cluster/test_auto_scaling.py                      |  1 +
 tests/custom_cluster/test_automatic_invalidation.py            |  1 +
 tests/custom_cluster/test_blacklist.py                         |  2 +-
 tests/custom_cluster/test_blacklisted_dbs_and_tables.py        |  1 +
 tests/custom_cluster/test_breakpad.py                          |  2 +-
 tests/custom_cluster/test_catalog_hms_failures.py              |  2 +-
 tests/custom_cluster/test_catalog_wait.py                      |  1 +
 tests/custom_cluster/test_client_ssl.py                        |  2 +-
 tests/custom_cluster/test_codegen_cache.py                     |  1 +
 tests/custom_cluster/test_compact_catalog_updates.py           |  1 +
 tests/custom_cluster/test_concurrent_ddls.py                   |  1 +
 tests/custom_cluster/test_concurrent_kudu_create.py            |  1 +
 tests/custom_cluster/test_coordinators.py                      |  1 +
 tests/custom_cluster/test_custom_hive_configs.py               |  1 +
 tests/custom_cluster/test_custom_statestore.py                 |  1 +
 tests/custom_cluster/test_data_cache.py                        |  1 +
 tests/custom_cluster/test_delegation.py                        |  1 +
 tests/custom_cluster/test_disable_catalog_data_ops.py          |  1 +
 tests/custom_cluster/test_disable_features.py                  |  1 +
 tests/custom_cluster/test_disk_spill_configurations.py         |  1 +
 tests/custom_cluster/test_events_custom_configs.py             |  2 +-
 tests/custom_cluster/test_exchange_deferred_batches.py         |  1 +
 tests/custom_cluster/test_exchange_delays.py                   |  1 +
 tests/custom_cluster/test_exchange_eos.py                      |  1 +
 tests/custom_cluster/test_executor_groups.py                   |  1 +
 tests/custom_cluster/test_frontend_connection_limit.py         |  1 +
 tests/custom_cluster/test_geospatial_library.py                |  2 ++
 tests/custom_cluster/test_hbase_hms_column_order.py            |  1 +
 tests/custom_cluster/test_hdfs_fd_caching.py                   |  1 +
 tests/custom_cluster/test_hdfs_timeout.py                      |  1 +
 tests/custom_cluster/test_hedged_reads.py                      |  1 +
 tests/custom_cluster/test_hive_parquet_codec_interop.py        |  1 +
 tests/custom_cluster/test_hive_parquet_timestamp_conversion.py |  1 +
 tests/custom_cluster/test_hive_text_codec_interop.py           |  1 +
 tests/custom_cluster/test_hs2.py                               |  1 +
 tests/custom_cluster/test_hs2_fault_injection.py               |  1 +
 tests/custom_cluster/test_incremental_metadata_updates.py      |  1 +
 tests/custom_cluster/test_insert_behaviour.py                  |  1 +
 tests/custom_cluster/test_jvm_mem_tracking.py                  |  1 +
 tests/custom_cluster/test_krpc_mem_usage.py                    |  1 +
 tests/custom_cluster/test_krpc_metrics.py                      |  1 +
 tests/custom_cluster/test_krpc_options.py                      |  1 +
 tests/custom_cluster/test_krpc_socket.py                       |  1 +
 tests/custom_cluster/test_kudu.py                              |  1 +
 tests/custom_cluster/test_kudu_not_available.py                |  1 +
 tests/custom_cluster/test_kudu_table_create_without_hms.py     |  1 +
 tests/custom_cluster/test_lineage.py                           |  1 +
 tests/custom_cluster/test_local_catalog.py                     |  2 +-
 tests/custom_cluster/test_local_tz_conversion.py               |  1 +
 tests/custom_cluster/test_logging.py                           |  1 +
 tests/custom_cluster/test_mem_reservations.py                  |  1 +
 tests/custom_cluster/test_metadata_no_events_processing.py     |  1 +
 tests/custom_cluster/test_metadata_replicas.py                 |  1 +
 tests/custom_cluster/test_metastore_events_cleanup.py          |  1 +
 tests/custom_cluster/test_metastore_service.py                 |  1 +
 tests/custom_cluster/test_mt_dop.py                            |  1 +
 tests/custom_cluster/test_observability.py                     |  1 +
 tests/custom_cluster/test_parquet_max_page_header.py           |  1 +
 tests/custom_cluster/test_partition.py                         |  1 +
 tests/custom_cluster/test_pause_monitor.py                     |  1 +
 tests/custom_cluster/test_permanent_udfs.py                    |  1 +
 tests/custom_cluster/test_preload_table_types.py               |  1 +
 tests/custom_cluster/test_process_failures.py                  |  1 +
 tests/custom_cluster/test_query_concurrency.py                 |  1 +
 tests/custom_cluster/test_query_event_hooks.py                 |  1 +
 tests/custom_cluster/test_query_expiration.py                  |  1 +
 tests/custom_cluster/test_query_retries.py                     |  2 +-
 tests/custom_cluster/test_re2_max_mem.py                       |  1 +
 tests/custom_cluster/test_redaction.py                         |  1 +
 tests/custom_cluster/test_reserved_words_version.py            |  1 +
 tests/custom_cluster/test_restart_services.py                  |  6 +++---
 tests/custom_cluster/test_result_spooling.py                   |  1 +
 tests/custom_cluster/test_rpc_exception.py                     |  1 +
 tests/custom_cluster/test_rpc_timeout.py                       |  1 +
 tests/custom_cluster/test_runtime_profile.py                   |  1 +
 tests/custom_cluster/test_s3a_access.py                        |  1 +
 tests/custom_cluster/test_saml2_sso.py                         |  1 +
 tests/custom_cluster/test_scheduler_locality.py                |  1 +
 tests/custom_cluster/test_scratch_disk.py                      |  2 +-
 tests/custom_cluster/test_seq_file_filtering.py                |  1 +
 tests/custom_cluster/test_services_rpc_errors.py               |  1 +
 tests/custom_cluster/test_session_expiration.py                |  1 +
 tests/custom_cluster/test_set_and_unset.py                     |  1 +
 tests/custom_cluster/test_shared_tzdb.py                       |  1 +
 tests/custom_cluster/test_shell_commandline.py                 |  1 +
 tests/custom_cluster/test_shell_interactive.py                 |  1 +
 tests/custom_cluster/test_shell_interactive_reconnect.py       |  1 +
 tests/custom_cluster/test_startup_filesystem_checks.py         |  1 +
 tests/custom_cluster/test_stats_extrapolation.py               |  1 +
 tests/custom_cluster/test_thrift_debug_string_exception.py     |  1 +
 tests/custom_cluster/test_thrift_socket.py                     |  1 +
 tests/custom_cluster/test_topic_update_frequency.py            |  2 +-
 tests/custom_cluster/test_udf_concurrency.py                   |  2 +-
 tests/custom_cluster/test_web_pages.py                         |  2 +-
 tests/custom_cluster/test_wide_table_operations.py             |  1 +
 tests/data_errors/test_data_errors.py                          |  1 +
 tests/experiments/test_targeted_perf.py                        |  1 +
 tests/failure/test_failpoints.py                               |  1 +
 tests/hs2/hs2_test_suite.py                                    |  3 ++-
 tests/hs2/test_fetch.py                                        |  1 +
 tests/hs2/test_fetch_first.py                                  |  1 +
 tests/hs2/test_fetch_timeout.py                                |  1 +
 tests/hs2/test_hs2.py                                          |  1 +
 tests/hs2/test_json_endpoints.py                               |  1 +
 tests/infra/test_perf_infra.py                                 |  1 +
 tests/infra/test_stress_infra.py                               |  1 +
 tests/infra/test_utils.py                                      |  1 +
 tests/metadata/test_catalogd_debug_actions.py                  |  1 +
 tests/metadata/test_compute_stats.py                           |  1 +
 tests/metadata/test_ddl.py                                     |  5 +++--
 tests/metadata/test_ddl_base.py                                |  1 +
 tests/metadata/test_event_processing.py                        |  1 +
 tests/metadata/test_explain.py                                 |  1 +
 tests/metadata/test_hdfs_encryption.py                         |  1 +
 tests/metadata/test_hdfs_permissions.py                        |  1 +
 tests/metadata/test_hidden_files.py                            |  1 +
 tests/metadata/test_hms_integration.py                         |  2 +-
 tests/metadata/test_last_ddl_time_update.py                    |  1 +
 tests/metadata/test_load.py                                    |  1 +
 tests/metadata/test_metadata_query_statements.py               |  1 +
 tests/metadata/test_partition_metadata.py                      |  1 +
 tests/metadata/test_recover_partitions.py                      |  1 +
 tests/metadata/test_recursive_listing.py                       |  1 +
 tests/metadata/test_refresh_partition.py                       |  1 +
 tests/metadata/test_reset_metadata.py                          |  1 +
 tests/metadata/test_reuse_partitions.py                        |  1 +
 tests/metadata/test_set.py                                     |  1 +
 tests/metadata/test_show_create_table.py                       |  1 +
 tests/metadata/test_stale_metadata.py                          |  1 +
 tests/metadata/test_stats_extrapolation.py                     |  1 +
 tests/metadata/test_testcase_builder.py                        |  1 +
 tests/metadata/test_views_compatibility.py                     |  1 +
 tests/observability/test_jvm_metrics.py                        |  1 +
 tests/observability/test_log_fragments.py                      |  1 +
 tests/observability/test_profile_tool.py                       |  1 +
 tests/performance/query.py                                     |  1 +
 tests/performance/query_exec_functions.py                      |  1 +
 tests/performance/query_executor.py                            |  1 +
 tests/performance/scheduler.py                                 |  1 +
 tests/performance/workload.py                                  |  1 +
 tests/performance/workload_runner.py                           |  1 +
 tests/query_test/test_acid.py                                  |  1 +
 tests/query_test/test_acid_row_validation.py                   |  1 +
 tests/query_test/test_aggregation.py                           |  2 +-
 tests/query_test/test_analytic_tpcds.py                        |  1 +
 tests/query_test/test_async_codegen.py                         |  1 +
 tests/query_test/test_avro_schema_resolution.py                |  1 +
 tests/query_test/test_beeswax.py                               |  1 +
 tests/query_test/test_cancellation.py                          |  1 +
 tests/query_test/test_cast_with_format.py                      |  1 +
 tests/query_test/test_chars.py                                 |  1 +
 tests/query_test/test_codegen.py                               |  1 +
 tests/query_test/test_compressed_formats.py                    |  4 ++--
 tests/query_test/test_datasketches.py                          |  1 +
 tests/query_test/test_datastream_sender.py                     |  1 +
 tests/query_test/test_date_queries.py                          |  1 +
 tests/query_test/test_decimal_casting.py                       |  1 +
 tests/query_test/test_decimal_fuzz.py                          |  3 ++-
 tests/query_test/test_decimal_queries.py                       |  1 +
 tests/query_test/test_delimited_text.py                        |  1 +
 tests/query_test/test_errorlog.py                              |  1 +
 tests/query_test/test_exprs.py                                 |  3 ++-
 tests/query_test/test_fetch.py                                 |  1 +
 tests/query_test/test_geospatial_functions.py                  |  1 +
 tests/query_test/test_hash_join_timer.py                       |  5 +++--
 tests/query_test/test_hbase_queries.py                         |  1 +
 tests/query_test/test_hdfs_caching.py                          |  2 +-
 tests/query_test/test_hdfs_file_mods.py                        |  1 +
 tests/query_test/test_iceberg.py                               |  1 +
 tests/query_test/test_insert.py                                |  1 +
 tests/query_test/test_insert_behaviour.py                      |  1 +
 tests/query_test/test_insert_parquet.py                        |  1 +
 tests/query_test/test_insert_permutation.py                    |  1 +
 tests/query_test/test_invalid_test_header.py                   |  1 +
 tests/query_test/test_io_metrics.py                            |  1 +
 tests/query_test/test_join_queries.py                          |  1 +
 tests/query_test/test_kudu.py                                  |  2 +-
 tests/query_test/test_lifecycle.py                             |  1 +
 tests/query_test/test_limit.py                                 |  2 +-
 tests/query_test/test_limit_pushdown_analytic.py               |  1 +
 tests/query_test/test_local_fs.py                              |  1 +
 tests/query_test/test_mem_usage_scaling.py                     |  2 ++
 tests/query_test/test_mt_dop.py                                |  1 +
 tests/query_test/test_multiple_filesystems.py                  |  1 +
 tests/query_test/test_nested_types.py                          |  1 +
 tests/query_test/test_observability.py                         |  1 +
 tests/query_test/test_orc_stats.py                             |  1 +
 tests/query_test/test_parquet_bloom_filter.py                  |  1 +
 tests/query_test/test_parquet_late_materialization.py          |  1 +
 tests/query_test/test_parquet_page_index.py                    |  1 +
 tests/query_test/test_parquet_stats.py                         |  1 +
 tests/query_test/test_partitioning.py                          |  1 +
 tests/query_test/test_queries.py                               |  1 +
 tests/query_test/test_query_compilation.py                     |  1 +
 tests/query_test/test_query_mem_limit.py                       |  5 +++--
 tests/query_test/test_query_opts.py                            |  1 +
 tests/query_test/test_resource_limits.py                       |  1 +
 tests/query_test/test_result_spooling.py                       |  1 +
 tests/query_test/test_rows_availability.py                     |  1 +
 tests/query_test/test_runtime_filters.py                       |  1 +
 tests/query_test/test_scanners.py                              |  2 +-
 tests/query_test/test_scanners_fuzz.py                         |  1 +
 tests/query_test/test_scratch_limit.py                         |  1 +
 tests/query_test/test_sfs.py                                   |  1 +
 tests/query_test/test_sort.py                                  |  1 +
 tests/query_test/test_spilling.py                              |  1 +
 tests/query_test/test_tablesample.py                           |  1 +
 tests/query_test/test_tpcds_queries.py                         |  1 +
 tests/query_test/test_tpch_nested_queries.py                   |  1 +
 tests/query_test/test_tpch_queries.py                          |  1 +
 tests/query_test/test_udfs.py                                  |  1 +
 tests/query_test/test_utf8_strings.py                          |  1 +
 tests/run-tests.py                                             |  2 +-
 tests/shell/test_cookie_util.py                                |  1 +
 tests/shell/test_shell_client.py                               |  7 ++++---
 tests/shell/test_shell_commandline.py                          |  7 ++++---
 tests/shell/test_shell_interactive.py                          |  8 ++++----
 tests/shell/util.py                                            |  2 +-
 tests/statestore/test_statestore.py                            |  2 +-
 tests/stress/concurrent_select.py                              |  8 ++++----
 tests/stress/extract_min_mem.py                                |  2 +-
 tests/stress/mem_broker.py                                     |  1 +
 tests/stress/queries.py                                        |  1 +
 tests/stress/query_retries_stress_runner.py                    |  1 +
 tests/stress/query_runner.py                                   |  1 +
 tests/stress/runtime_info.py                                   |  2 +-
 tests/stress/stress_util.py                                    |  1 +
 tests/stress/test_acid_stress.py                               |  1 +
 tests/stress/test_ddl_stress.py                                |  1 +
 tests/stress/test_insert_stress.py                             |  1 +
 tests/stress/util.py                                           |  2 +-
 tests/unittests/test_command.py                                |  1 +
 tests/unittests/test_file_parser.py                            |  2 +-
 tests/unittests/test_result_verifier.py                        |  1 +
 tests/util/acid_txn.py                                         |  2 +-
 tests/util/adls_util.py                                        |  1 +
 tests/util/auto_scaler.py                                      |  3 ++-
 tests/util/calculation_util.py                                 |  5 +++--
 tests/util/cancel_util.py                                      |  1 +
 tests/util/cluster_controller.py                               |  1 +
 tests/util/compute_table_stats.py                              |  1 +
 tests/util/concurrent_workload.py                              |  1 +
 tests/util/event_processor_utils.py                            |  1 +
 tests/util/failpoints_util.py                                  |  1 +
 tests/util/filesystem_base.py                                  |  1 +
 tests/util/filesystem_utils.py                                 |  1 +
 tests/util/get_parquet_metadata.py                             |  1 +
 tests/util/hdfs_util.py                                        |  1 +
 tests/util/iceberg_util.py                                     |  1 +
 tests/util/parse_util.py                                       |  1 +
 tests/util/plugin_runner.py                                    |  1 +
 tests/util/run_impyla_http_query.py                            |  2 +-
 tests/util/shell_util.py                                       |  1 +
 tests/util/ssh_util.py                                         |  1 +
 tests/util/test_file_parser.py                                 |  2 +-
 tests/util/thrift_util.py                                      |  1 +
 tests/util/web_pages_util.py                                   |  1 +
 tests/verifiers/mem_usage_verifier.py                          |  1 +
 tests/verifiers/metric_verifier.py                             |  1 +
 tests/verifiers/test_verify_metrics.py                         |  1 +
 tests/webserver/test_web_pages.py                              |  1 +
 354 files changed, 409 insertions(+), 114 deletions(-)

diff --git a/bin/banned_py3k_warnings.txt b/bin/banned_py3k_warnings.txt
index e69de29bb..c5e7bdc12 100644
--- a/bin/banned_py3k_warnings.txt
+++ b/bin/banned_py3k_warnings.txt
@@ -0,0 +1,2 @@
+no-absolute-import
+old-division
diff --git a/bin/dump_breakpad_symbols.py b/bin/dump_breakpad_symbols.py
index b4edff494..81bf00d54 100755
--- a/bin/dump_breakpad_symbols.py
+++ b/bin/dump_breakpad_symbols.py
@@ -53,6 +53,7 @@
 #   $IMPALA_TOOLCHAIN_PACKAGES_HOME/breakpad-*/bin/minidump_stackwalk \
 #   /tmp/impala-minidumps/impalad/03c0ee26-bfd1-cf3e-43fa49ca-1a6aae25.dmp /tmp/syms
 
+from __future__ import absolute_import, division, print_function
 import errno
 import logging
 import glob
diff --git a/bin/generate_minidump_collection_testdata.py b/bin/generate_minidump_collection_testdata.py
index 2cee8b9af..09341f539 100755
--- a/bin/generate_minidump_collection_testdata.py
+++ b/bin/generate_minidump_collection_testdata.py
@@ -27,6 +27,7 @@
 # create the files in the interval [now - duration, now]. Minidumps are simulated by
 # making the files easily compressible by having some repeated data.
 
+from __future__ import absolute_import, division, print_function
 import errno
 import os
 import random
diff --git a/bin/get_code_size.py b/bin/get_code_size.py
index b7d6eda6f..44afba04f 100755
--- a/bin/get_code_size.py
+++ b/bin/get_code_size.py
@@ -19,7 +19,7 @@
 
 # This tool walks the build directory (release by default) and will print the text, data,
 # and bss section sizes of the archives.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import fnmatch
 import os
 import re
diff --git a/bin/inline_pom.py b/bin/inline_pom.py
index 1b021683a..3b99560d1 100755
--- a/bin/inline_pom.py
+++ b/bin/inline_pom.py
@@ -21,7 +21,7 @@
 #
 # Usage: inline_pom.py <pom.xml>...
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import re
 import sys
 from tempfile import mkstemp
diff --git a/bin/load-data.py b/bin/load-data.py
index 362ec8ee3..3c35cfc59 100755
--- a/bin/load-data.py
+++ b/bin/load-data.py
@@ -20,7 +20,7 @@
 # This script is used to load the proper datasets for the specified workloads. It loads
 # all data via Hive except for parquet data which needs to be loaded via Impala.
 # Most ddl commands are executed by Impala.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import collections
 import getpass
 import logging
diff --git a/bin/parse-thrift-profile.py b/bin/parse-thrift-profile.py
index 7661e1ff0..8e16aa079 100755
--- a/bin/parse-thrift-profile.py
+++ b/bin/parse-thrift-profile.py
@@ -39,7 +39,7 @@
 # 2018-04-13T15:06:34.144000 e44af7f93edb8cd6:1b1f801600000000 TRuntimeProfileTree(nodes=[TRuntimeProf...
 
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from impala_py_lib import profiles
 import sys
 
diff --git a/bin/run-workload.py b/bin/run-workload.py
index abe95ceb1..1da5dd0f5 100755
--- a/bin/run-workload.py
+++ b/bin/run-workload.py
@@ -27,7 +27,7 @@
 #   - Stores the execution details in JSON format.
 #
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import getpass
 import json
 import logging
diff --git a/bin/single_node_perf_run.py b/bin/single_node_perf_run.py
index e1b74de64..f64d94e6c 100755
--- a/bin/single_node_perf_run.py
+++ b/bin/single_node_perf_run.py
@@ -69,7 +69,7 @@
 #   --start_minicluster   start a new Hadoop minicluster
 #   --ninja               use ninja, rather than Make, as the build tool
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from optparse import OptionParser
 from tempfile import mkdtemp
 
diff --git a/bin/start-impala-cluster.py b/bin/start-impala-cluster.py
index b1e94545e..6c5fa07d4 100755
--- a/bin/start-impala-cluster.py
+++ b/bin/start-impala-cluster.py
@@ -20,6 +20,7 @@
 # Starts up an Impala cluster (ImpalaD + State Store) with the specified number of
 # ImpalaD instances. Each ImpalaD runs on a different port allowing this to be run
 # on a single machine.
+from __future__ import absolute_import, division, print_function
 import getpass
 import itertools
 import json
@@ -473,7 +474,7 @@ def compute_impalad_mem_limit(cluster_size):
   # memory choice here to max out at 12GB. This should be sufficient for tests.
   #
   # Beware that ASAN builds use more memory than regular builds.
-  physical_mem_gb = psutil.virtual_memory().total / 1024 / 1024 / 1024
+  physical_mem_gb = psutil.virtual_memory().total // 1024 // 1024 // 1024
   available_mem = int(os.getenv("IMPALA_CLUSTER_MAX_MEM_GB", str(physical_mem_gb)))
   mem_limit = int(0.7 * available_mem * 1024 * 1024 * 1024 / cluster_size)
   return min(12 * 1024 * 1024 * 1024, mem_limit)
diff --git a/docker/setup_build_context.py b/docker/setup_build_context.py
index cd2955d97..9d32ab1d6 100755
--- a/docker/setup_build_context.py
+++ b/docker/setup_build_context.py
@@ -20,6 +20,7 @@
 # Most artifacts are symlinked so need to be dereferenced (e.g. with tar -h) before
 # being used as a build context.
 
+from __future__ import absolute_import, division, print_function
 import argparse
 import glob
 import os
diff --git a/infra/python/bootstrap_virtualenv.py b/infra/python/bootstrap_virtualenv.py
index bd9c08144..5a96ad3c6 100644
--- a/infra/python/bootstrap_virtualenv.py
+++ b/infra/python/bootstrap_virtualenv.py
@@ -32,7 +32,7 @@
 # This module can be run with python >= 2.7. It makes no guarantees about usage on
 # python < 2.7.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import glob
 import logging
 import optparse
diff --git a/lib/python/impala_py_lib/gdb/impala-gdb.py b/lib/python/impala_py_lib/gdb/impala-gdb.py
index 1bf81eabc..c5aa93d21 100644
--- a/lib/python/impala_py_lib/gdb/impala-gdb.py
+++ b/lib/python/impala_py_lib/gdb/impala-gdb.py
@@ -19,7 +19,7 @@
 # A collection of useful Python GDB modules and commands for
 # debugging Impala core dumps.
 #
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import gdb
 from collections import defaultdict
 
diff --git a/lib/python/impala_py_lib/helpers.py b/lib/python/impala_py_lib/helpers.py
index 9631ba75b..4fc2f32a8 100644
--- a/lib/python/impala_py_lib/helpers.py
+++ b/lib/python/impala_py_lib/helpers.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import fnmatch
 import logging
 import os
diff --git a/lib/python/impala_py_lib/profiles.py b/lib/python/impala_py_lib/profiles.py
index fc7a37298..4d5ecb731 100644
--- a/lib/python/impala_py_lib/profiles.py
+++ b/lib/python/impala_py_lib/profiles.py
@@ -18,7 +18,7 @@
 
 # This file contains library functions to decode and access Impala query profiles.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import base64
 import datetime
 import zlib
diff --git a/testdata/bin/check-hbase-nodes.py b/testdata/bin/check-hbase-nodes.py
index ffe7a7c23..876955de5 100755
--- a/testdata/bin/check-hbase-nodes.py
+++ b/testdata/bin/check-hbase-nodes.py
@@ -20,6 +20,7 @@
 """Given a series of hosts and Zookeeper nodes, make sure that each node is accessible.
 """
 
+from __future__ import absolute_import, division, print_function
 import argparse
 import hdfs
 import logging
@@ -191,4 +192,4 @@ if __name__ == "__main__":
             LOGGER.error(msg)
             sys.exit(errors)
     else:
-        sys.exit(1)
\ No newline at end of file
+        sys.exit(1)
diff --git a/testdata/bin/generate-schema-statements.py b/testdata/bin/generate-schema-statements.py
index acd369db4..23cb88556 100755
--- a/testdata/bin/generate-schema-statements.py
+++ b/testdata/bin/generate-schema-statements.py
@@ -94,7 +94,7 @@
 # This should be used sparingly, because these commands are executed
 # serially.
 #
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import collections
 import csv
 import glob
diff --git a/testdata/bin/generate-test-vectors.py b/testdata/bin/generate-test-vectors.py
index c7d288bd8..00e7228e8 100755
--- a/testdata/bin/generate-test-vectors.py
+++ b/testdata/bin/generate-test-vectors.py
@@ -40,7 +40,7 @@
 # The pairwise generation is done using the Python 'AllPairs' module. This module can be
 # downloaded from http://pypi.python.org/pypi/AllPairs/2.0.1
 #
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import collections
 import csv
 import math
diff --git a/testdata/bin/load-tpc-kudu.py b/testdata/bin/load-tpc-kudu.py
index 422d064ba..6f0610ffa 100755
--- a/testdata/bin/load-tpc-kudu.py
+++ b/testdata/bin/load-tpc-kudu.py
@@ -22,7 +22,7 @@
 # Kudu tables are created in the specified 'target-db' using the existing HDFS tables
 # from 'source-db'.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import sqlparse
diff --git a/testdata/bin/load_nested.py b/testdata/bin/load_nested.py
index a4ae42646..7a4faceed 100755
--- a/testdata/bin/load_nested.py
+++ b/testdata/bin/load_nested.py
@@ -20,6 +20,7 @@
 '''This script creates a nested version of TPC-H. Non-nested TPC-H must already be
    loaded.
 '''
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 
diff --git a/testdata/bin/random_avro_schema.py b/testdata/bin/random_avro_schema.py
index ccdf25c05..e065b1dcc 100755
--- a/testdata/bin/random_avro_schema.py
+++ b/testdata/bin/random_avro_schema.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from random import choice, randint, random, shuffle
 from os.path import join as join_path
 from optparse import OptionParser
diff --git a/testdata/bin/rewrite-iceberg-metadata.py b/testdata/bin/rewrite-iceberg-metadata.py
index 26997345b..2f8e22e32 100755
--- a/testdata/bin/rewrite-iceberg-metadata.py
+++ b/testdata/bin/rewrite-iceberg-metadata.py
@@ -17,7 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import glob
 import json
 import os
diff --git a/testdata/bin/wait-for-hiveserver2.py b/testdata/bin/wait-for-hiveserver2.py
index 6e99fa5f3..6ba00f012 100755
--- a/testdata/bin/wait-for-hiveserver2.py
+++ b/testdata/bin/wait-for-hiveserver2.py
@@ -22,7 +22,7 @@
 # TODO: Consider combining this with wait-for-metastore.py. A TCLIService client
 # can perhaps also talk to the metastore.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import time
 import getpass
diff --git a/testdata/bin/wait-for-metastore.py b/testdata/bin/wait-for-metastore.py
index 0707cc16b..6b62487c0 100755
--- a/testdata/bin/wait-for-metastore.py
+++ b/testdata/bin/wait-for-metastore.py
@@ -21,7 +21,7 @@
 # to execute the get_database("default") Thrift RPC until the call succeeds,
 # or a timeout is reached.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import time
 from optparse import OptionParser
diff --git a/testdata/common/cgroups.py b/testdata/common/cgroups.py
index 5e1f6f73e..36fe5b75f 100755
--- a/testdata/common/cgroups.py
+++ b/testdata/common/cgroups.py
@@ -19,7 +19,7 @@
 
 # Utility code for creating cgroups for the Impala development environment.
 # May be used as a library or as a command-line utility for manual testing.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import sys
 import errno
diff --git a/testdata/common/text_delims_table.py b/testdata/common/text_delims_table.py
index 92b2d01a4..a5b06acf0 100755
--- a/testdata/common/text_delims_table.py
+++ b/testdata/common/text_delims_table.py
@@ -22,7 +22,7 @@
 # command line, will generate data files in the specified directory and a
 # print a SQL load statement to incorporate into dataload SQL script generation.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from shutil import rmtree
 from optparse import OptionParser
 from contextlib import contextmanager
@@ -35,7 +35,7 @@ parser.add_option("--only_newline", dest="only_newline", default=False, action="
 parser.add_option("--file_len", dest="file_len", type="int")
 
 def generate_testescape_files(table_location, only_newline, file_len):
-  data = ''.join(["1234567890" for _ in xrange(1 + file_len / 10)])
+  data = ''.join(["1234567890" for _ in xrange(1 + file_len // 10)])
 
   suffix_list = ["\\", ",", "a"]
   if only_newline:
diff --git a/testdata/common/widetable.py b/testdata/common/widetable.py
index dcd31de49..f04b5cc69 100755
--- a/testdata/common/widetable.py
+++ b/testdata/common/widetable.py
@@ -22,7 +22,7 @@
 # generate a CSV data file and prints a SQL load statement to incorporate
 # into dataload SQL script generation.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from datetime import datetime, timedelta
 import itertools
 import optparse
@@ -51,7 +51,7 @@ def get_columns(num_cols):
   iter = itertools.cycle(templates)
   # Produces [bool_col1, tinyint_col1, ..., bool_col2, tinyint_col2, ...]
   # The final list has 'num_cols' elements.
-  return  [iter.next() % (i / len(templates) + 1) for i in xrange(num_cols)]
+  return [iter.next() % (i // len(templates) + 1) for i in xrange(num_cols)]
 
 # Data generators for different types. Each generator yields an infinite number of
 # value strings suitable for writing to a CSV file.
diff --git a/tests/authorization/test_authorization.py b/tests/authorization/test_authorization.py
index 6f52ccc4d..059008370 100644
--- a/tests/authorization/test_authorization.py
+++ b/tests/authorization/test_authorization.py
@@ -17,6 +17,7 @@
 #
 # Client tests for SQL statement authorization
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import tempfile
diff --git a/tests/authorization/test_authorized_proxy.py b/tests/authorization/test_authorized_proxy.py
index 832a8505c..68053a840 100644
--- a/tests/authorization/test_authorized_proxy.py
+++ b/tests/authorization/test_authorized_proxy.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import os
 import grp
diff --git a/tests/authorization/test_provider.py b/tests/authorization/test_provider.py
index 362ca7ae9..f7e71ac61 100644
--- a/tests/authorization/test_provider.py
+++ b/tests/authorization/test_provider.py
@@ -17,6 +17,7 @@
 #
 # Client tests for SQL statement authorization
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import os
 import tempfile
diff --git a/tests/authorization/test_ranger.py b/tests/authorization/test_ranger.py
index e90e27055..03669f081 100644
--- a/tests/authorization/test_ranger.py
+++ b/tests/authorization/test_ranger.py
@@ -17,6 +17,7 @@
 #
 # Client tests for SQL statement authorization
 
+from __future__ import absolute_import, division, print_function
 import os
 import grp
 import json
diff --git a/tests/beeswax/impala_beeswax.py b/tests/beeswax/impala_beeswax.py
index 201532dc9..f7c2eb3f3 100644
--- a/tests/beeswax/impala_beeswax.py
+++ b/tests/beeswax/impala_beeswax.py
@@ -25,6 +25,7 @@
 #   client.connect()
 #   result = client.execute(query_string)
 #   where result is an object of the class ImpalaBeeswaxResult.
+from __future__ import absolute_import, division, print_function
 import logging
 import time
 import shlex
@@ -282,7 +283,7 @@ class ImpalaBeeswaxClient(object):
             setattr(max_stats, attr, max(getattr(max_stats, attr), val))
 
       if len(node.exec_stats) > 0:
-        avg_time = agg_stats.latency_ns / len(node.exec_stats)
+        avg_time = agg_stats.latency_ns // len(node.exec_stats)
       else:
         avg_time = 0
 
diff --git a/tests/benchmark/plugins/clear_buffer_cache.py b/tests/benchmark/plugins/clear_buffer_cache.py
index 8fada8d70..6c35ff96a 100644
--- a/tests/benchmark/plugins/clear_buffer_cache.py
+++ b/tests/benchmark/plugins/clear_buffer_cache.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.util.cluster_controller import ClusterController
 from tests.benchmark.plugins import Plugin
 
diff --git a/tests/benchmark/plugins/vtune_plugin.py b/tests/benchmark/plugins/vtune_plugin.py
index 61c4fe044..ada5e1069 100644
--- a/tests/benchmark/plugins/vtune_plugin.py
+++ b/tests/benchmark/plugins/vtune_plugin.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from os import environ
 from tests.util.cluster_controller import ClusterController
 from tests.benchmark.plugins import Plugin
diff --git a/tests/benchmark/report_benchmark_results.py b/tests/benchmark/report_benchmark_results.py
index 7ce8ba688..680a871f9 100755
--- a/tests/benchmark/report_benchmark_results.py
+++ b/tests/benchmark/report_benchmark_results.py
@@ -28,8 +28,7 @@
 # be an int (2). The following line changes this behavior so that float will be returned
 # if necessary (2.5).
 
-from __future__ import division
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import difflib
 import json
 import logging
diff --git a/tests/catalog_service/test_catalog_service_client.py b/tests/catalog_service/test_catalog_service_client.py
index 939c4a255..8d89d9a19 100644
--- a/tests/catalog_service/test_catalog_service_client.py
+++ b/tests/catalog_service/test_catalog_service_client.py
@@ -17,6 +17,7 @@
 #
 # Tests to validate the Catalog Service client APIs.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import pytest
 
diff --git a/tests/catalog_service/test_large_num_partitions.py b/tests/catalog_service/test_large_num_partitions.py
index 548723ba9..e72d1720b 100644
--- a/tests/catalog_service/test_large_num_partitions.py
+++ b/tests/catalog_service/test_large_num_partitions.py
@@ -18,6 +18,7 @@
 # Tests to validate the Catalog Service works properly when partitions
 # need to be fetched in multiple batches.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_single_exec_option_dimension
 
diff --git a/tests/common/base_test_suite.py b/tests/common/base_test_suite.py
index e4bb0670b..bd9cb1882 100644
--- a/tests/common/base_test_suite.py
+++ b/tests/common/base_test_suite.py
@@ -16,6 +16,7 @@
 # under the License.
 
 # The base class that should be used for tests.
+from __future__ import absolute_import, division, print_function
 import logging
 
 from tests.common.test_vector import ImpalaTestMatrix
diff --git a/tests/common/custom_cluster_test_suite.py b/tests/common/custom_cluster_test_suite.py
index bc940cd0b..fb951ff58 100644
--- a/tests/common/custom_cluster_test_suite.py
+++ b/tests/common/custom_cluster_test_suite.py
@@ -18,6 +18,7 @@
 # Superclass for all tests that need a custom cluster.
 # TODO: Configure cluster size and other parameters.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import os.path
diff --git a/tests/common/environ.py b/tests/common/environ.py
index dfb9c2d98..80c2750ac 100644
--- a/tests/common/environ.py
+++ b/tests/common/environ.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import json
 import logging
 import os
diff --git a/tests/common/file_utils.py b/tests/common/file_utils.py
index fe10a5230..9850c3270 100644
--- a/tests/common/file_utils.py
+++ b/tests/common/file_utils.py
@@ -19,6 +19,7 @@
 # and other functions used for checking for strings in files and
 # directories.
 
+from __future__ import absolute_import, division, print_function
 import os
 import re
 import tempfile
diff --git a/tests/common/iceberg_test_suite.py b/tests/common/iceberg_test_suite.py
index f4ac06622..f7faba902 100644
--- a/tests/common/iceberg_test_suite.py
+++ b/tests/common/iceberg_test_suite.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import datetime
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/common/impala_cluster.py b/tests/common/impala_cluster.py
index 4a0ccb940..0b43189eb 100644
--- a/tests/common/impala_cluster.py
+++ b/tests/common/impala_cluster.py
@@ -17,7 +17,7 @@
 #
 # Basic object model of an Impala cluster (set of Impala processes).
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import json
 import logging
 import os
diff --git a/tests/common/impala_connection.py b/tests/common/impala_connection.py
index 7fbc7597b..21128db5d 100644
--- a/tests/common/impala_connection.py
+++ b/tests/common/impala_connection.py
@@ -19,6 +19,7 @@
 # in the future will support HS2 connections. Provides tracing around all
 # operations.
 
+from __future__ import absolute_import, division, print_function
 import abc
 import logging
 import re
diff --git a/tests/common/impala_service.py b/tests/common/impala_service.py
index 822e361f6..84e008b8a 100644
--- a/tests/common/impala_service.py
+++ b/tests/common/impala_service.py
@@ -19,6 +19,7 @@
 # programatically interact with the services and perform operations such as querying
 # the debug webpage, getting metric values, or creating client connections.
 
+from __future__ import absolute_import, division, print_function
 from collections import defaultdict
 import json
 import logging
diff --git a/tests/common/impala_test_suite.py b/tests/common/impala_test_suite.py
index 0245b9330..605d9894a 100644
--- a/tests/common/impala_test_suite.py
+++ b/tests/common/impala_test_suite.py
@@ -17,7 +17,7 @@
 #
 # The base class that should be used for almost all Impala tests
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import glob
 import grp
 import json
diff --git a/tests/common/kudu_test_suite.py b/tests/common/kudu_test_suite.py
index 1691addb8..5292b31eb 100644
--- a/tests/common/kudu_test_suite.py
+++ b/tests/common/kudu_test_suite.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import requests
diff --git a/tests/common/network.py b/tests/common/network.py
index ea9b739c2..55502b4eb 100644
--- a/tests/common/network.py
+++ b/tests/common/network.py
@@ -17,6 +17,7 @@
 
 # Tools for identifying network characteristics.
 
+from __future__ import absolute_import, division, print_function
 import socket
 
 
diff --git a/tests/common/parametrize.py b/tests/common/parametrize.py
index 0ba42057a..fc5b2b8c0 100644
--- a/tests/common/parametrize.py
+++ b/tests/common/parametrize.py
@@ -17,6 +17,7 @@
 
 # Fixture parametrizations should go here, not in conftest.py.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.patterns import is_valid_impala_identifier
diff --git a/tests/common/patterns.py b/tests/common/patterns.py
index b8d832588..1214e5e37 100644
--- a/tests/common/patterns.py
+++ b/tests/common/patterns.py
@@ -18,6 +18,7 @@
 # Common patterns that ought to be the same throughout the framework should be placed
 # here.
 
+from __future__ import absolute_import, division, print_function
 import re
 
 # http://www.cloudera.com/content/www/en-us/documentation/enterprise/latest/topics/impala_identifiers.html
diff --git a/tests/common/resource_pool_config.py b/tests/common/resource_pool_config.py
index 88f9b55e4..934107f7a 100644
--- a/tests/common/resource_pool_config.py
+++ b/tests/common/resource_pool_config.py
@@ -20,7 +20,7 @@
 # the tests it is used for. However, it is generic enough that it can be extended if
 # more functionality is required for adding tests.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 from time import sleep, time
 import xml.etree.ElementTree as ET
diff --git a/tests/common/skip.py b/tests/common/skip.py
index b908ea9e8..c79f80ca9 100644
--- a/tests/common/skip.py
+++ b/tests/common/skip.py
@@ -20,6 +20,7 @@
 # annotate the class or test routine with the marker.
 #
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from functools import partial
 
diff --git a/tests/common/test_dimensions.py b/tests/common/test_dimensions.py
index 869179402..48d147541 100644
--- a/tests/common/test_dimensions.py
+++ b/tests/common/test_dimensions.py
@@ -17,6 +17,7 @@
 
 # Common test dimensions and associated utility functions.
 
+from __future__ import absolute_import, division, print_function
 import copy
 import os
 from itertools import product
diff --git a/tests/common/test_result_verifier.py b/tests/common/test_result_verifier.py
index 1532712c4..59f637d9a 100644
--- a/tests/common/test_result_verifier.py
+++ b/tests/common/test_result_verifier.py
@@ -17,6 +17,7 @@
 
 # This modules contians utility functions used to help verify query test results.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import math
 import re
diff --git a/tests/common/test_vector.py b/tests/common/test_vector.py
index 8fcac5a79..d1b37bb59 100644
--- a/tests/common/test_vector.py
+++ b/tests/common/test_vector.py
@@ -56,6 +56,7 @@
 #
 # Additional examples of usage can be found within the test suites.
 
+from __future__ import absolute_import, division, print_function
 from itertools import product
 
 # A list of test dimension values.
diff --git a/tests/comparison/cli_options.py b/tests/comparison/cli_options.py
index 1d737cfaa..339faff49 100644
--- a/tests/comparison/cli_options.py
+++ b/tests/comparison/cli_options.py
@@ -17,6 +17,7 @@
 
 '''Helpers for parsing command line options'''
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import sys
diff --git a/tests/comparison/cluster.py b/tests/comparison/cluster.py
index 81fe672b1..c8bb416d8 100644
--- a/tests/comparison/cluster.py
+++ b/tests/comparison/cluster.py
@@ -16,11 +16,11 @@
 # under the License.
 
 """This module provides utilities for interacting with a cluster."""
-from __future__ import print_function
 
 # This should be moved into the test/util folder eventually. The problem is this
 # module depends on db_connection which use some query generator classes.
 
+from __future__ import absolute_import, division, print_function
 import hdfs
 import logging
 import os
@@ -46,7 +46,7 @@ from xml.etree.ElementTree import parse as parse_xml
 from zipfile import ZipFile
 
 
-from db_connection import HiveConnection, ImpalaConnection
+from tests.comparison.db_connection import HiveConnection, ImpalaConnection
 from tests.common.environ import HIVE_MAJOR_VERSION
 from tests.common.errors import Timeout
 from tests.util.shell_util import shell as local_shell
@@ -795,7 +795,7 @@ class Impalad(object):
     if not pid:
       raise Exception("Impalad at %s is not running" % self.label)
     mem_kb = self.shell("ps --no-header -o rss -p %s" % pid)
-    return int(mem_kb) / 1024
+    return int(mem_kb) // 1024
 
   def _read_web_page(self, relative_url, params={}, timeout_secs=DEFAULT_TIMEOUT):
     if "json" not in params:
@@ -874,7 +874,7 @@ class MiniClusterImpalad(Impalad):
       return int(pid)
 
   def find_process_mem_mb_limit(self):
-    return long(self.get_metric("mem-tracker.process.limit")["value"]) / 1024 ** 2
+    return long(self.get_metric("mem-tracker.process.limit")["value"]) // 1024 ** 2
 
   def find_core_dump_dir(self):
     raise NotImplementedError()
@@ -916,7 +916,7 @@ class CmImpalad(Impalad):
       return int(pid)
 
   def find_process_mem_mb_limit(self):
-    return self._get_cm_config("impalad_memory_limit", value_type=int) / 1024 ** 2
+    return self._get_cm_config("impalad_memory_limit", value_type=int) // 1024 ** 2
 
   def find_core_dump_dir(self):
     return self._get_cm_config("core_dump_dir")
diff --git a/tests/comparison/common.py b/tests/comparison/common.py
index 2b3217f7b..1025e7c79 100644
--- a/tests/comparison/common.py
+++ b/tests/comparison/common.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import json
 
 from collections import defaultdict
diff --git a/tests/comparison/compat.py b/tests/comparison/compat.py
index 80e8af752..aa63f8ab9 100644
--- a/tests/comparison/compat.py
+++ b/tests/comparison/compat.py
@@ -20,6 +20,7 @@
 # differences based on DB API2 libraries (like Impyla vs. psycopg2). Putting the
 # handling in a single place will make it easier to track what workarounds exist.
 
+from __future__ import absolute_import, division, print_function
 from tests.comparison import db_connection
 
 
diff --git a/tests/comparison/data_generator.py b/tests/comparison/data_generator.py
index a52ce6ffb..45dd611b7 100755
--- a/tests/comparison/data_generator.py
+++ b/tests/comparison/data_generator.py
@@ -26,6 +26,7 @@
 
 '''
 
+from __future__ import absolute_import, division, print_function
 import os
 from copy import deepcopy
 from logging import getLogger
@@ -217,8 +218,8 @@ class DbPopulator(object):
     reducer_count = 0
     mapper_input_data = list()
     for table_data_generator in table_data_generators:
-      reducer_count += (table_data_generator.row_count /
-          estimate_rows_per_reducer(table_data_generator, MB_PER_REDUCER)) + 1
+      reducer_count += (table_data_generator.row_count
+          // estimate_rows_per_reducer(table_data_generator, MB_PER_REDUCER)) + 1
       mapper_input_data.append(serialize(table_data_generator))
     hdfs.write(mapper_input_file, data='\n'.join(mapper_input_data))
 
diff --git a/tests/comparison/data_generator_mapred_common.py b/tests/comparison/data_generator_mapred_common.py
index df6c087b5..dfc811147 100644
--- a/tests/comparison/data_generator_mapred_common.py
+++ b/tests/comparison/data_generator_mapred_common.py
@@ -23,6 +23,7 @@
 
 '''
 
+from __future__ import absolute_import, division, print_function
 import base64
 import pickle
 import StringIO
@@ -107,7 +108,7 @@ def estimate_rows_per_reducer(table_data_generator, mb_per_reducer):
   bytes_per_row = estimate_bytes_per_row(table_data_generator, 1)
   if bytes_per_row >= bytes_per_reducer:
     return 1
-  rows_per_reducer = bytes_per_reducer / bytes_per_row
+  rows_per_reducer = bytes_per_reducer // bytes_per_row
   bytes_per_row = estimate_bytes_per_row(table_data_generator,
       max(int(rows_per_reducer * 0.001), 1))
-  return max(bytes_per_reducer / bytes_per_row, 1)
+  return max(bytes_per_reducer // bytes_per_row, 1)
diff --git a/tests/comparison/db_connection.py b/tests/comparison/db_connection.py
index a70a896c3..e641b15c9 100644
--- a/tests/comparison/db_connection.py
+++ b/tests/comparison/db_connection.py
@@ -21,7 +21,7 @@
    connection.
 
 '''
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import hashlib
 import impala.dbapi
 import re
diff --git a/tests/comparison/db_types.py b/tests/comparison/db_types.py
index 1684a35a1..5f78d4e84 100644
--- a/tests/comparison/db_types.py
+++ b/tests/comparison/db_types.py
@@ -15,12 +15,13 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import re
 import sys
 
 from collections import defaultdict
 
-from common import ValExpr, ValExprList
+from tests.comparison.common import ValExpr, ValExprList
 
 module_contents = dict()
 
diff --git a/tests/comparison/discrepancy_searcher.py b/tests/comparison/discrepancy_searcher.py
index 7a223db8f..ce56d7961 100755
--- a/tests/comparison/discrepancy_searcher.py
+++ b/tests/comparison/discrepancy_searcher.py
@@ -22,9 +22,9 @@
    results.
 
 '''
-from __future__ import print_function
-# TODO: IMPALA-4600: refactor this module
 
+# TODO: IMPALA-4600: refactor this module
+from __future__ import absolute_import, division, print_function
 from copy import deepcopy
 from decimal import Decimal
 from itertools import izip
@@ -455,8 +455,8 @@ class QueryExecutor(object):
       log_file.flush()
       cursor.execute(query_sql)
       col_count = len(cursor.description)
-      batch_size = max(10000 / col_count, 1)
-      row_limit = self.TOO_MUCH_DATA / col_count
+      batch_size = max(10000 // col_count, 1)
+      row_limit = self.TOO_MUCH_DATA // col_count
       data_set = list()
       current_thread().data_set = data_set
       current_thread().cursor_description = cursor.description
diff --git a/tests/comparison/funcs.py b/tests/comparison/funcs.py
index 98670791c..7a0f37272 100644
--- a/tests/comparison/funcs.py
+++ b/tests/comparison/funcs.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from copy import deepcopy
 from itertools import ifilter
 
diff --git a/tests/comparison/leopard/controller.py b/tests/comparison/leopard/controller.py
index 24e18ce96..16abd1ed8 100755
--- a/tests/comparison/leopard/controller.py
+++ b/tests/comparison/leopard/controller.py
@@ -17,9 +17,10 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from time import sleep, localtime, strftime
 from tests.comparison.query_profile import DefaultProfile, ImpalaNestedTypesProfile
-from schedule_item import ScheduleItem
+from tests.comparison.leopard.schedule_item import ScheduleItem
 from threading import Thread
 import os
 import pickle
diff --git a/tests/comparison/leopard/front_end.py b/tests/comparison/leopard/front_end.py
index ada5bd130..5f344ec3f 100755
--- a/tests/comparison/leopard/front_end.py
+++ b/tests/comparison/leopard/front_end.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import pickle
@@ -29,8 +30,8 @@ except ImportError as e:
   raise Exception(
       "Please run impala-pip install -r $IMPALA_HOME/infra/python/deps/extended-test-"
       "requirements.txt:\n{0}".format(str(e)))
-from schedule_item import ScheduleItem
-from controller import PATH_TO_REPORTS, PATH_TO_SCHEDULE
+from tests.comparison.leopard.schedule_item import ScheduleItem
+from tests.comparison.leopard.controller import PATH_TO_REPORTS, PATH_TO_SCHEDULE
 from threading import Thread
 from tests.comparison.query_profile import DefaultProfile
 from tests.comparison.db_types import (
diff --git a/tests/comparison/leopard/impala_docker_env.py b/tests/comparison/leopard/impala_docker_env.py
index 63fc33199..af3a09d48 100755
--- a/tests/comparison/leopard/impala_docker_env.py
+++ b/tests/comparison/leopard/impala_docker_env.py
@@ -17,7 +17,7 @@
 
 '''This module generates a docker environment for a job'''
 
-from __future__ import division
+from __future__ import absolute_import, division, print_function
 try:
   from fabric.api import sudo, run, settings
 except ImportError as e:
diff --git a/tests/comparison/leopard/job.py b/tests/comparison/leopard/job.py
index b526d4c1b..4f103dca3 100755
--- a/tests/comparison/leopard/job.py
+++ b/tests/comparison/leopard/job.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import division
+from __future__ import absolute_import, division, print_function
 from os.path import join as join_path
 from tests.comparison.query_generator import QueryGenerator
 from time import time
@@ -36,7 +36,7 @@ from tests.comparison.leopard.controller import (
 from tests.comparison.discrepancy_searcher import QueryResultComparator
 from tests.comparison.query_profile import DefaultProfile, ImpalaNestedTypesProfile
 from threading import Thread
-from impala_docker_env import ImpalaDockerEnv
+from tests.comparison.leopard.impala_docker_env import ImpalaDockerEnv
 
 import logging
 import os
diff --git a/tests/comparison/leopard/report.py b/tests/comparison/leopard/report.py
index db463c993..740128074 100644
--- a/tests/comparison/leopard/report.py
+++ b/tests/comparison/leopard/report.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pickle
 import re
 import os
diff --git a/tests/comparison/leopard/schedule_item.py b/tests/comparison/leopard/schedule_item.py
index b08bc42a6..595543261 100644
--- a/tests/comparison/leopard/schedule_item.py
+++ b/tests/comparison/leopard/schedule_item.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import random
 import string
 import pickle
diff --git a/tests/comparison/model_translator.py b/tests/comparison/model_translator.py
index 7064d5cbd..653a44b39 100644
--- a/tests/comparison/model_translator.py
+++ b/tests/comparison/model_translator.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from inspect import getmro
 from logging import getLogger
 from re import sub
diff --git a/tests/comparison/query.py b/tests/comparison/query.py
index f7bd59304..c3e80352f 100644
--- a/tests/comparison/query.py
+++ b/tests/comparison/query.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from abc import ABCMeta, abstractproperty
 from copy import deepcopy
 from logging import getLogger
diff --git a/tests/comparison/query_flattener.py b/tests/comparison/query_flattener.py
index 2a119131e..50de47159 100644
--- a/tests/comparison/query_flattener.py
+++ b/tests/comparison/query_flattener.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from copy import deepcopy
 from logging import getLogger
 
diff --git a/tests/comparison/query_generator.py b/tests/comparison/query_generator.py
index 361c1cb46..f4150fc86 100644
--- a/tests/comparison/query_generator.py
+++ b/tests/comparison/query_generator.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from collections import defaultdict
 from copy import deepcopy
 from itertools import ifilter
diff --git a/tests/comparison/query_profile.py b/tests/comparison/query_profile.py
index 553010485..f5003732a 100644
--- a/tests/comparison/query_profile.py
+++ b/tests/comparison/query_profile.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from logging import getLogger
 from random import choice, randint, random, shuffle
 
diff --git a/tests/comparison/random_val_generator.py b/tests/comparison/random_val_generator.py
index 340a18c32..45d14756e 100644
--- a/tests/comparison/random_val_generator.py
+++ b/tests/comparison/random_val_generator.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from datetime import datetime, timedelta
 from decimal import Decimal as PyDecimal
 from random import randint, random, uniform
diff --git a/tests/comparison/statement_generator.py b/tests/comparison/statement_generator.py
index 37842572b..3cfa713c4 100644
--- a/tests/comparison/statement_generator.py
+++ b/tests/comparison/statement_generator.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from copy import deepcopy
 
 from tests.comparison.common import Table
diff --git a/tests/comparison/tests/conftest.py b/tests/comparison/tests/conftest.py
index dd39fdebf..69e4f7257 100644
--- a/tests/comparison/tests/conftest.py
+++ b/tests/comparison/tests/conftest.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.comparison import cli_options
diff --git a/tests/comparison/tests/fake_query.py b/tests/comparison/tests/fake_query.py
index 3bf141011..e1cf46ed0 100644
--- a/tests/comparison/tests/fake_query.py
+++ b/tests/comparison/tests/fake_query.py
@@ -32,6 +32,7 @@
 # gain confidence, we can modify them to be more testable, and we can remove items from
 # here.
 
+from __future__ import absolute_import, division, print_function
 from tests.comparison.common import Column, Table
 from tests.comparison.funcs import AnalyticFirstValue
 from tests.comparison.query import Query, SelectClause, SelectItem
diff --git a/tests/comparison/tests/hive/test_hive_create_agg_or_analytic_tree.py b/tests/comparison/tests/hive/test_hive_create_agg_or_analytic_tree.py
index 45f0de1e6..26c0427e1 100644
--- a/tests/comparison/tests/hive/test_hive_create_agg_or_analytic_tree.py
+++ b/tests/comparison/tests/hive/test_hive_create_agg_or_analytic_tree.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.comparison.db_types import Int
diff --git a/tests/comparison/tests/hive/test_hive_create_relational_join_condition.py b/tests/comparison/tests/hive/test_hive_create_relational_join_condition.py
index 4d4eea13f..49b4b7b3a 100644
--- a/tests/comparison/tests/hive/test_hive_create_relational_join_condition.py
+++ b/tests/comparison/tests/hive/test_hive_create_relational_join_condition.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.comparison.common import TableExprList, Column, Table
 from tests.comparison.db_types import Int
 from tests.comparison.funcs import Equals
diff --git a/tests/comparison/tests/query_object_testdata.py b/tests/comparison/tests/query_object_testdata.py
index 154c8b104..ad3c8db30 100644
--- a/tests/comparison/tests/query_object_testdata.py
+++ b/tests/comparison/tests/query_object_testdata.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from collections import namedtuple
 
 from fake_query import (
diff --git a/tests/comparison/tests/test_cluster.py b/tests/comparison/tests/test_cluster.py
index 2e3bc5416..ece822b15 100644
--- a/tests/comparison/tests/test_cluster.py
+++ b/tests/comparison/tests/test_cluster.py
@@ -17,6 +17,7 @@
 
 # These are unit tests for cluster.py.
 
+from __future__ import absolute_import, division, print_function
 from time import time
 
 from tests.common.errors import Timeout
diff --git a/tests/comparison/tests/test_cursor.py b/tests/comparison/tests/test_cursor.py
index 38c296c1d..ee66e3fb3 100644
--- a/tests/comparison/tests/test_cursor.py
+++ b/tests/comparison/tests/test_cursor.py
@@ -16,6 +16,7 @@
 # under the License.
 
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.comparison.db_connection import ImpalaConnection, PostgresqlConnection
diff --git a/tests/comparison/tests/test_query_generator.py b/tests/comparison/tests/test_query_generator.py
index d64fc3e53..6f7e23658 100644
--- a/tests/comparison/tests/test_query_generator.py
+++ b/tests/comparison/tests/test_query_generator.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.comparison.db_types import Boolean
 from tests.comparison.funcs import And, Equals, Or
 from tests.comparison.query_generator import QueryGenerator
@@ -41,4 +42,4 @@ def test_func_tree_contains_funcs():
   and_func.parent = None
   assert qgen._func_tree_contains_funcs(equals_func, [And])
   assert qgen._func_tree_contains_funcs(equals_func, [Equals])
-  assert not qgen._func_tree_contains_funcs(equals_func, [Or])
\ No newline at end of file
+  assert not qgen._func_tree_contains_funcs(equals_func, [Or])
diff --git a/tests/comparison/tests/test_query_objects.py b/tests/comparison/tests/test_query_objects.py
index 029f524bc..177b98e79 100644
--- a/tests/comparison/tests/test_query_objects.py
+++ b/tests/comparison/tests/test_query_objects.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.comparison.model_translator import (
diff --git a/tests/comparison/tests/test_use_nested_with.py b/tests/comparison/tests/test_use_nested_with.py
index ad9b23690..b20667056 100644
--- a/tests/comparison/tests/test_use_nested_with.py
+++ b/tests/comparison/tests/test_use_nested_with.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.comparison.common import TableExprList, Column, Table
 from tests.comparison.db_types import Int
 from tests.comparison.query_generator import QueryGenerator
diff --git a/tests/comparison/util/verify-oracle-connection.py b/tests/comparison/util/verify-oracle-connection.py
index f4435b40f..cbc14a757 100755
--- a/tests/comparison/util/verify-oracle-connection.py
+++ b/tests/comparison/util/verify-oracle-connection.py
@@ -31,7 +31,7 @@
 
 # Importing the whole module instead of doing selective import seems to help find linker
 # errors.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import cx_Oracle
 
 # Host on which Oracle Database lies.
diff --git a/tests/conftest.py b/tests/conftest.py
index 0616e9110..ae8fc0a3c 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -17,7 +17,7 @@
 
 # py.test configuration module
 #
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from impala.dbapi import connect as impala_connect
 from kudu import connect as kudu_connect
 from random import choice, sample
@@ -32,7 +32,7 @@ import sys
 import tests.common
 from impala_py_lib.helpers import find_all_files, is_core_dump
 from tests.common.environ import build_flavor_timeout
-from common.test_result_verifier import QueryTestResult
+from tests.common.test_result_verifier import QueryTestResult
 from tests.common.patterns import is_valid_impala_identifier
 from tests.comparison.db_connection import ImpalaConnection
 from tests.util.filesystem_utils import FILESYSTEM, ISILON_WEBHDFS_PORT, WAREHOUSE
diff --git a/tests/custom_cluster/test_admission_controller.py b/tests/custom_cluster/test_admission_controller.py
index 445e0d208..b10f8e4ef 100644
--- a/tests/custom_cluster/test_admission_controller.py
+++ b/tests/custom_cluster/test_admission_controller.py
@@ -17,6 +17,7 @@
 
 # Tests admission control
 
+from __future__ import absolute_import, division, print_function
 import itertools
 import logging
 import os
@@ -75,7 +76,7 @@ STATESTORE_RPC_FREQUENCY_MS = 100
 # the time the next query is submitted. Otherwise the different impalads will see stale
 # state for some admission decisions.
 SUBMISSION_DELAY_MS = \
-    [0, STATESTORE_RPC_FREQUENCY_MS / 2, STATESTORE_RPC_FREQUENCY_MS * 3 / 2]
+    [0, STATESTORE_RPC_FREQUENCY_MS // 2, STATESTORE_RPC_FREQUENCY_MS * 3 // 2]
 
 # Whether we will submit queries to all available impalads (in a round-robin fashion)
 ROUND_ROBIN_SUBMISSION = [True, False]
@@ -2263,7 +2264,7 @@ class TestAdmissionControllerStress(TestAdmissionControllerBase):
     # of running requests is very high so that requests are only queued/rejected due to
     # the mem limit.
     num_impalads = len(self.cluster.impalads)
-    query_mem_limit = (proc_limit / MAX_NUM_CONCURRENT_QUERIES / num_impalads) - 1
+    query_mem_limit = (proc_limit // MAX_NUM_CONCURRENT_QUERIES // num_impalads) - 1
     self.run_admission_test(vector,
         {'request_pool': self.pool_name, 'mem_limit': query_mem_limit})
 
diff --git a/tests/custom_cluster/test_alloc_fail.py b/tests/custom_cluster/test_alloc_fail.py
index 888dd9a77..507ea8af7 100644
--- a/tests/custom_cluster/test_alloc_fail.py
+++ b/tests/custom_cluster/test_alloc_fail.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_always_false_filter.py b/tests/custom_cluster/test_always_false_filter.py
index 1bc8a2dfc..ead7a4ee1 100644
--- a/tests/custom_cluster/test_always_false_filter.py
+++ b/tests/custom_cluster/test_always_false_filter.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 
diff --git a/tests/custom_cluster/test_auto_scaling.py b/tests/custom_cluster/test_auto_scaling.py
index eb7832660..86dda7687 100644
--- a/tests/custom_cluster/test_auto_scaling.py
+++ b/tests/custom_cluster/test_auto_scaling.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import pytest
 from time import sleep, time
diff --git a/tests/custom_cluster/test_automatic_invalidation.py b/tests/custom_cluster/test_automatic_invalidation.py
index eda202177..321add208 100644
--- a/tests/custom_cluster/test_automatic_invalidation.py
+++ b/tests/custom_cluster/test_automatic_invalidation.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import time
diff --git a/tests/custom_cluster/test_blacklist.py b/tests/custom_cluster/test_blacklist.py
index 20b18b508..d98cd8221 100644
--- a/tests/custom_cluster/test_blacklist.py
+++ b/tests/custom_cluster/test_blacklist.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
 import pytest
diff --git a/tests/custom_cluster/test_blacklisted_dbs_and_tables.py b/tests/custom_cluster/test_blacklisted_dbs_and_tables.py
index bdcb33de5..8ce0e5969 100644
--- a/tests/custom_cluster/test_blacklisted_dbs_and_tables.py
+++ b/tests/custom_cluster/test_blacklisted_dbs_and_tables.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
diff --git a/tests/custom_cluster/test_breakpad.py b/tests/custom_cluster/test_breakpad.py
index 1d17f8570..c44d3259b 100644
--- a/tests/custom_cluster/test_breakpad.py
+++ b/tests/custom_cluster/test_breakpad.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import glob
 import os
 import psutil
diff --git a/tests/custom_cluster/test_catalog_hms_failures.py b/tests/custom_cluster/test_catalog_hms_failures.py
index 78c52f42b..09e26a433 100644
--- a/tests/custom_cluster/test_catalog_hms_failures.py
+++ b/tests/custom_cluster/test_catalog_hms_failures.py
@@ -14,7 +14,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import pytest
 import os
 import time
diff --git a/tests/custom_cluster/test_catalog_wait.py b/tests/custom_cluster/test_catalog_wait.py
index 11b90d15a..eb1cc542e 100644
--- a/tests/custom_cluster/test_catalog_wait.py
+++ b/tests/custom_cluster/test_catalog_wait.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from time import sleep
diff --git a/tests/custom_cluster/test_client_ssl.py b/tests/custom_cluster/test_client_ssl.py
index b02a688aa..99109cd00 100644
--- a/tests/custom_cluster/test_client_ssl.py
+++ b/tests/custom_cluster/test_client_ssl.py
@@ -16,7 +16,7 @@
 # under the License.
 #
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import json
 import logging
 import os
diff --git a/tests/custom_cluster/test_codegen_cache.py b/tests/custom_cluster/test_codegen_cache.py
index bdd69c614..72b8e28d6 100644
--- a/tests/custom_cluster/test_codegen_cache.py
+++ b/tests/custom_cluster/test_codegen_cache.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from copy import copy
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_compact_catalog_updates.py b/tests/custom_cluster/test_compact_catalog_updates.py
index 4440e3bb9..9ca1dc92a 100644
--- a/tests/custom_cluster/test_compact_catalog_updates.py
+++ b/tests/custom_cluster/test_compact_catalog_updates.py
@@ -17,6 +17,7 @@
 #
 # Test Catalog behavior when --compact_catalog_topic is false.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_concurrent_ddls.py b/tests/custom_cluster/test_concurrent_ddls.py
index 7ec6153ce..8d61e2735 100644
--- a/tests/custom_cluster/test_concurrent_ddls.py
+++ b/tests/custom_cluster/test_concurrent_ddls.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import threading
 
diff --git a/tests/custom_cluster/test_concurrent_kudu_create.py b/tests/custom_cluster/test_concurrent_kudu_create.py
index d5d285702..ad86ee925 100644
--- a/tests/custom_cluster/test_concurrent_kudu_create.py
+++ b/tests/custom_cluster/test_concurrent_kudu_create.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import threading
 import time
diff --git a/tests/custom_cluster/test_coordinators.py b/tests/custom_cluster/test_coordinators.py
index 635892da5..436e26572 100644
--- a/tests/custom_cluster/test_coordinators.py
+++ b/tests/custom_cluster/test_coordinators.py
@@ -17,6 +17,7 @@
 #
 # The base class that should be used for almost all Impala tests
 
+from __future__ import absolute_import, division, print_function
 import logging
 import pytest
 import os
diff --git a/tests/custom_cluster/test_custom_hive_configs.py b/tests/custom_cluster/test_custom_hive_configs.py
index 933a114af..4fcb88e72 100644
--- a/tests/custom_cluster/test_custom_hive_configs.py
+++ b/tests/custom_cluster/test_custom_hive_configs.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from os import getenv
 
diff --git a/tests/custom_cluster/test_custom_statestore.py b/tests/custom_cluster/test_custom_statestore.py
index 742ba19e0..185e3f049 100644
--- a/tests/custom_cluster/test_custom_statestore.py
+++ b/tests/custom_cluster/test_custom_statestore.py
@@ -18,6 +18,7 @@
 
 # Tests statestore with non-default startup options
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import pytest
diff --git a/tests/custom_cluster/test_data_cache.py b/tests/custom_cluster/test_data_cache.py
index c5c2555d8..988c08dfc 100644
--- a/tests/custom_cluster/test_data_cache.py
+++ b/tests/custom_cluster/test_data_cache.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_delegation.py b/tests/custom_cluster/test_delegation.py
index f63ffc885..72660b394 100644
--- a/tests/custom_cluster/test_delegation.py
+++ b/tests/custom_cluster/test_delegation.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import absolute_import, division, print_function
 import getpass
 import pytest
 from tests.hs2.hs2_test_suite import HS2TestSuite, needs_session
diff --git a/tests/custom_cluster/test_disable_catalog_data_ops.py b/tests/custom_cluster/test_disable_catalog_data_ops.py
index 062de847b..181afbe5a 100644
--- a/tests/custom_cluster/test_disable_catalog_data_ops.py
+++ b/tests/custom_cluster/test_disable_catalog_data_ops.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_disable_features.py b/tests/custom_cluster/test_disable_features.py
index 632322301..83d0d4abb 100644
--- a/tests/custom_cluster/test_disable_features.py
+++ b/tests/custom_cluster/test_disable_features.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_disk_spill_configurations.py b/tests/custom_cluster/test_disk_spill_configurations.py
index efddd231b..f73fd15fc 100644
--- a/tests/custom_cluster/test_disk_spill_configurations.py
+++ b/tests/custom_cluster/test_disk_spill_configurations.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_events_custom_configs.py b/tests/custom_cluster/test_events_custom_configs.py
index 95fb83e6c..703f11b61 100644
--- a/tests/custom_cluster/test_events_custom_configs.py
+++ b/tests/custom_cluster/test_events_custom_configs.py
@@ -14,7 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import logging
 import pytest
 
diff --git a/tests/custom_cluster/test_exchange_deferred_batches.py b/tests/custom_cluster/test_exchange_deferred_batches.py
index 31cd78e56..52a70a074 100644
--- a/tests/custom_cluster/test_exchange_deferred_batches.py
+++ b/tests/custom_cluster/test_exchange_deferred_batches.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.skip import SkipIfBuildType
diff --git a/tests/custom_cluster/test_exchange_delays.py b/tests/custom_cluster/test_exchange_delays.py
index b6aa044c5..44d79ea2a 100644
--- a/tests/custom_cluster/test_exchange_delays.py
+++ b/tests/custom_cluster/test_exchange_delays.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.environ import build_flavor_timeout
diff --git a/tests/custom_cluster/test_exchange_eos.py b/tests/custom_cluster/test_exchange_eos.py
index b26739fdd..c6e2999dd 100644
--- a/tests/custom_cluster/test_exchange_eos.py
+++ b/tests/custom_cluster/test_exchange_eos.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_executor_groups.py b/tests/custom_cluster/test_executor_groups.py
index 3044b6232..f0d3c3293 100644
--- a/tests/custom_cluster/test_executor_groups.py
+++ b/tests/custom_cluster/test_executor_groups.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.util.concurrent_workload import ConcurrentWorkload
 
diff --git a/tests/custom_cluster/test_frontend_connection_limit.py b/tests/custom_cluster/test_frontend_connection_limit.py
index 54d1a7f68..911b808c9 100644
--- a/tests/custom_cluster/test_frontend_connection_limit.py
+++ b/tests/custom_cluster/test_frontend_connection_limit.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from threading import Thread
diff --git a/tests/custom_cluster/test_geospatial_library.py b/tests/custom_cluster/test_geospatial_library.py
index 9d5ff6001..5ce0d9730 100644
--- a/tests/custom_cluster/test_geospatial_library.py
+++ b/tests/custom_cluster/test_geospatial_library.py
@@ -14,6 +14,8 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_hbase_hms_column_order.py b/tests/custom_cluster/test_hbase_hms_column_order.py
index 869a75c4b..447dd071d 100644
--- a/tests/custom_cluster/test_hbase_hms_column_order.py
+++ b/tests/custom_cluster/test_hbase_hms_column_order.py
@@ -17,6 +17,7 @@
 #
 # Tests for IMPALA-1658
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
 
diff --git a/tests/custom_cluster/test_hdfs_fd_caching.py b/tests/custom_cluster/test_hdfs_fd_caching.py
index fd9b04f82..c2c66be49 100644
--- a/tests/custom_cluster/test_hdfs_fd_caching.py
+++ b/tests/custom_cluster/test_hdfs_fd_caching.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_hdfs_timeout.py b/tests/custom_cluster/test_hdfs_timeout.py
index fb2d3e38e..629b63de2 100644
--- a/tests/custom_cluster/test_hdfs_timeout.py
+++ b/tests/custom_cluster/test_hdfs_timeout.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 import time
diff --git a/tests/custom_cluster/test_hedged_reads.py b/tests/custom_cluster/test_hedged_reads.py
index e1d36e73b..b82181743 100644
--- a/tests/custom_cluster/test_hedged_reads.py
+++ b/tests/custom_cluster/test_hedged_reads.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.skip import SkipIf
diff --git a/tests/custom_cluster/test_hive_parquet_codec_interop.py b/tests/custom_cluster/test_hive_parquet_codec_interop.py
index c9601d72d..a020a2be7 100644
--- a/tests/custom_cluster/test_hive_parquet_codec_interop.py
+++ b/tests/custom_cluster/test_hive_parquet_codec_interop.py
@@ -17,6 +17,7 @@
 #
 # Tests for Hive-IMPALA parquet compression codec interoperability
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_hive_parquet_timestamp_conversion.py b/tests/custom_cluster/test_hive_parquet_timestamp_conversion.py
index c93a0d0f4..3fe286d5f 100644
--- a/tests/custom_cluster/test_hive_parquet_timestamp_conversion.py
+++ b/tests/custom_cluster/test_hive_parquet_timestamp_conversion.py
@@ -17,6 +17,7 @@
 #
 # Tests for IMPALA-1658
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 from subprocess import check_call
diff --git a/tests/custom_cluster/test_hive_text_codec_interop.py b/tests/custom_cluster/test_hive_text_codec_interop.py
index a23d88102..e5223be3a 100644
--- a/tests/custom_cluster/test_hive_text_codec_interop.py
+++ b/tests/custom_cluster/test_hive_text_codec_interop.py
@@ -17,6 +17,7 @@
 #
 # Tests for Hive-IMPALA text compression codec interoperability
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_hs2.py b/tests/custom_cluster/test_hs2.py
index 62185118f..8a38bef38 100644
--- a/tests/custom_cluster/test_hs2.py
+++ b/tests/custom_cluster/test_hs2.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
 import pytest
diff --git a/tests/custom_cluster/test_hs2_fault_injection.py b/tests/custom_cluster/test_hs2_fault_injection.py
index 27e536fdd..cb9866044 100644
--- a/tests/custom_cluster/test_hs2_fault_injection.py
+++ b/tests/custom_cluster/test_hs2_fault_injection.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import requests
 
diff --git a/tests/custom_cluster/test_incremental_metadata_updates.py b/tests/custom_cluster/test_incremental_metadata_updates.py
index 0029cf3a3..82334f080 100755
--- a/tests/custom_cluster/test_incremental_metadata_updates.py
+++ b/tests/custom_cluster/test_incremental_metadata_updates.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
diff --git a/tests/custom_cluster/test_insert_behaviour.py b/tests/custom_cluster/test_insert_behaviour.py
index 89d06f5cc..44076a2a6 100644
--- a/tests/custom_cluster/test_insert_behaviour.py
+++ b/tests/custom_cluster/test_insert_behaviour.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_jvm_mem_tracking.py b/tests/custom_cluster/test_jvm_mem_tracking.py
index e4b9a07e0..3999a0cb2 100644
--- a/tests/custom_cluster/test_jvm_mem_tracking.py
+++ b/tests/custom_cluster/test_jvm_mem_tracking.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import json
 import pytest
diff --git a/tests/custom_cluster/test_krpc_mem_usage.py b/tests/custom_cluster/test_krpc_mem_usage.py
index 0d76ca866..ffcf44957 100644
--- a/tests/custom_cluster/test_krpc_mem_usage.py
+++ b/tests/custom_cluster/test_krpc_mem_usage.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import time
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_krpc_metrics.py b/tests/custom_cluster/test_krpc_metrics.py
index 0acc72eb2..7d5a4e531 100644
--- a/tests/custom_cluster/test_krpc_metrics.py
+++ b/tests/custom_cluster/test_krpc_metrics.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import time
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_krpc_options.py b/tests/custom_cluster/test_krpc_options.py
index b949621b7..3958eb512 100644
--- a/tests/custom_cluster/test_krpc_options.py
+++ b/tests/custom_cluster/test_krpc_options.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import socket
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_krpc_socket.py b/tests/custom_cluster/test_krpc_socket.py
index 1845102cf..009547438 100644
--- a/tests/custom_cluster/test_krpc_socket.py
+++ b/tests/custom_cluster/test_krpc_socket.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import socket
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_kudu.py b/tests/custom_cluster/test_kudu.py
index 74155da95..1e3d39a8b 100644
--- a/tests/custom_cluster/test_kudu.py
+++ b/tests/custom_cluster/test_kudu.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import pytest
diff --git a/tests/custom_cluster/test_kudu_not_available.py b/tests/custom_cluster/test_kudu_not_available.py
index 090854d92..23b09c026 100644
--- a/tests/custom_cluster/test_kudu_not_available.py
+++ b/tests/custom_cluster/test_kudu_not_available.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from impala.dbapi import connect
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_kudu_table_create_without_hms.py b/tests/custom_cluster/test_kudu_table_create_without_hms.py
index cfe957ef4..fecbd1e4c 100644
--- a/tests/custom_cluster/test_kudu_table_create_without_hms.py
+++ b/tests/custom_cluster/test_kudu_table_create_without_hms.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import os
 
diff --git a/tests/custom_cluster/test_lineage.py b/tests/custom_cluster/test_lineage.py
index 71668b0db..6551d545e 100644
--- a/tests/custom_cluster/test_lineage.py
+++ b/tests/custom_cluster/test_lineage.py
@@ -17,6 +17,7 @@
 #
 # Tests for column lineage.
 
+from __future__ import absolute_import, division, print_function
 import json
 import logging
 import os
diff --git a/tests/custom_cluster/test_local_catalog.py b/tests/custom_cluster/test_local_catalog.py
index 5f7a25332..baeb453bc 100644
--- a/tests/custom_cluster/test_local_catalog.py
+++ b/tests/custom_cluster/test_local_catalog.py
@@ -17,7 +17,7 @@
 
 # Test behaviors specific to --use_local_catalog being enabled.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import pytest
 import Queue
 import random
diff --git a/tests/custom_cluster/test_local_tz_conversion.py b/tests/custom_cluster/test_local_tz_conversion.py
index ca1a720d7..35b4e809e 100644
--- a/tests/custom_cluster/test_local_tz_conversion.py
+++ b/tests/custom_cluster/test_local_tz_conversion.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.test_vector import ImpalaTestDimension
diff --git a/tests/custom_cluster/test_logging.py b/tests/custom_cluster/test_logging.py
index 34cf2578e..13f6595c2 100644
--- a/tests/custom_cluster/test_logging.py
+++ b/tests/custom_cluster/test_logging.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_mem_reservations.py b/tests/custom_cluster/test_mem_reservations.py
index 6365ec126..f6e66ae81 100644
--- a/tests/custom_cluster/test_mem_reservations.py
+++ b/tests/custom_cluster/test_mem_reservations.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import threading
 
diff --git a/tests/custom_cluster/test_metadata_no_events_processing.py b/tests/custom_cluster/test_metadata_no_events_processing.py
index 9d380cf4b..ee6af0821 100644
--- a/tests/custom_cluster/test_metadata_no_events_processing.py
+++ b/tests/custom_cluster/test_metadata_no_events_processing.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.skip import SkipIfFS
 
diff --git a/tests/custom_cluster/test_metadata_replicas.py b/tests/custom_cluster/test_metadata_replicas.py
index a458b23aa..4afa4249f 100644
--- a/tests/custom_cluster/test_metadata_replicas.py
+++ b/tests/custom_cluster/test_metadata_replicas.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.skip import SkipIfFS
diff --git a/tests/custom_cluster/test_metastore_events_cleanup.py b/tests/custom_cluster/test_metastore_events_cleanup.py
index 79662680e..a2f578422 100644
--- a/tests/custom_cluster/test_metastore_events_cleanup.py
+++ b/tests/custom_cluster/test_metastore_events_cleanup.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import os
 
diff --git a/tests/custom_cluster/test_metastore_service.py b/tests/custom_cluster/test_metastore_service.py
index 62a621a73..c74ab63fd 100644
--- a/tests/custom_cluster/test_metastore_service.py
+++ b/tests/custom_cluster/test_metastore_service.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from hive_metastore.ttypes import Database
 from hive_metastore.ttypes import FieldSchema
diff --git a/tests/custom_cluster/test_mt_dop.py b/tests/custom_cluster/test_mt_dop.py
index e832a26f2..38878c086 100644
--- a/tests/custom_cluster/test_mt_dop.py
+++ b/tests/custom_cluster/test_mt_dop.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 from copy import deepcopy
diff --git a/tests/custom_cluster/test_observability.py b/tests/custom_cluster/test_observability.py
index 4a4a5a976..c5fd9e2b2 100644
--- a/tests/custom_cluster/test_observability.py
+++ b/tests/custom_cluster/test_observability.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 
diff --git a/tests/custom_cluster/test_parquet_max_page_header.py b/tests/custom_cluster/test_parquet_max_page_header.py
index 48cfa0fce..73496487b 100644
--- a/tests/custom_cluster/test_parquet_max_page_header.py
+++ b/tests/custom_cluster/test_parquet_max_page_header.py
@@ -17,6 +17,7 @@
 #
 # Tests for IMPALA-2273
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import random
diff --git a/tests/custom_cluster/test_partition.py b/tests/custom_cluster/test_partition.py
index aa996a5ce..89d80f2c1 100644
--- a/tests/custom_cluster/test_partition.py
+++ b/tests/custom_cluster/test_partition.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import pytest
 import shutil
diff --git a/tests/custom_cluster/test_pause_monitor.py b/tests/custom_cluster/test_pause_monitor.py
index bf471901f..165b11dc5 100644
--- a/tests/custom_cluster/test_pause_monitor.py
+++ b/tests/custom_cluster/test_pause_monitor.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import signal
 import time
 
diff --git a/tests/custom_cluster/test_permanent_udfs.py b/tests/custom_cluster/test_permanent_udfs.py
index 31f34094a..c84ac6667 100644
--- a/tests/custom_cluster/test_permanent_udfs.py
+++ b/tests/custom_cluster/test_permanent_udfs.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import glob
 import os
 import pytest
diff --git a/tests/custom_cluster/test_preload_table_types.py b/tests/custom_cluster/test_preload_table_types.py
index ae5f16f2d..f86427eac 100644
--- a/tests/custom_cluster/test_preload_table_types.py
+++ b/tests/custom_cluster/test_preload_table_types.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
 
diff --git a/tests/custom_cluster/test_process_failures.py b/tests/custom_cluster/test_process_failures.py
index 0bf5b2ab3..21464ed3f 100644
--- a/tests/custom_cluster/test_process_failures.py
+++ b/tests/custom_cluster/test_process_failures.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from beeswaxd.BeeswaxService import QueryState
diff --git a/tests/custom_cluster/test_query_concurrency.py b/tests/custom_cluster/test_query_concurrency.py
index 703ffd646..49a9ca246 100644
--- a/tests/custom_cluster/test_query_concurrency.py
+++ b/tests/custom_cluster/test_query_concurrency.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import time
 from threading import Thread
diff --git a/tests/custom_cluster/test_query_event_hooks.py b/tests/custom_cluster/test_query_event_hooks.py
index 36fe36047..e709f83d3 100644
--- a/tests/custom_cluster/test_query_event_hooks.py
+++ b/tests/custom_cluster/test_query_event_hooks.py
@@ -17,6 +17,7 @@
 #
 # Client tests for Query Event Hooks
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import tempfile
diff --git a/tests/custom_cluster/test_query_expiration.py b/tests/custom_cluster/test_query_expiration.py
index d6b0011fd..d7dd5a0c3 100644
--- a/tests/custom_cluster/test_query_expiration.py
+++ b/tests/custom_cluster/test_query_expiration.py
@@ -17,6 +17,7 @@
 #
 # Tests for query expiration.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 import threading
diff --git a/tests/custom_cluster/test_query_retries.py b/tests/custom_cluster/test_query_retries.py
index d7e8e4fb7..5d321ceed 100644
--- a/tests/custom_cluster/test_query_retries.py
+++ b/tests/custom_cluster/test_query_retries.py
@@ -21,7 +21,7 @@
 # TODO: Re-factor tests into multiple classes.
 # TODO: Add a test that cancels queries while a retry is running
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 import shutil
diff --git a/tests/custom_cluster/test_re2_max_mem.py b/tests/custom_cluster/test_re2_max_mem.py
index 9348bcb1a..ded88bd2d 100755
--- a/tests/custom_cluster/test_re2_max_mem.py
+++ b/tests/custom_cluster/test_re2_max_mem.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_redaction.py b/tests/custom_cluster/test_redaction.py
index fd95a1657..607502723 100644
--- a/tests/custom_cluster/test_redaction.py
+++ b/tests/custom_cluster/test_redaction.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import getpass
 import logging
 import os
diff --git a/tests/custom_cluster/test_reserved_words_version.py b/tests/custom_cluster/test_reserved_words_version.py
index 0c3b80075..b317f93cb 100644
--- a/tests/custom_cluster/test_reserved_words_version.py
+++ b/tests/custom_cluster/test_reserved_words_version.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_restart_services.py b/tests/custom_cluster/test_restart_services.py
index 9740974bb..7d9c003d1 100644
--- a/tests/custom_cluster/test_restart_services.py
+++ b/tests/custom_cluster/test_restart_services.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import pytest
@@ -612,7 +612,7 @@ class TestGracefulShutdown(CustomClusterTestSuite, HS2TestSuite):
         self.client, SHUTDOWN_EXEC3.format(HIGH_DEADLINE))
     grace, deadline, _, _ = parse_shutdown_result(result)
     assert grace == "{0}s000ms".format(self.EXEC_SHUTDOWN_GRACE_PERIOD_S)
-    assert deadline == "{0}m{1}s".format(HIGH_DEADLINE / 60, HIGH_DEADLINE % 60)
+    assert deadline == "{0}m{1}s".format(HIGH_DEADLINE // 60, HIGH_DEADLINE % 60)
 
     result = self.execute_query_expect_success(
         self.client, SHUTDOWN_EXEC3.format(VERY_HIGH_DEADLINE))
@@ -660,7 +660,7 @@ class TestGracefulShutdown(CustomClusterTestSuite, HS2TestSuite):
     result = self.execute_query_expect_success(self.client, SHUTDOWN)
     grace, deadline, registered, _ = parse_shutdown_result(result)
     assert grace == "{0}s000ms".format(self.COORD_SHUTDOWN_GRACE_PERIOD_S)
-    assert deadline == "{0}m".format(self.COORD_SHUTDOWN_DEADLINE_S / 60), "4"
+    assert deadline == "{0}m".format(self.COORD_SHUTDOWN_DEADLINE_S // 60), "4"
     assert registered == "3"
 
     # Expect that the beeswax shutdown error occurs when calling fn()
diff --git a/tests/custom_cluster/test_result_spooling.py b/tests/custom_cluster/test_result_spooling.py
index 03f0a1709..795c38c5a 100644
--- a/tests/custom_cluster/test_result_spooling.py
+++ b/tests/custom_cluster/test_result_spooling.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 
diff --git a/tests/custom_cluster/test_rpc_exception.py b/tests/custom_cluster/test_rpc_exception.py
index 4921ca926..dcbdde595 100644
--- a/tests/custom_cluster/test_rpc_exception.py
+++ b/tests/custom_cluster/test_rpc_exception.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import time
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/custom_cluster/test_rpc_timeout.py b/tests/custom_cluster/test_rpc_timeout.py
index 8b266629f..410e22e9e 100644
--- a/tests/custom_cluster/test_rpc_timeout.py
+++ b/tests/custom_cluster/test_rpc_timeout.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_runtime_profile.py b/tests/custom_cluster/test_runtime_profile.py
index cb5e2963c..5b7841ea7 100644
--- a/tests/custom_cluster/test_runtime_profile.py
+++ b/tests/custom_cluster/test_runtime_profile.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.skip import SkipIfFS
diff --git a/tests/custom_cluster/test_s3a_access.py b/tests/custom_cluster/test_s3a_access.py
index 62160d686..6bc876df1 100644
--- a/tests/custom_cluster/test_s3a_access.py
+++ b/tests/custom_cluster/test_s3a_access.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import stat
diff --git a/tests/custom_cluster/test_saml2_sso.py b/tests/custom_cluster/test_saml2_sso.py
index 476e0613f..2cf4babce 100644
--- a/tests/custom_cluster/test_saml2_sso.py
+++ b/tests/custom_cluster/test_saml2_sso.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+from __future__ import absolute_import, division, print_function
 import base64
 import datetime
 import os
diff --git a/tests/custom_cluster/test_scheduler_locality.py b/tests/custom_cluster/test_scheduler_locality.py
index adfbcd581..9a156cc3e 100644
--- a/tests/custom_cluster/test_scheduler_locality.py
+++ b/tests/custom_cluster/test_scheduler_locality.py
@@ -17,6 +17,7 @@
 #
 # Tests for local and remote disk scheduling.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.network import get_external_ip
 from tests.common.skip import SkipIfNotHdfsMinicluster
diff --git a/tests/custom_cluster/test_scratch_disk.py b/tests/custom_cluster/test_scratch_disk.py
index 4ed4ebba5..dc3797b8e 100644
--- a/tests/custom_cluster/test_scratch_disk.py
+++ b/tests/custom_cluster/test_scratch_disk.py
@@ -17,7 +17,7 @@
 #
 # Tests for query expiration.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import re
diff --git a/tests/custom_cluster/test_seq_file_filtering.py b/tests/custom_cluster/test_seq_file_filtering.py
index 126c7c452..fa731b7c5 100644
--- a/tests/custom_cluster/test_seq_file_filtering.py
+++ b/tests/custom_cluster/test_seq_file_filtering.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_services_rpc_errors.py b/tests/custom_cluster/test_services_rpc_errors.py
index 0789d262e..3efcb393b 100644
--- a/tests/custom_cluster/test_services_rpc_errors.py
+++ b/tests/custom_cluster/test_services_rpc_errors.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
diff --git a/tests/custom_cluster/test_session_expiration.py b/tests/custom_cluster/test_session_expiration.py
index fb9771c83..fccf35f34 100644
--- a/tests/custom_cluster/test_session_expiration.py
+++ b/tests/custom_cluster/test_session_expiration.py
@@ -17,6 +17,7 @@
 #
 # Tests for query expiration.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import socket
 from time import sleep
diff --git a/tests/custom_cluster/test_set_and_unset.py b/tests/custom_cluster/test_set_and_unset.py
index 3d3c6ab5b..3425a5895 100644
--- a/tests/custom_cluster/test_set_and_unset.py
+++ b/tests/custom_cluster/test_set_and_unset.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_shared_tzdb.py b/tests/custom_cluster/test_shared_tzdb.py
index e0fd2f889..85b6d31c1 100644
--- a/tests/custom_cluster/test_shared_tzdb.py
+++ b/tests/custom_cluster/test_shared_tzdb.py
@@ -17,6 +17,7 @@
 #
 # Tests for IMPALA-3307
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
diff --git a/tests/custom_cluster/test_shell_commandline.py b/tests/custom_cluster/test_shell_commandline.py
index c7379a93d..9bdf4fba2 100644
--- a/tests/custom_cluster/test_shell_commandline.py
+++ b/tests/custom_cluster/test_shell_commandline.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import re
diff --git a/tests/custom_cluster/test_shell_interactive.py b/tests/custom_cluster/test_shell_interactive.py
index f9ed9c8bb..b14bcd65a 100644
--- a/tests/custom_cluster/test_shell_interactive.py
+++ b/tests/custom_cluster/test_shell_interactive.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from multiprocessing.pool import ThreadPool
diff --git a/tests/custom_cluster/test_shell_interactive_reconnect.py b/tests/custom_cluster/test_shell_interactive_reconnect.py
index dde6deb19..20fcdc581 100644
--- a/tests/custom_cluster/test_shell_interactive_reconnect.py
+++ b/tests/custom_cluster/test_shell_interactive_reconnect.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import tempfile
 import socket
diff --git a/tests/custom_cluster/test_startup_filesystem_checks.py b/tests/custom_cluster/test_startup_filesystem_checks.py
index 4d2da9dfe..7b2e81a76 100644
--- a/tests/custom_cluster/test_startup_filesystem_checks.py
+++ b/tests/custom_cluster/test_startup_filesystem_checks.py
@@ -17,6 +17,7 @@
 #
 # Tests for the behavior of startup_filesystem_check_directories
 
+from __future__ import absolute_import, division, print_function
 import logging
 import pytest
 import os
diff --git a/tests/custom_cluster/test_stats_extrapolation.py b/tests/custom_cluster/test_stats_extrapolation.py
index 9b219210e..f16b566f1 100644
--- a/tests/custom_cluster/test_stats_extrapolation.py
+++ b/tests/custom_cluster/test_stats_extrapolation.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 from tests.common.test_dimensions import (
diff --git a/tests/custom_cluster/test_thrift_debug_string_exception.py b/tests/custom_cluster/test_thrift_debug_string_exception.py
index af03abd49..eec216679 100644
--- a/tests/custom_cluster/test_thrift_debug_string_exception.py
+++ b/tests/custom_cluster/test_thrift_debug_string_exception.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.custom_cluster_test_suite import CustomClusterTestSuite
 
 
diff --git a/tests/custom_cluster/test_thrift_socket.py b/tests/custom_cluster/test_thrift_socket.py
index c276384fd..4451ccf8d 100644
--- a/tests/custom_cluster/test_thrift_socket.py
+++ b/tests/custom_cluster/test_thrift_socket.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import ssl
diff --git a/tests/custom_cluster/test_topic_update_frequency.py b/tests/custom_cluster/test_topic_update_frequency.py
index 13402714e..f5e6c92f5 100644
--- a/tests/custom_cluster/test_topic_update_frequency.py
+++ b/tests/custom_cluster/test_topic_update_frequency.py
@@ -9,7 +9,7 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from multiprocessing.pool import ThreadPool
 
 import pytest
diff --git a/tests/custom_cluster/test_udf_concurrency.py b/tests/custom_cluster/test_udf_concurrency.py
index 8e002655d..e9f9b8575 100644
--- a/tests/custom_cluster/test_udf_concurrency.py
+++ b/tests/custom_cluster/test_udf_concurrency.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import random
diff --git a/tests/custom_cluster/test_web_pages.py b/tests/custom_cluster/test_web_pages.py
index fb983cb9d..69b873ba9 100644
--- a/tests/custom_cluster/test_web_pages.py
+++ b/tests/custom_cluster/test_web_pages.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import json
 import random
 import re
diff --git a/tests/custom_cluster/test_wide_table_operations.py b/tests/custom_cluster/test_wide_table_operations.py
index e1081aff1..26daf46aa 100644
--- a/tests/custom_cluster/test_wide_table_operations.py
+++ b/tests/custom_cluster/test_wide_table_operations.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 from subprocess import call
diff --git a/tests/data_errors/test_data_errors.py b/tests/data_errors/test_data_errors.py
index d098dfed0..b0139e7ec 100644
--- a/tests/data_errors/test_data_errors.py
+++ b/tests/data_errors/test_data_errors.py
@@ -19,6 +19,7 @@
 #
 # Tests Impala properly handles errors when reading and writing data.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import subprocess
 
diff --git a/tests/experiments/test_targeted_perf.py b/tests/experiments/test_targeted_perf.py
index ceef28020..23c44e164 100644
--- a/tests/experiments/test_targeted_perf.py
+++ b/tests/experiments/test_targeted_perf.py
@@ -20,6 +20,7 @@
 # Additionally, we don't get any 'extra' coverage from them, so they're
 # not an essential part of functional verification.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 
 class TestTargetedPerf(ImpalaTestSuite):
diff --git a/tests/failure/test_failpoints.py b/tests/failure/test_failpoints.py
index 9283d4919..e95aa1e86 100644
--- a/tests/failure/test_failpoints.py
+++ b/tests/failure/test_failpoints.py
@@ -18,6 +18,7 @@
 # Injects failures  at specific locations in each of the plan nodes. Currently supports
 # two types of failures - cancellation of the query and a failure test hook.
 #
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 from time import sleep
diff --git a/tests/hs2/hs2_test_suite.py b/tests/hs2/hs2_test_suite.py
index c92b555f5..b8acbc502 100644
--- a/tests/hs2/hs2_test_suite.py
+++ b/tests/hs2/hs2_test_suite.py
@@ -17,6 +17,7 @@
 #
 # Superclass of all HS2 tests containing commonly used functions.
 
+from __future__ import absolute_import, division, print_function
 from getpass import getuser
 from TCLIService import TCLIService
 from ImpalaService import ImpalaHiveServer2Service
@@ -286,7 +287,7 @@ class HS2TestSuite(ImpalaTestSuite):
         for col_type in HS2TestSuite.HS2_V6_COLUMN_TYPES:
           typed_col = getattr(c, col_type)
           if typed_col != None:
-            indicator = ord(typed_col.nulls[i / 8])
+            indicator = ord(typed_col.nulls[i // 8])
             if indicator & (1 << (i % 8)):
               row.append("NULL")
             else:
diff --git a/tests/hs2/test_fetch.py b/tests/hs2/test_fetch.py
index 7b4fe396c..1d64d49b3 100644
--- a/tests/hs2/test_fetch.py
+++ b/tests/hs2/test_fetch.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 
diff --git a/tests/hs2/test_fetch_first.py b/tests/hs2/test_fetch_first.py
index 75d846873..d40b1d0bb 100644
--- a/tests/hs2/test_fetch_first.py
+++ b/tests/hs2/test_fetch_first.py
@@ -20,6 +20,7 @@
 # via the 'impala.resultset.cache.size' confOverlay option. FETCH_FIRST will
 # succeed as long all previously fetched rows fit into the bounded result cache.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from ImpalaService import ImpalaHiveServer2Service
diff --git a/tests/hs2/test_fetch_timeout.py b/tests/hs2/test_fetch_timeout.py
index 01faac7c2..ea0ec5929 100644
--- a/tests/hs2/test_fetch_timeout.py
+++ b/tests/hs2/test_fetch_timeout.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from time import sleep
 from time import time
 from tests.common.errors import Timeout
diff --git a/tests/hs2/test_hs2.py b/tests/hs2/test_hs2.py
index b7f71a19c..e87877b54 100644
--- a/tests/hs2/test_hs2.py
+++ b/tests/hs2/test_hs2.py
@@ -17,6 +17,7 @@
 #
 # Client tests for Impala's HiveServer2 interface
 
+from __future__ import absolute_import, division, print_function
 from getpass import getuser
 from contextlib import contextmanager
 import json
diff --git a/tests/hs2/test_json_endpoints.py b/tests/hs2/test_json_endpoints.py
index d661bf757..64bce618c 100644
--- a/tests/hs2/test_json_endpoints.py
+++ b/tests/hs2/test_json_endpoints.py
@@ -17,6 +17,7 @@
 #
 # Tests for query expiration.
 
+from __future__ import absolute_import, division, print_function
 import json
 import pytest
 from time import time
diff --git a/tests/infra/test_perf_infra.py b/tests/infra/test_perf_infra.py
index 3ec461706..951cf38d9 100644
--- a/tests/infra/test_perf_infra.py
+++ b/tests/infra/test_perf_infra.py
@@ -19,6 +19,7 @@
 # product or other constraints. We want to stop these assumptions from breaking at
 # pre-merge time, not later.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/infra/test_stress_infra.py b/tests/infra/test_stress_infra.py
index 20dac52e2..8dd90457d 100644
--- a/tests/infra/test_stress_infra.py
+++ b/tests/infra/test_stress_infra.py
@@ -19,6 +19,7 @@
 # product or other constraints. We want to stop these assumptions from breaking at
 # pre-merge time, not later.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from decimal import Decimal
diff --git a/tests/infra/test_utils.py b/tests/infra/test_utils.py
index 1c2e28271..897cd90c7 100644
--- a/tests/infra/test_utils.py
+++ b/tests/infra/test_utils.py
@@ -17,6 +17,7 @@
 
 # This module contains tests for some of the tests/util code.
 
+from __future__ import absolute_import, division, print_function
 from tests.util.filesystem_utils import prepend_with_fs
 from tests.util.parse_util import get_bytes_summary_stats_counter
 
diff --git a/tests/metadata/test_catalogd_debug_actions.py b/tests/metadata/test_catalogd_debug_actions.py
index 77cfb58ef..23faf68eb 100644
--- a/tests/metadata/test_catalogd_debug_actions.py
+++ b/tests/metadata/test_catalogd_debug_actions.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfFS
diff --git a/tests/metadata/test_compute_stats.py b/tests/metadata/test_compute_stats.py
index e4c919e42..7f4bdff9a 100644
--- a/tests/metadata/test_compute_stats.py
+++ b/tests/metadata/test_compute_stats.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from subprocess import check_call
 
diff --git a/tests/metadata/test_ddl.py b/tests/metadata/test_ddl.py
index f633ad48a..ff9357315 100644
--- a/tests/metadata/test_ddl.py
+++ b/tests/metadata/test_ddl.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import getpass
 import itertools
 import pytest
@@ -622,7 +623,7 @@ class TestDdlStatements(TestDdlBase):
          "location '{1}/{0}'".format(fq_tbl_name, WAREHOUSE))
 
     # Add some partitions (first batch of two)
-    for i in xrange(num_parts / 5):
+    for i in xrange(num_parts // 5):
       start = time.time()
       self.client.execute(
           "alter table {0} add partition(j={1}, s='{1}')".format(fq_tbl_name, i))
@@ -644,7 +645,7 @@ class TestDdlStatements(TestDdlBase):
         .format(fq_tbl_name, WAREHOUSE))
 
     # Add some more partitions
-    for i in xrange(num_parts / 5, num_parts):
+    for i in xrange(num_parts // 5, num_parts):
       start = time.time()
       self.client.execute(
           "alter table {0} add partition(j={1},s='{1}')".format(fq_tbl_name, i))
diff --git a/tests/metadata/test_ddl_base.py b/tests/metadata/test_ddl_base.py
index 068d34bce..494d99315 100644
--- a/tests/metadata/test_ddl_base.py
+++ b/tests/metadata/test_ddl_base.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import absolute_import, division, print_function
 from tests.common.test_dimensions import (
     ALL_NODES_ONLY,
     create_exec_option_dimension,
diff --git a/tests/metadata/test_event_processing.py b/tests/metadata/test_event_processing.py
index b8d5553ca..f0358b7aa 100644
--- a/tests/metadata/test_event_processing.py
+++ b/tests/metadata/test_event_processing.py
@@ -14,6 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from __future__ import absolute_import, division, print_function
 from subprocess import check_call
 import pytest
 
diff --git a/tests/metadata/test_explain.py b/tests/metadata/test_explain.py
index 9e1e35697..c42f485dc 100644
--- a/tests/metadata/test_explain.py
+++ b/tests/metadata/test_explain.py
@@ -17,6 +17,7 @@
 
 # Functional tests running EXPLAIN statements.
 #
+from __future__ import absolute_import, division, print_function
 import re
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/metadata/test_hdfs_encryption.py b/tests/metadata/test_hdfs_encryption.py
index 897180fd5..ff3706d0f 100644
--- a/tests/metadata/test_hdfs_encryption.py
+++ b/tests/metadata/test_hdfs_encryption.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import getpass
 import pytest
 
diff --git a/tests/metadata/test_hdfs_permissions.py b/tests/metadata/test_hdfs_permissions.py
index 766fdfcfc..b840154b1 100644
--- a/tests/metadata/test_hdfs_permissions.py
+++ b/tests/metadata/test_hdfs_permissions.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfFS, SkipIfLocal, SkipIfCatalogV2
 from tests.common.test_dimensions import (
diff --git a/tests/metadata/test_hidden_files.py b/tests/metadata/test_hidden_files.py
index 8454b83b8..d6775d27f 100644
--- a/tests/metadata/test_hidden_files.py
+++ b/tests/metadata/test_hidden_files.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from subprocess import check_call
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/metadata/test_hms_integration.py b/tests/metadata/test_hms_integration.py
index 828033a9f..343f67877 100644
--- a/tests/metadata/test_hms_integration.py
+++ b/tests/metadata/test_hms_integration.py
@@ -23,7 +23,7 @@
 # TODO: For each test, verify all the metadata available via Hive and
 # Impala, in all the possible ways of validating that metadata.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import pytest
 import random
 import string
diff --git a/tests/metadata/test_last_ddl_time_update.py b/tests/metadata/test_last_ddl_time_update.py
index 36a4db358..7e44b4bd5 100644
--- a/tests/metadata/test_last_ddl_time_update.py
+++ b/tests/metadata/test_last_ddl_time_update.py
@@ -16,6 +16,7 @@
 # under the License.
 
 # Impala tests for DDL statements
+from __future__ import absolute_import, division, print_function
 import time
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/metadata/test_load.py b/tests/metadata/test_load.py
index 149664d66..9dc3500e8 100644
--- a/tests/metadata/test_load.py
+++ b/tests/metadata/test_load.py
@@ -17,6 +17,7 @@
 
 # Functional tests for LOAD DATA statements.
 
+from __future__ import absolute_import, division, print_function
 import time
 from beeswaxd.BeeswaxService import QueryState
 from copy import deepcopy
diff --git a/tests/metadata/test_metadata_query_statements.py b/tests/metadata/test_metadata_query_statements.py
index 357cc8bc8..e2ecc985d 100644
--- a/tests/metadata/test_metadata_query_statements.py
+++ b/tests/metadata/test_metadata_query_statements.py
@@ -17,6 +17,7 @@
 
 # Impala tests for queries that query metadata and set session settings
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 
diff --git a/tests/metadata/test_partition_metadata.py b/tests/metadata/test_partition_metadata.py
index 0b922e38b..0f571fc1a 100644
--- a/tests/metadata/test_partition_metadata.py
+++ b/tests/metadata/test_partition_metadata.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfFS, SkipIfLocal
diff --git a/tests/metadata/test_recover_partitions.py b/tests/metadata/test_recover_partitions.py
index 40b6343d0..131c31155 100644
--- a/tests/metadata/test_recover_partitions.py
+++ b/tests/metadata/test_recover_partitions.py
@@ -17,6 +17,7 @@
 #
 # Impala tests for ALTER TABLE RECOVER PARTITIONS statement
 
+from __future__ import absolute_import, division, print_function
 import os
 from six.moves import urllib
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/metadata/test_recursive_listing.py b/tests/metadata/test_recursive_listing.py
index eb4d0e86f..9273387e4 100644
--- a/tests/metadata/test_recursive_listing.py
+++ b/tests/metadata/test_recursive_listing.py
@@ -10,6 +10,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import requests
 import time
diff --git a/tests/metadata/test_refresh_partition.py b/tests/metadata/test_refresh_partition.py
index 984f96ebb..b3abbbe5f 100644
--- a/tests/metadata/test_refresh_partition.py
+++ b/tests/metadata/test_refresh_partition.py
@@ -11,6 +11,7 @@
 # limitations under the License.
 
 
+from __future__ import absolute_import, division, print_function
 from subprocess import check_call
 
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/metadata/test_reset_metadata.py b/tests/metadata/test_reset_metadata.py
index 53e4ad538..6a02f003b 100644
--- a/tests/metadata/test_reset_metadata.py
+++ b/tests/metadata/test_reset_metadata.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from test_ddl_base import TestDdlBase
 
 
diff --git a/tests/metadata/test_reuse_partitions.py b/tests/metadata/test_reuse_partitions.py
index 72bd0d8b6..24a3e36a4 100644
--- a/tests/metadata/test_reuse_partitions.py
+++ b/tests/metadata/test_reuse_partitions.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import json
 import requests
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/metadata/test_set.py b/tests/metadata/test_set.py
index a1b3276e5..bbfa71f3a 100644
--- a/tests/metadata/test_set.py
+++ b/tests/metadata/test_set.py
@@ -17,6 +17,7 @@
 #
 # Tests for SET <query option>
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (
     create_single_exec_option_dimension,
diff --git a/tests/metadata/test_show_create_table.py b/tests/metadata/test_show_create_table.py
index f1d44627e..d0f264739 100644
--- a/tests/metadata/test_show_create_table.py
+++ b/tests/metadata/test_show_create_table.py
@@ -14,6 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from __future__ import absolute_import, division, print_function
 import pprint
 import pytest
 import re
diff --git a/tests/metadata/test_stale_metadata.py b/tests/metadata/test_stale_metadata.py
index 9611939fd..d58a5fc22 100644
--- a/tests/metadata/test_stale_metadata.py
+++ b/tests/metadata/test_stale_metadata.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from subprocess import check_call
 
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/metadata/test_stats_extrapolation.py b/tests/metadata/test_stats_extrapolation.py
index 605bf663c..00aa721ad 100644
--- a/tests/metadata/test_stats_extrapolation.py
+++ b/tests/metadata/test_stats_extrapolation.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from os import path
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfEC
diff --git a/tests/metadata/test_testcase_builder.py b/tests/metadata/test_testcase_builder.py
index 30a271404..a3d5d38a6 100644
--- a/tests/metadata/test_testcase_builder.py
+++ b/tests/metadata/test_testcase_builder.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (
   create_single_exec_option_dimension,
diff --git a/tests/metadata/test_views_compatibility.py b/tests/metadata/test_views_compatibility.py
index 7daedc711..8d19fceb1 100644
--- a/tests/metadata/test_views_compatibility.py
+++ b/tests/metadata/test_views_compatibility.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pprint
 import pytest
 import shlex
diff --git a/tests/observability/test_jvm_metrics.py b/tests/observability/test_jvm_metrics.py
index 80deb8134..9977d1130 100644
--- a/tests/observability/test_jvm_metrics.py
+++ b/tests/observability/test_jvm_metrics.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 
 
diff --git a/tests/observability/test_log_fragments.py b/tests/observability/test_log_fragments.py
index f81d79edd..f1172efad 100644
--- a/tests/observability/test_log_fragments.py
+++ b/tests/observability/test_log_fragments.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfDockerizedCluster
 
diff --git a/tests/observability/test_profile_tool.py b/tests/observability/test_profile_tool.py
index 42ad87fb6..c370e26c0 100644
--- a/tests/observability/test_profile_tool.py
+++ b/tests/observability/test_profile_tool.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os.path
 import tempfile
 from subprocess import check_call
diff --git a/tests/performance/query.py b/tests/performance/query.py
index 5884a015b..5832e5dfa 100644
--- a/tests/performance/query.py
+++ b/tests/performance/query.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.util.test_file_parser import QueryTestSectionReader
 
 # TODO: This interface needs to be more robust; At the moment, it has two users with
diff --git a/tests/performance/query_exec_functions.py b/tests/performance/query_exec_functions.py
index 2bd2953f1..471a1ea61 100644
--- a/tests/performance/query_exec_functions.py
+++ b/tests/performance/query_exec_functions.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+from __future__ import absolute_import, division, print_function
 import logging
 import re
 from datetime import datetime
diff --git a/tests/performance/query_executor.py b/tests/performance/query_executor.py
index 344ebbfc9..bb47a40cb 100644
--- a/tests/performance/query_executor.py
+++ b/tests/performance/query_executor.py
@@ -29,6 +29,7 @@
 # executor.run()
 # result = executor.result
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import re
diff --git a/tests/performance/scheduler.py b/tests/performance/scheduler.py
index e61245474..95d2a7a13 100644
--- a/tests/performance/scheduler.py
+++ b/tests/performance/scheduler.py
@@ -19,6 +19,7 @@
 # defined as a set of queries for a given  data set, scale factor and a specific test
 # vector. It treats a workload an the unit of parallelism.
 
+from __future__ import absolute_import, division, print_function
 import logging
 
 from collections import defaultdict
diff --git a/tests/performance/workload.py b/tests/performance/workload.py
index e6d0a6e88..1fc47b2e1 100644
--- a/tests/performance/workload.py
+++ b/tests/performance/workload.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+from __future__ import absolute_import, division, print_function
 import os
 import fnmatch
 import re
diff --git a/tests/performance/workload_runner.py b/tests/performance/workload_runner.py
index 24b353f72..f77f730f5 100644
--- a/tests/performance/workload_runner.py
+++ b/tests/performance/workload_runner.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 
 from tests.common.test_dimensions import (
diff --git a/tests/query_test/test_acid.py b/tests/query_test/test_acid.py
index 2b09d830a..53d52270a 100644
--- a/tests/query_test/test_acid.py
+++ b/tests/query_test/test_acid.py
@@ -17,6 +17,7 @@
 
 # Functional tests for ACID integration with Hive.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import time
diff --git a/tests/query_test/test_acid_row_validation.py b/tests/query_test/test_acid_row_validation.py
index 041e75450..21880391f 100644
--- a/tests/query_test/test_acid_row_validation.py
+++ b/tests/query_test/test_acid_row_validation.py
@@ -17,6 +17,7 @@
 
 # Functional tests for ACID integration with Hive.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 
diff --git a/tests/query_test/test_aggregation.py b/tests/query_test/test_aggregation.py
index 165e595ce..cf399e20d 100644
--- a/tests/query_test/test_aggregation.py
+++ b/tests/query_test/test_aggregation.py
@@ -17,7 +17,7 @@
 
 # Validates all aggregate functions across all datatypes
 #
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from testdata.common import widetable
diff --git a/tests/query_test/test_analytic_tpcds.py b/tests/query_test/test_analytic_tpcds.py
index 57042e815..1cdc7f861 100644
--- a/tests/query_test/test_analytic_tpcds.py
+++ b/tests/query_test/test_analytic_tpcds.py
@@ -17,6 +17,7 @@
 #
 # Targeted tests to validate analytic functions use TPCDS dataset.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_parquet_dimension, ImpalaTestDimension
 
diff --git a/tests/query_test/test_async_codegen.py b/tests/query_test/test_async_codegen.py
index ae7e43fb4..acc073f24 100644
--- a/tests/query_test/test_async_codegen.py
+++ b/tests/query_test/test_async_codegen.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_avro_schema_resolution.py b/tests/query_test/test_avro_schema_resolution.py
index 52feb8a55..b6ed92bff 100644
--- a/tests/query_test/test_avro_schema_resolution.py
+++ b/tests/query_test/test_avro_schema_resolution.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfCatalogV2
 
diff --git a/tests/query_test/test_beeswax.py b/tests/query_test/test_beeswax.py
index 2887d1c23..59a9ad5bc 100644
--- a/tests/query_test/test_beeswax.py
+++ b/tests/query_test/test_beeswax.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
 from tests.common.impala_test_suite import ImpalaTestSuite
 
diff --git a/tests/query_test/test_cancellation.py b/tests/query_test/test_cancellation.py
index b12725c17..784c8ef24 100644
--- a/tests/query_test/test_cancellation.py
+++ b/tests/query_test/test_cancellation.py
@@ -18,6 +18,7 @@
 # Tests query cancellation using the ImpalaService.Cancel API
 #
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import threading
 from time import sleep
diff --git a/tests/query_test/test_cast_with_format.py b/tests/query_test/test_cast_with_format.py
index 2e5127661..e73a6f9cf 100644
--- a/tests/query_test/test_cast_with_format.py
+++ b/tests/query_test/test_cast_with_format.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_client_protocol_dimension
 
diff --git a/tests/query_test/test_chars.py b/tests/query_test/test_chars.py
index de9ab2cf6..e4cf8ea9f 100644
--- a/tests/query_test/test_chars.py
+++ b/tests/query_test/test_chars.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_codegen.py b/tests/query_test/test_codegen.py
index 18597aa64..81a56b3b0 100644
--- a/tests/query_test/test_codegen.py
+++ b/tests/query_test/test_codegen.py
@@ -17,6 +17,7 @@
 
 # Tests end-to-end codegen behaviour.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIf
 from tests.common.test_dimensions import create_exec_option_dimension_from_dict
diff --git a/tests/query_test/test_compressed_formats.py b/tests/query_test/test_compressed_formats.py
index e9187445d..894f237f0 100644
--- a/tests/query_test/test_compressed_formats.py
+++ b/tests/query_test/test_compressed_formats.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import math
 import os
 import pytest
@@ -259,7 +259,7 @@ class TestLargeCompressedFile(ImpalaTestSuite):
     # Number of nested structures described above.
     num_chunks = int(math.ceil(file_size / self.CHUNK_SIZE))
     # Number of compressed snappy blocks per chunk.
-    num_blocks_per_chunk = self.CHUNK_SIZE / (compressed_size + 4)
+    num_blocks_per_chunk = self.CHUNK_SIZE // (compressed_size + 4)
     # Total uncompressed size of a nested structure.
     total_chunk_size = num_blocks_per_chunk * payload_size
 
diff --git a/tests/query_test/test_datasketches.py b/tests/query_test/test_datasketches.py
index 89e2da2c5..b8925133d 100644
--- a/tests/query_test/test_datasketches.py
+++ b/tests/query_test/test_datasketches.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.file_utils import create_table_from_parquet
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_single_exec_option_dimension
diff --git a/tests/query_test/test_datastream_sender.py b/tests/query_test/test_datastream_sender.py
index c48798884..b5c266a35 100644
--- a/tests/query_test/test_datastream_sender.py
+++ b/tests/query_test/test_datastream_sender.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 
 
diff --git a/tests/query_test/test_date_queries.py b/tests/query_test/test_date_queries.py
index 56e37aeb2..ad51e4b03 100644
--- a/tests/query_test/test_date_queries.py
+++ b/tests/query_test/test_date_queries.py
@@ -17,6 +17,7 @@
 
 # Targeted tests for date type.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.file_utils import create_table_and_copy_files
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_decimal_casting.py b/tests/query_test/test_decimal_casting.py
index f487e8bc3..8c4ea5912 100644
--- a/tests/query_test/test_decimal_casting.py
+++ b/tests/query_test/test_decimal_casting.py
@@ -17,6 +17,7 @@
 #
 # Validates that casting to Decimal works.
 #
+from __future__ import absolute_import, division, print_function
 import pytest
 from decimal import Decimal, getcontext, ROUND_DOWN, ROUND_HALF_UP
 from allpairspy import AllPairs as all_pairs
diff --git a/tests/query_test/test_decimal_fuzz.py b/tests/query_test/test_decimal_fuzz.py
index b0fb57253..1f468960c 100644
--- a/tests/query_test/test_decimal_fuzz.py
+++ b/tests/query_test/test_decimal_fuzz.py
@@ -18,6 +18,7 @@
 # Generates random decimal numbers and verifies that mathematical
 # operations return correct results under decimal_v2.
 
+from __future__ import absolute_import, division, print_function
 import decimal
 import math
 import pytest
@@ -263,7 +264,7 @@ class TestDecimalFuzz(ImpalaTestSuite):
 
     range_size = max_range_int - min_range_int
     dist_from_min = val_int - min_range_int
-    return (num_buckets * dist_from_min) / range_size + 1
+    return (num_buckets * dist_from_min) // range_size + 1
 
   def execute_one_width_bucket(self):
     val, val_prec, val_scale = self.get_decimal()
diff --git a/tests/query_test/test_decimal_queries.py b/tests/query_test/test_decimal_queries.py
index a361eef59..7ed102275 100644
--- a/tests/query_test/test_decimal_queries.py
+++ b/tests/query_test/test_decimal_queries.py
@@ -17,6 +17,7 @@
 
 # Targeted tests for decimal type.
 
+from __future__ import absolute_import, division, print_function
 from copy import copy
 import pytest
 
diff --git a/tests/query_test/test_delimited_text.py b/tests/query_test/test_delimited_text.py
index 779397c7b..34bd93e04 100644
--- a/tests/query_test/test_delimited_text.py
+++ b/tests/query_test/test_delimited_text.py
@@ -19,6 +19,7 @@
 # and escape characters.
 #
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (
     create_single_exec_option_dimension,
diff --git a/tests/query_test/test_errorlog.py b/tests/query_test/test_errorlog.py
index 258dba020..0cdaa2f06 100644
--- a/tests/query_test/test_errorlog.py
+++ b/tests/query_test/test_errorlog.py
@@ -18,6 +18,7 @@
 # Injects failures  at specific locations in each of the plan nodes. Currently supports
 # two types of failures - cancellation of the query and a failure test hook.
 #
+from __future__ import absolute_import, division, print_function
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (
diff --git a/tests/query_test/test_exprs.py b/tests/query_test/test_exprs.py
index 03e6a3b15..f396841d0 100644
--- a/tests/query_test/test_exprs.py
+++ b/tests/query_test/test_exprs.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 from random import randint
@@ -110,7 +111,7 @@ class TestExprLimits(ImpalaTestSuite):
 
     # CASE expr
     case_query = "select case "
-    for i in xrange(0, self.EXPR_CHILDREN_LIMIT/2):
+    for i in xrange(0, self.EXPR_CHILDREN_LIMIT // 2):
       case_query += " when true then 1"
     case_query += " end"
     self.__exec_query(case_query)
diff --git a/tests/query_test/test_fetch.py b/tests/query_test/test_fetch.py
index 361d8ea9f..2b86a77fc 100644
--- a/tests/query_test/test_fetch.py
+++ b/tests/query_test/test_fetch.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import re
 
 from time import sleep
diff --git a/tests/query_test/test_geospatial_functions.py b/tests/query_test/test_geospatial_functions.py
index 2d8108d9a..2b34e8f1e 100644
--- a/tests/query_test/test_geospatial_functions.py
+++ b/tests/query_test/test_geospatial_functions.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfApacheHive
 
diff --git a/tests/query_test/test_hash_join_timer.py b/tests/query_test/test_hash_join_timer.py
index a6e408e54..5a340d0a9 100644
--- a/tests/query_test/test_hash_join_timer.py
+++ b/tests/query_test/test_hash_join_timer.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 
@@ -118,9 +119,9 @@ class TestHashJoinTimer(ImpalaTestSuite):
     join_node_name = "03:%s" % (join_type)
     for line in exec_summary:
       if line['operator'] == join_node_name:
-        avg_time_ms = line['avg_time'] / self.NANOS_PER_MILLI
+        avg_time_ms = line['avg_time'] // self.NANOS_PER_MILLI
         self.__verify_join_time(avg_time_ms, "ExecSummary Avg")
-        max_time_ms = line['max_time'] / self.NANOS_PER_MILLI
+        max_time_ms = line['max_time'] // self.NANOS_PER_MILLI
         self.__verify_join_time(max_time_ms, "ExecSummary Max")
         check_execsummary_count += 1
     assert (check_execsummary_count == 1), \
diff --git a/tests/query_test/test_hbase_queries.py b/tests/query_test/test_hbase_queries.py
index a1acbf33b..15e715dae 100644
--- a/tests/query_test/test_hbase_queries.py
+++ b/tests/query_test/test_hbase_queries.py
@@ -17,6 +17,7 @@
 
 # Targeted Impala HBase Tests
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_hdfs_caching.py b/tests/query_test/test_hdfs_caching.py
index 32f91702a..105895af2 100644
--- a/tests/query_test/test_hdfs_caching.py
+++ b/tests/query_test/test_hdfs_caching.py
@@ -17,7 +17,7 @@
 
 # Validates limit on scan nodes
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 import time
diff --git a/tests/query_test/test_hdfs_file_mods.py b/tests/query_test/test_hdfs_file_mods.py
index 48e899521..38e9a5ca2 100644
--- a/tests/query_test/test_hdfs_file_mods.py
+++ b/tests/query_test/test_hdfs_file_mods.py
@@ -16,6 +16,7 @@
 # under the License.
 
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/query_test/test_iceberg.py b/tests/query_test/test_iceberg.py
index 6f1938c0d..76491ce65 100644
--- a/tests/query_test/test_iceberg.py
+++ b/tests/query_test/test_iceberg.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import datetime
 import logging
 import os
diff --git a/tests/query_test/test_insert.py b/tests/query_test/test_insert.py
index 05a40401f..05e3aa998 100644
--- a/tests/query_test/test_insert.py
+++ b/tests/query_test/test_insert.py
@@ -17,6 +17,7 @@
 
 # Targeted Impala insert tests
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import re
diff --git a/tests/query_test/test_insert_behaviour.py b/tests/query_test/test_insert_behaviour.py
index 5b20759c0..f4b269c32 100644
--- a/tests/query_test/test_insert_behaviour.py
+++ b/tests/query_test/test_insert_behaviour.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import getpass
 import grp
 import os
diff --git a/tests/query_test/test_insert_parquet.py b/tests/query_test/test_insert_parquet.py
index 6113664f0..33fc83af5 100644
--- a/tests/query_test/test_insert_parquet.py
+++ b/tests/query_test/test_insert_parquet.py
@@ -17,6 +17,7 @@
 
 # Targeted Impala insert tests
 
+from __future__ import absolute_import, division, print_function
 import os
 
 from collections import namedtuple
diff --git a/tests/query_test/test_insert_permutation.py b/tests/query_test/test_insert_permutation.py
index 46d10903a..a3973a40e 100644
--- a/tests/query_test/test_insert_permutation.py
+++ b/tests/query_test/test_insert_permutation.py
@@ -17,6 +17,7 @@
 
 # Targeted Impala insert tests
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (
     create_exec_option_dimension,
diff --git a/tests/query_test/test_invalid_test_header.py b/tests/query_test/test_invalid_test_header.py
index 6b7b3bd49..886972e04 100644
--- a/tests/query_test/test_invalid_test_header.py
+++ b/tests/query_test/test_invalid_test_header.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.impala_test_suite import ImpalaTestSuite
 
diff --git a/tests/query_test/test_io_metrics.py b/tests/query_test/test_io_metrics.py
index 5388f85b6..621d6f418 100644
--- a/tests/query_test/test_io_metrics.py
+++ b/tests/query_test/test_io_metrics.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.environ import IS_DOCKERIZED_TEST_CLUSTER
diff --git a/tests/query_test/test_join_queries.py b/tests/query_test/test_join_queries.py
index 8961b6391..48abae1ad 100644
--- a/tests/query_test/test_join_queries.py
+++ b/tests/query_test/test_join_queries.py
@@ -17,6 +17,7 @@
 
 # Targeted tests for Impala joins
 #
+from __future__ import absolute_import, division, print_function
 import pytest
 from copy import deepcopy
 
diff --git a/tests/query_test/test_kudu.py b/tests/query_test/test_kudu.py
index 0f1c59a17..d637b3c35 100644
--- a/tests/query_test/test_kudu.py
+++ b/tests/query_test/test_kudu.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from kudu.schema import (
     BOOL,
     DOUBLE,
diff --git a/tests/query_test/test_lifecycle.py b/tests/query_test/test_lifecycle.py
index 30b12c067..a14cf1e79 100644
--- a/tests/query_test/test_lifecycle.py
+++ b/tests/query_test/test_lifecycle.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import time
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/query_test/test_limit.py b/tests/query_test/test_limit.py
index 5233b4682..8ff09e462 100644
--- a/tests/query_test/test_limit.py
+++ b/tests/query_test/test_limit.py
@@ -17,7 +17,7 @@
 
 # Validates limit on scan nodes
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_vector import ImpalaTestDimension
diff --git a/tests/query_test/test_limit_pushdown_analytic.py b/tests/query_test/test_limit_pushdown_analytic.py
index caac68b5a..d1295eea8 100644
--- a/tests/query_test/test_limit_pushdown_analytic.py
+++ b/tests/query_test/test_limit_pushdown_analytic.py
@@ -18,6 +18,7 @@
 # Test the limit pushdown to analytic sort in the presence
 # of ranking functions
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (create_single_exec_option_dimension,
     extend_exec_option_dimension)
diff --git a/tests/query_test/test_local_fs.py b/tests/query_test/test_local_fs.py
index dd891dbbb..a6468fbbd 100644
--- a/tests/query_test/test_local_fs.py
+++ b/tests/query_test/test_local_fs.py
@@ -17,6 +17,7 @@
 
 # Validates table stored on the LocalFileSystem.
 #
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfDockerizedCluster
 from tests.common.test_dimensions import create_single_exec_option_dimension
diff --git a/tests/query_test/test_mem_usage_scaling.py b/tests/query_test/test_mem_usage_scaling.py
index 8910aa336..8660f9433 100644
--- a/tests/query_test/test_mem_usage_scaling.py
+++ b/tests/query_test/test_mem_usage_scaling.py
@@ -15,6 +15,8 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+
+from __future__ import absolute_import, division, print_function
 import pytest
 from copy import copy
 
diff --git a/tests/query_test/test_mt_dop.py b/tests/query_test/test_mt_dop.py
index 58483c9ec..94d54c90a 100644
--- a/tests/query_test/test_mt_dop.py
+++ b/tests/query_test/test_mt_dop.py
@@ -17,6 +17,7 @@
 
 # Tests queries with the MT_DOP query option.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import logging
 
diff --git a/tests/query_test/test_multiple_filesystems.py b/tests/query_test/test_multiple_filesystems.py
index 91abe53a2..628baa79a 100644
--- a/tests/query_test/test_multiple_filesystems.py
+++ b/tests/query_test/test_multiple_filesystems.py
@@ -17,6 +17,7 @@
 
 # Validates table stored on the LocalFileSystem.
 #
+from __future__ import absolute_import, division, print_function
 import pytest
 from subprocess import check_call, call
 
diff --git a/tests/query_test/test_nested_types.py b/tests/query_test/test_nested_types.py
index 99d44e537..e92cf49bd 100644
--- a/tests/query_test/test_nested_types.py
+++ b/tests/query_test/test_nested_types.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 from copy import deepcopy
 import pytest
diff --git a/tests/query_test/test_observability.py b/tests/query_test/test_observability.py
index 51124bb61..a7f42058f 100644
--- a/tests/query_test/test_observability.py
+++ b/tests/query_test/test_observability.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from collections import defaultdict
 from datetime import datetime
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/query_test/test_orc_stats.py b/tests/query_test/test_orc_stats.py
index 25cb10616..3237ac8d0 100644
--- a/tests/query_test/test_orc_stats.py
+++ b/tests/query_test/test_orc_stats.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 
 
diff --git a/tests/query_test/test_parquet_bloom_filter.py b/tests/query_test/test_parquet_bloom_filter.py
index 11af6d28d..902d7e769 100644
--- a/tests/query_test/test_parquet_bloom_filter.py
+++ b/tests/query_test/test_parquet_bloom_filter.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import math
 import os
 
diff --git a/tests/query_test/test_parquet_late_materialization.py b/tests/query_test/test_parquet_late_materialization.py
index 670daa4d6..aa1fb3b13 100644
--- a/tests/query_test/test_parquet_late_materialization.py
+++ b/tests/query_test/test_parquet_late_materialization.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 
 
diff --git a/tests/query_test/test_parquet_page_index.py b/tests/query_test/test_parquet_page_index.py
index cd8127767..8bf26a074 100644
--- a/tests/query_test/test_parquet_page_index.py
+++ b/tests/query_test/test_parquet_page_index.py
@@ -17,6 +17,7 @@
 
 # Targeted Impala insert tests
 
+from __future__ import absolute_import, division, print_function
 import os
 
 from collections import namedtuple
diff --git a/tests/query_test/test_parquet_stats.py b/tests/query_test/test_parquet_stats.py
index dd3ce678f..41b2a8349 100644
--- a/tests/query_test/test_parquet_stats.py
+++ b/tests/query_test/test_parquet_stats.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import shlex
diff --git a/tests/query_test/test_partitioning.py b/tests/query_test/test_partitioning.py
index 649d785fc..1ff0d23cf 100644
--- a/tests/query_test/test_partitioning.py
+++ b/tests/query_test/test_partitioning.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/query_test/test_queries.py b/tests/query_test/test_queries.py
index dbde99a2f..2b9ee01bf 100644
--- a/tests/query_test/test_queries.py
+++ b/tests/query_test/test_queries.py
@@ -17,6 +17,7 @@
 
 # General Impala query tests
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 from copy import deepcopy
diff --git a/tests/query_test/test_query_compilation.py b/tests/query_test/test_query_compilation.py
index 1d4c9caff..f880d37c1 100644
--- a/tests/query_test/test_query_compilation.py
+++ b/tests/query_test/test_query_compilation.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from tests.common.impala_test_suite import ImpalaTestSuite
 
diff --git a/tests/query_test/test_query_mem_limit.py b/tests/query_test/test_query_mem_limit.py
index 209fca84f..bd3615c35 100644
--- a/tests/query_test/test_query_mem_limit.py
+++ b/tests/query_test/test_query_mem_limit.py
@@ -17,6 +17,7 @@
 #
 # Targeted tests to validate per-query memory limit.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 import sys
@@ -46,8 +47,8 @@ class TestQueryMemLimit(ImpalaTestSuite):
   # A mem_limit is expressed in bytes, with values <= 0 signifying no cap.
   # These values are either really small, unlimited, or have a really large cap.
   MAXINT_BYTES = str(sys.maxint)
-  MAXINT_MB = str(sys.maxint/(1024*1024))
-  MAXINT_GB = str(sys.maxint/(1024*1024*1024))
+  MAXINT_MB = str(sys.maxint // (1024 * 1024))
+  MAXINT_GB = str(sys.maxint // (1024 * 1024 * 1024))
   # We expect the tests with MAXINT_* using valid units [bmg] to succeed.
   PASS_REGEX = re.compile("(%s|%s|%s)[bmg]?$" % (MAXINT_BYTES, MAXINT_MB, MAXINT_GB),
                           re.I)
diff --git a/tests/query_test/test_query_opts.py b/tests/query_test/test_query_opts.py
index f9ef1d573..93f925d40 100644
--- a/tests/query_test/test_query_opts.py
+++ b/tests/query_test/test_query_opts.py
@@ -20,6 +20,7 @@
 #       to make it easier to handle startup failures (right now it waits 60sec to
 #       timeout).
 
+from __future__ import absolute_import, division, print_function
 from TCLIService import TCLIService
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_resource_limits.py b/tests/query_test/test_resource_limits.py
index 7644193c3..9f95b4eb8 100644
--- a/tests/query_test/test_resource_limits.py
+++ b/tests/query_test/test_resource_limits.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIfEC, SkipIfLocal, SkipIfFS
 from tests.common.test_dimensions import create_parquet_dimension
diff --git a/tests/query_test/test_result_spooling.py b/tests/query_test/test_result_spooling.py
index a2db1bca8..9883cd94f 100644
--- a/tests/query_test/test_result_spooling.py
+++ b/tests/query_test/test_result_spooling.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 import time
diff --git a/tests/query_test/test_rows_availability.py b/tests/query_test/test_rows_availability.py
index 0bd65df8b..357929894 100644
--- a/tests/query_test/test_rows_availability.py
+++ b/tests/query_test/test_rows_availability.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import re
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_runtime_filters.py b/tests/query_test/test_runtime_filters.py
index 2e91c1cf9..4be4305af 100644
--- a/tests/query_test/test_runtime_filters.py
+++ b/tests/query_test/test_runtime_filters.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 
+from __future__ import absolute_import, division, print_function
 from copy import deepcopy
 import os
 import pytest
diff --git a/tests/query_test/test_scanners.py b/tests/query_test/test_scanners.py
index 566442542..be372018b 100644
--- a/tests/query_test/test_scanners.py
+++ b/tests/query_test/test_scanners.py
@@ -21,7 +21,7 @@
 # tests can run with the normal exploration strategy and the overall test runtime doesn't
 # explode.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import random
diff --git a/tests/query_test/test_scanners_fuzz.py b/tests/query_test/test_scanners_fuzz.py
index 0576132c2..ec411abc1 100644
--- a/tests/query_test/test_scanners_fuzz.py
+++ b/tests/query_test/test_scanners_fuzz.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from copy import copy
 import itertools
 import logging
diff --git a/tests/query_test/test_scratch_limit.py b/tests/query_test/test_scratch_limit.py
index 8779cd31b..2620dc0ea 100644
--- a/tests/query_test/test_scratch_limit.py
+++ b/tests/query_test/test_scratch_limit.py
@@ -10,6 +10,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_single_exec_option_dimension
diff --git a/tests/query_test/test_sfs.py b/tests/query_test/test_sfs.py
index 5db318e21..4a1ee1caf 100644
--- a/tests/query_test/test_sfs.py
+++ b/tests/query_test/test_sfs.py
@@ -18,6 +18,7 @@
 # This test suite validates the functionality that allows users to create an external
 # table associated with a single file.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.file_utils import copy_files_to_hdfs_dir
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.skip import SkipIf
diff --git a/tests/query_test/test_sort.py b/tests/query_test/test_sort.py
index 2644c4c76..bcb76a766 100644
--- a/tests/query_test/test_sort.py
+++ b/tests/query_test/test_sort.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import re
 from copy import copy, deepcopy
 
diff --git a/tests/query_test/test_spilling.py b/tests/query_test/test_spilling.py
index 3c0c04d3d..ea49fb47f 100644
--- a/tests/query_test/test_spilling.py
+++ b/tests/query_test/test_spilling.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 from copy import deepcopy
 
diff --git a/tests/query_test/test_tablesample.py b/tests/query_test/test_tablesample.py
index 865238205..08e73ccb7 100644
--- a/tests/query_test/test_tablesample.py
+++ b/tests/query_test/test_tablesample.py
@@ -17,6 +17,7 @@
 
 # Tests the TABLESAMPLE clause.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import subprocess
 
diff --git a/tests/query_test/test_tpcds_queries.py b/tests/query_test/test_tpcds_queries.py
index a17276da4..bd497c9bd 100644
--- a/tests/query_test/test_tpcds_queries.py
+++ b/tests/query_test/test_tpcds_queries.py
@@ -17,6 +17,7 @@
 
 # Functional tests running the TPC-DS workload
 #
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_tpch_nested_queries.py b/tests/query_test/test_tpch_nested_queries.py
index 84ee2b58d..714852d94 100644
--- a/tests/query_test/test_tpch_nested_queries.py
+++ b/tests/query_test/test_tpch_nested_queries.py
@@ -17,6 +17,7 @@
 
 # Functional tests running the TPCH workload.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_single_exec_option_dimension
 
diff --git a/tests/query_test/test_tpch_queries.py b/tests/query_test/test_tpch_queries.py
index 68a298400..593037d5b 100644
--- a/tests/query_test/test_tpch_queries.py
+++ b/tests/query_test/test_tpch_queries.py
@@ -16,6 +16,7 @@
 # under the License.
 
 # Functional tests running the TPCH workload.
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/query_test/test_udfs.py b/tests/query_test/test_udfs.py
index 5ac87c038..a7e93fcbe 100644
--- a/tests/query_test/test_udfs.py
+++ b/tests/query_test/test_udfs.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from copy import copy
 import os
 import re
diff --git a/tests/query_test/test_utf8_strings.py b/tests/query_test/test_utf8_strings.py
index 3221eb8bc..8d583d884 100644
--- a/tests/query_test/test_utf8_strings.py
+++ b/tests/query_test/test_utf8_strings.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (create_exec_option_dimension,
     create_client_protocol_dimension, hs2_parquet_constraint)
diff --git a/tests/run-tests.py b/tests/run-tests.py
index 7c1ae8559..1ec0f9722 100755
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -22,7 +22,7 @@
 # executing the remaining tests in parallel. To run only some of
 # these, use --skip-serial, --skip-stress, or --skip-parallel.
 # All additional command line options are passed to py.test.
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_cluster import ImpalaCluster
 from tests.common.impala_service import ImpaladService
 from tests.conftest import configure_logging
diff --git a/tests/shell/test_cookie_util.py b/tests/shell/test_cookie_util.py
index 7e0cc54f3..5441ee334 100644
--- a/tests/shell/test_cookie_util.py
+++ b/tests/shell/test_cookie_util.py
@@ -18,6 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import unittest
 
 from datetime import datetime, timedelta
diff --git a/tests/shell/test_shell_client.py b/tests/shell/test_shell_client.py
index 1388b527f..949608613 100644
--- a/tests/shell/test_shell_client.py
+++ b/tests/shell/test_shell_client.py
@@ -18,12 +18,13 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from shell.impala_client import ImpalaBeeswaxClient, ImpalaHS2Client
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import (
   create_client_protocol_dimension, create_client_protocol_no_strict_dimension,
   create_uncompressed_text_dimension, create_single_exec_option_dimension)
-from util import get_impalad_host_port
+from tests.shell.util import get_impalad_host_port
 
 
 class TestShellClient(ImpalaTestSuite):
@@ -76,7 +77,7 @@ class TestShellClient(ImpalaTestSuite):
       client.connect()
       handle = client.execute_query(
           "select * from functional.alltypes limit {0}".format(num_rows), query_options)
-      self.__fetch_rows(client.fetch(handle), num_rows / fetch_size, num_rows)
+      self.__fetch_rows(client.fetch(handle), num_rows // fetch_size, num_rows)
     finally:
       if handle is not None: client.close_query(handle)
       client.close_connection()
@@ -85,7 +86,7 @@ class TestShellClient(ImpalaTestSuite):
     """Fetches all rows using the given fetch_batches generator. Asserts that num_batches
     batches are produced by the generator and that num_rows are returned."""
     num_batches_count = 0
-    rows_per_batch = num_rows / num_batches
+    rows_per_batch = num_rows // num_batches
     for fetch_batch in fetch_batches:
       assert len(fetch_batch) == rows_per_batch
       num_batches_count += 1
diff --git a/tests/shell/test_shell_commandline.py b/tests/shell/test_shell_commandline.py
index 484f7b97a..f78fa332c 100644
--- a/tests/shell/test_shell_commandline.py
+++ b/tests/shell/test_shell_commandline.py
@@ -18,6 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import errno
 import getpass
 import os
@@ -38,9 +39,9 @@ from tests.common.test_dimensions import (
   create_client_protocol_dimension, create_client_protocol_strict_dimension,
   create_uncompressed_text_dimension, create_single_exec_option_dimension)
 from time import sleep, time
-from util import (get_impalad_host_port, assert_var_substitution, run_impala_shell_cmd,
-                  ImpalaShell, build_shell_env, wait_for_query_state,
-                  create_impala_shell_executable_dimension, get_impala_shell_executable)
+from tests.shell.util import (get_impalad_host_port, assert_var_substitution,
+  run_impala_shell_cmd, ImpalaShell, build_shell_env, wait_for_query_state,
+  create_impala_shell_executable_dimension, get_impala_shell_executable)
 from contextlib import closing
 
 
diff --git a/tests/shell/test_shell_interactive.py b/tests/shell/test_shell_interactive.py
index 30ae99f16..f3469e907 100755
--- a/tests/shell/test_shell_interactive.py
+++ b/tests/shell/test_shell_interactive.py
@@ -18,7 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import httplib
 import logging
 import os
@@ -44,9 +44,9 @@ from tests.common.skip import SkipIfLocal
 from tests.common.test_dimensions import (
   create_client_protocol_dimension, create_client_protocol_strict_dimension,
   create_uncompressed_text_dimension, create_single_exec_option_dimension)
-from util import (assert_var_substitution, ImpalaShell, get_impalad_port, get_shell_cmd,
-                  get_open_sessions_metric, spawn_shell, get_unused_port,
-                  create_impala_shell_executable_dimension, get_impala_shell_executable)
+from tests.shell.util import (assert_var_substitution, ImpalaShell, get_impalad_port,
+  get_shell_cmd, get_open_sessions_metric, spawn_shell, get_unused_port,
+  create_impala_shell_executable_dimension, get_impala_shell_executable)
 import SimpleHTTPServer
 import SocketServer
 
diff --git a/tests/shell/util.py b/tests/shell/util.py
index 2097eabd3..fe30b83a7 100755
--- a/tests/shell/util.py
+++ b/tests/shell/util.py
@@ -18,7 +18,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import socket
diff --git a/tests/statestore/test_statestore.py b/tests/statestore/test_statestore.py
index 5dfead822..55cbf9b93 100644
--- a/tests/statestore/test_statestore.py
+++ b/tests/statestore/test_statestore.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from collections import defaultdict
 import json
 import logging
diff --git a/tests/stress/concurrent_select.py b/tests/stress/concurrent_select.py
index bb2d96829..7fa6f6d28 100755
--- a/tests/stress/concurrent_select.py
+++ b/tests/stress/concurrent_select.py
@@ -55,7 +55,7 @@
 #  8) Verify the result set hash of successful queries if there are no DML queries in the
 #     current run.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import logging
 import os
@@ -968,7 +968,7 @@ def populate_runtime_info(query, impala, converted_args, timeout_secs=maxint):
         return
     reports = reports_by_outcome[leading_outcome]
     reports.sort(key=lambda r: r.runtime_secs)
-    return reports[len(reports) / 2]
+    return reports[len(reports) // 2]
 
   if not any((old_required_mem_mb_with_spilling, old_required_mem_mb_without_spilling)):
     mem_estimate = estimate_query_mem_mb_usage(query, runner.impalad_conn)
@@ -1001,7 +1001,7 @@ def populate_runtime_info(query, impala, converted_args, timeout_secs=maxint):
       mem_limit = old_required_mem_mb_without_spilling
       old_required_mem_mb_without_spilling = None
     else:
-      mem_limit = (lower_bound + upper_bound) / 2
+      mem_limit = (lower_bound + upper_bound) // 2
     LOG.info("Next mem_limit: {0}".format(mem_limit))
     should_break = mem_limit / float(upper_bound) > 1 - mem_limit_eq_threshold_percent \
         or upper_bound - mem_limit < mem_limit_eq_threshold_mb
@@ -1038,7 +1038,7 @@ def populate_runtime_info(query, impala, converted_args, timeout_secs=maxint):
       mem_limit = old_required_mem_mb_with_spilling
       old_required_mem_mb_with_spilling = None
     else:
-      mem_limit = (lower_bound + upper_bound) / 2
+      mem_limit = (lower_bound + upper_bound) // 2
     LOG.info("Next mem_limit: {0}".format(mem_limit))
     should_break = mem_limit / float(upper_bound) > 1 - mem_limit_eq_threshold_percent \
         or upper_bound - mem_limit < mem_limit_eq_threshold_mb
diff --git a/tests/stress/extract_min_mem.py b/tests/stress/extract_min_mem.py
index 5749d164f..22301441c 100755
--- a/tests/stress/extract_min_mem.py
+++ b/tests/stress/extract_min_mem.py
@@ -33,7 +33,7 @@
 #
 #   ./tests/stress/extract_min_mem.py mem_usage_scaling_runtime_info.json
 #
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import json
 import sys
 
diff --git a/tests/stress/mem_broker.py b/tests/stress/mem_broker.py
index cd2c83fff..e844cbe05 100644
--- a/tests/stress/mem_broker.py
+++ b/tests/stress/mem_broker.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 from contextlib import contextmanager
diff --git a/tests/stress/queries.py b/tests/stress/queries.py
index 62b703886..c4c01a783 100644
--- a/tests/stress/queries.py
+++ b/tests/stress/queries.py
@@ -20,6 +20,7 @@
 # This module implements helpers for representing queries to be executed by the
 # stress test, loading them and generating them.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 from textwrap import dedent
diff --git a/tests/stress/query_retries_stress_runner.py b/tests/stress/query_retries_stress_runner.py
index f0876e1bc..d21496a83 100755
--- a/tests/stress/query_retries_stress_runner.py
+++ b/tests/stress/query_retries_stress_runner.py
@@ -24,6 +24,7 @@
 # TODO: Make the script cancellable; more of a nice to have, but Ctrl+C does not kill
 # the script, it has to be killed manually (e.g. kill [pid]).
 
+from __future__ import absolute_import, division, print_function
 import logging
 import pipes
 import os
diff --git a/tests/stress/query_runner.py b/tests/stress/query_runner.py
index 524cf07ff..26a99fbca 100644
--- a/tests/stress/query_runner.py
+++ b/tests/stress/query_runner.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 from multiprocessing import Value
 import os
diff --git a/tests/stress/runtime_info.py b/tests/stress/runtime_info.py
index d9ac7c757..a10692a22 100644
--- a/tests/stress/runtime_info.py
+++ b/tests/stress/runtime_info.py
@@ -20,7 +20,7 @@
 # Utility functions used by the stress test to save and load runtime info
 # about queries to and from JSON files.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from collections import defaultdict
 import json
 import logging
diff --git a/tests/stress/stress_util.py b/tests/stress/stress_util.py
index 7163515da..6bd8faa1c 100644
--- a/tests/stress/stress_util.py
+++ b/tests/stress/stress_util.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import time
 import traceback
 
diff --git a/tests/stress/test_acid_stress.py b/tests/stress/test_acid_stress.py
index 6ba33d65f..49b94b2db 100644
--- a/tests/stress/test_acid_stress.py
+++ b/tests/stress/test_acid_stress.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import random
 import time
diff --git a/tests/stress/test_ddl_stress.py b/tests/stress/test_ddl_stress.py
index 16d71a6fe..09480b315 100644
--- a/tests/stress/test_ddl_stress.py
+++ b/tests/stress/test_ddl_stress.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 
 from tests.common.impala_test_suite import ImpalaTestSuite
diff --git a/tests/stress/test_insert_stress.py b/tests/stress/test_insert_stress.py
index 3b5af90d5..93eaf91d6 100644
--- a/tests/stress/test_insert_stress.py
+++ b/tests/stress/test_insert_stress.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import pytest
 import random
 import time
diff --git a/tests/stress/util.py b/tests/stress/util.py
index 00b581503..1b3d9fe42 100644
--- a/tests/stress/util.py
+++ b/tests/stress/util.py
@@ -19,7 +19,7 @@
 
 # Utility functions used by the stress test that don't fit in the other modules.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 
 import sys
 import threading
diff --git a/tests/unittests/test_command.py b/tests/unittests/test_command.py
index a2a9e4c74..2ab58f92d 100644
--- a/tests/unittests/test_command.py
+++ b/tests/unittests/test_command.py
@@ -17,6 +17,7 @@
 #
 # Unit tests for collect_diagnostics.Command
 
+from __future__ import absolute_import, division, print_function
 import os
 import pytest
 import sys
diff --git a/tests/unittests/test_file_parser.py b/tests/unittests/test_file_parser.py
index 5e79eae1e..e6f7a935e 100644
--- a/tests/unittests/test_file_parser.py
+++ b/tests/unittests/test_file_parser.py
@@ -17,7 +17,7 @@
 
 # Unit tests for the test file parser
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from tests.common.base_test_suite import BaseTestSuite
 from tests.util.test_file_parser import parse_test_file_text
 
diff --git a/tests/unittests/test_result_verifier.py b/tests/unittests/test_result_verifier.py
index 94d2fd917..9142ca1a8 100644
--- a/tests/unittests/test_result_verifier.py
+++ b/tests/unittests/test_result_verifier.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.test_dimensions import create_uncompressed_text_dimension
 from tests.common.test_result_verifier import create_query_result
diff --git a/tests/util/acid_txn.py b/tests/util/acid_txn.py
index 0bc82125b..f1830f2db 100644
--- a/tests/util/acid_txn.py
+++ b/tests/util/acid_txn.py
@@ -15,7 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 from tests.util.thrift_util import create_transport
 from hive_metastore import ThriftHiveMetastore
 from hive_metastore.ttypes import (AbortTxnRequest, AllocateTableWriteIdsRequest,
diff --git a/tests/util/adls_util.py b/tests/util/adls_util.py
index 3b9ea0f8e..b236a488f 100644
--- a/tests/util/adls_util.py
+++ b/tests/util/adls_util.py
@@ -20,6 +20,7 @@
 # This file uses the azure-data-lake-store-python client and provides simple
 # functions to the Impala test suite to access Azure Data Lake Store.
 
+from __future__ import absolute_import, division, print_function
 from azure.datalake.store import core, lib, multithread, exceptions
 from tests.util.filesystem_base import BaseFilesystem
 from tests.util.filesystem_utils import ADLS_CLIENT_ID, ADLS_TENANT_ID, ADLS_CLIENT_SECRET
diff --git a/tests/util/auto_scaler.py b/tests/util/auto_scaler.py
index 1236aaa84..79b87294b 100755
--- a/tests/util/auto_scaler.py
+++ b/tests/util/auto_scaler.py
@@ -17,6 +17,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import argparse
 import time
 import logging
@@ -56,7 +57,7 @@ class AutoScaler(object):
       self.start_batch_size = start_batch_size
     # Maximum number of executor groups. We only have 10 TCP ports free on our
     # miniclusters and we need one for the dedicated coordinator.
-    self.max_groups = 9 / self.group_size
+    self.max_groups = 9 // self.group_size
     # max_groups can further bound the maximum number of groups we are going to start,
     # but we won't start more than possible.
     if max_groups > 0 and max_groups < self.max_groups:
diff --git a/tests/util/calculation_util.py b/tests/util/calculation_util.py
index 263d7e3e1..657c40a92 100644
--- a/tests/util/calculation_util.py
+++ b/tests/util/calculation_util.py
@@ -20,6 +20,7 @@
 # are simple enough that it is better to implement them ourselves to avoid extra
 # dependencies.
 
+from __future__ import absolute_import, division, print_function
 import math
 import random
 import string
@@ -38,9 +39,9 @@ def calculate_median(values):
   sorted_values = sorted(values)
   length = len(sorted_values)
   if length % 2 == 0:
-    return (sorted_values[length / 2] + sorted_values[length / 2 - 1]) / 2
+    return (sorted_values[length // 2] + sorted_values[length // 2 - 1]) / 2
   else:
-    return sorted_values[length / 2]
+    return sorted_values[length // 2]
 
 def calculate_geomean(values):
   """ Calculates the geometric mean of the given collection of numerics """
diff --git a/tests/util/cancel_util.py b/tests/util/cancel_util.py
index 7e7bf15ec..60dabc4c5 100644
--- a/tests/util/cancel_util.py
+++ b/tests/util/cancel_util.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import threading
 from time import sleep
 from tests.beeswax.impala_beeswax import ImpalaBeeswaxException
diff --git a/tests/util/cluster_controller.py b/tests/util/cluster_controller.py
index 388fa4936..048507b21 100644
--- a/tests/util/cluster_controller.py
+++ b/tests/util/cluster_controller.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 try:
   import fabric.decorators
   from fabric.context_managers import hide, settings
diff --git a/tests/util/compute_table_stats.py b/tests/util/compute_table_stats.py
index f982802bb..bb25e6c67 100755
--- a/tests/util/compute_table_stats.py
+++ b/tests/util/compute_table_stats.py
@@ -19,6 +19,7 @@
 #
 # Utility for computing table statistics of tables in the Hive Metastore
 
+from __future__ import absolute_import, division, print_function
 from contextlib import contextmanager
 from optparse import OptionParser
 import logging
diff --git a/tests/util/concurrent_workload.py b/tests/util/concurrent_workload.py
index b9828066c..025f67da7 100755
--- a/tests/util/concurrent_workload.py
+++ b/tests/util/concurrent_workload.py
@@ -19,6 +19,7 @@
 
 # This class can be used to drive a concurrent workload against a local minicluster
 
+from __future__ import absolute_import, division, print_function
 import argparse
 import logging
 # Needed to work around datetime threading bug:
diff --git a/tests/util/event_processor_utils.py b/tests/util/event_processor_utils.py
index 261440cdc..4d2703cb1 100644
--- a/tests/util/event_processor_utils.py
+++ b/tests/util/event_processor_utils.py
@@ -19,6 +19,7 @@
 # modifies the metadata via Hive and checks that the modification
 # succeeded by querying Impala, or vice versa.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import requests
 import time
diff --git a/tests/util/failpoints_util.py b/tests/util/failpoints_util.py
index 2970567c6..de3f43666 100644
--- a/tests/util/failpoints_util.py
+++ b/tests/util/failpoints_util.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite, LOG
 
 
diff --git a/tests/util/filesystem_base.py b/tests/util/filesystem_base.py
index 037eefccf..8f479bcb6 100644
--- a/tests/util/filesystem_base.py
+++ b/tests/util/filesystem_base.py
@@ -17,6 +17,7 @@
 #
 # Filsystem access abstraction
 
+from __future__ import absolute_import, division, print_function
 from abc import ABCMeta, abstractmethod
 
 class BaseFilesystem(object):
diff --git a/tests/util/filesystem_utils.py b/tests/util/filesystem_utils.py
index fe13a807e..a3114e18b 100644
--- a/tests/util/filesystem_utils.py
+++ b/tests/util/filesystem_utils.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 # Utilities for supporting different filesystems.
+from __future__ import absolute_import, division, print_function
 import os
 
 # FILESYSTEM_PREFIX is the path prefix that should be used in queries.  When running
diff --git a/tests/util/get_parquet_metadata.py b/tests/util/get_parquet_metadata.py
index db4ef3f41..21099acb9 100644
--- a/tests/util/get_parquet_metadata.py
+++ b/tests/util/get_parquet_metadata.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import os
 import struct
 
diff --git a/tests/util/hdfs_util.py b/tests/util/hdfs_util.py
index 9afdf640c..ef5a0c38c 100644
--- a/tests/util/hdfs_util.py
+++ b/tests/util/hdfs_util.py
@@ -17,6 +17,7 @@
 #
 # Hdfs access utilities
 
+from __future__ import absolute_import, division, print_function
 import getpass
 import httplib
 import os.path
diff --git a/tests/util/iceberg_util.py b/tests/util/iceberg_util.py
index 9418638e3..924b5e249 100644
--- a/tests/util/iceberg_util.py
+++ b/tests/util/iceberg_util.py
@@ -14,6 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from __future__ import absolute_import, division, print_function
 import datetime
 
 
diff --git a/tests/util/parse_util.py b/tests/util/parse_util.py
index 97c1c5c5b..46a995a96 100644
--- a/tests/util/parse_util.py
+++ b/tests/util/parse_util.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import re
 from datetime import datetime
 
diff --git a/tests/util/plugin_runner.py b/tests/util/plugin_runner.py
index 2f2849f15..e16a28ac6 100644
--- a/tests/util/plugin_runner.py
+++ b/tests/util/plugin_runner.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import pkgutil
diff --git a/tests/util/run_impyla_http_query.py b/tests/util/run_impyla_http_query.py
index df81f8793..98f95d899 100755
--- a/tests/util/run_impyla_http_query.py
+++ b/tests/util/run_impyla_http_query.py
@@ -20,7 +20,7 @@
 # It can be used by other tests (e.g. LdapImpylaHttpTest.java) that start a cluster with
 # an LDAP server to validate Impyla's functionality.
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import argparse
 import logging
 
diff --git a/tests/util/shell_util.py b/tests/util/shell_util.py
index ddbd24b1c..17e19886c 100644
--- a/tests/util/shell_util.py
+++ b/tests/util/shell_util.py
@@ -17,6 +17,7 @@
 #
 # Utility functions related to executing shell commands.
 
+from __future__ import absolute_import, division, print_function
 import logging
 import os
 import shlex
diff --git a/tests/util/ssh_util.py b/tests/util/ssh_util.py
index a26f1bcf9..67b33889e 100644
--- a/tests/util/ssh_util.py
+++ b/tests/util/ssh_util.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import atexit
 import logging
 import os
diff --git a/tests/util/test_file_parser.py b/tests/util/test_file_parser.py
index 26516600c..91973c457 100644
--- a/tests/util/test_file_parser.py
+++ b/tests/util/test_file_parser.py
@@ -17,7 +17,7 @@
 
 # This module is used for common utilities related to parsing test files
 
-from __future__ import print_function
+from __future__ import absolute_import, division, print_function
 import codecs
 import collections
 import logging
diff --git a/tests/util/thrift_util.py b/tests/util/thrift_util.py
index e5f9360c7..8baff3334 100644
--- a/tests/util/thrift_util.py
+++ b/tests/util/thrift_util.py
@@ -16,6 +16,7 @@
 # under the License.
 #
 # Thrift utility functions
+from __future__ import absolute_import, division, print_function
 import getpass
 import sasl
 import struct
diff --git a/tests/util/web_pages_util.py b/tests/util/web_pages_util.py
index 317289e7b..a8b6b37a5 100644
--- a/tests/util/web_pages_util.py
+++ b/tests/util/web_pages_util.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 import json
 
 
diff --git a/tests/verifiers/mem_usage_verifier.py b/tests/verifiers/mem_usage_verifier.py
index 644e5fa69..0bcd40b55 100644
--- a/tests/verifiers/mem_usage_verifier.py
+++ b/tests/verifiers/mem_usage_verifier.py
@@ -17,6 +17,7 @@
 #
 # Verifier for memtracker usage values (Total, Peak, etc).
 
+from __future__ import absolute_import, division, print_function
 import re
 
 SIZE_FACTORS = {"b": 1, "kb": 1 << 10, "mb": 1 << 20, "gb": 1 << 30}
diff --git a/tests/verifiers/metric_verifier.py b/tests/verifiers/metric_verifier.py
index 59848b303..c8ee696d7 100644
--- a/tests/verifiers/metric_verifier.py
+++ b/tests/verifiers/metric_verifier.py
@@ -17,6 +17,7 @@
 #
 # Verifier for common impalad metrics
 
+from __future__ import absolute_import, division, print_function
 import logging
 from time import time, sleep
 
diff --git a/tests/verifiers/test_verify_metrics.py b/tests/verifiers/test_verify_metrics.py
index 8db6811a7..984beb05c 100644
--- a/tests/verifiers/test_verify_metrics.py
+++ b/tests/verifiers/test_verify_metrics.py
@@ -17,6 +17,7 @@
 #
 # Verification of impalad metrics after a test run.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.impala_test_suite import ImpalaTestSuite
 from tests.common.impala_cluster import ImpalaCluster
 from tests.verifiers.metric_verifier import MetricVerifier
diff --git a/tests/webserver/test_web_pages.py b/tests/webserver/test_web_pages.py
index 544e8c3d3..e1383a9aa 100644
--- a/tests/webserver/test_web_pages.py
+++ b/tests/webserver/test_web_pages.py
@@ -15,6 +15,7 @@
 # specific language governing permissions and limitations
 # under the License.
 
+from __future__ import absolute_import, division, print_function
 from tests.common.environ import ImpalaTestClusterFlagsDetector
 from tests.common.file_utils import grep_dir
 from tests.common.skip import SkipIfBuildType, SkipIfDockerizedCluster