Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/great_expectations/self_check/util.py b/great_expectations/self_check/util.py
--- a/great_expectations/self_check/util.py
+++ b/great_expectations/self_check/util.py
@@ -273,6 +273,7 @@
     mssqlDialect = None
     MSSQL_TYPES = {}
 
+import tempfile
 
 SQL_DIALECT_NAMES = (
     "sqlite",
@@ -1580,10 +1581,26 @@ def generate_expectation_tests(
 
         for c in backends:
 
+            datasets = []
+
             try:
-                validator_with_data = get_test_validator_with_data(
-                    c, d["data"], d["schemas"]
-                )
+                if isinstance(d["data"], list):
+                    sqlite_db_path = generate_sqlite_db_path()
+                    for dataset in d["data"]:
+                        datasets.append(
+                            get_test_validator_with_data(
+                                c,
+                                dataset["data"],
+                                dataset.get("schemas"),
+                                table_name=dataset.get("dataset_name"),
+                                sqlite_db_path=sqlite_db_path,
+                            )
+                        )
+                    validator_with_data = datasets[0]
+                else:
+                    validator_with_data = get_test_validator_with_data(
+                        c, d["data"], d["schemas"]
+                    )
             except Exception as e:
                 # Adding these print statements for build_gallery.py's console output
                 print("\n\n[[ Problem calling get_test_validator_with_data ]]")
@@ -2052,3 +2069,25 @@ def _bigquery_dataset() -> str:
             "Environment Variable GE_TEST_BIGQUERY_DATASET is required to run BigQuery expectation tests"
         )
     return dataset
+
+
+def generate_sqlite_db_path():
+    """Creates a temporary directory and absolute path to an ephemeral sqlite_db within that temp directory.
+
+    Used to support testing of multi-table expectations without creating temp directories at import.
+
+    Returns:
+        str: An absolute path to the ephemeral db within the created temporary directory.
+    """
+    tmp_dir = str(tempfile.mkdtemp())
+    abspath = os.path.abspath(
+        os.path.join(
+            tmp_dir,
+            "sqlite_db"
+            + "".join(
+                [random.choice(string.ascii_letters + string.digits) for _ in range(8)]
+            )
+            + ".db",
+        )
+    )
+    return abspath


Test patch:
diff --git a/tests/test_definitions/test_expectations.py b/tests/test_definitions/test_expectations.py
--- a/tests/test_definitions/test_expectations.py
+++ b/tests/test_definitions/test_expectations.py
@@ -4,7 +4,6 @@
 import os
 import random
 import string
-import tempfile
 from collections import OrderedDict
 
 import pandas as pd
@@ -15,6 +14,7 @@
     BigQueryDialect,
     candidate_test_is_on_temporary_notimplemented_list,
     evaluate_json_test,
+    generate_sqlite_db_path,
     get_dataset,
     mssqlDialect,
     mysqlDialect,
@@ -24,7 +24,6 @@
 from tests.conftest import build_test_backends_list
 
 logger = logging.getLogger(__name__)
-tmp_dir = str(tempfile.mkdtemp())
 
 
 def pytest_generate_tests(metafunc):
@@ -74,21 +73,7 @@ def pytest_generate_tests(metafunc):
                     else:
                         skip_expectation = False
                         if isinstance(d["data"], list):
-                            sqlite_db_path = os.path.abspath(
-                                os.path.join(
-                                    tmp_dir,
-                                    "sqlite_db"
-                                    + "".join(
-                                        [
-                                            random.choice(
-                                                string.ascii_letters + string.digits
-                                            )
-                                            for _ in range(8)
-                                        ]
-                                    )
-                                    + ".db",
-                                )
-                            )
+                            sqlite_db_path = generate_sqlite_db_path()
                             for dataset in d["data"]:
                                 datasets.append(
                                     get_dataset(
diff --git a/tests/test_definitions/test_expectations_cfe.py b/tests/test_definitions/test_expectations_cfe.py
--- a/tests/test_definitions/test_expectations_cfe.py
+++ b/tests/test_definitions/test_expectations_cfe.py
@@ -16,6 +16,7 @@
     BigQueryDialect,
     candidate_test_is_on_temporary_notimplemented_list_cfe,
     evaluate_json_test_cfe,
+    generate_sqlite_db_path,
     get_test_validator_with_data,
     mssqlDialect,
     mysqlDialect,
@@ -23,7 +24,6 @@
     sqliteDialect,
 )
 from tests.conftest import build_test_backends_list_cfe
-from tests.test_definitions.test_expectations import tmp_dir
 
 
 def pytest_generate_tests(metafunc):
@@ -71,21 +71,7 @@ def pytest_generate_tests(metafunc):
                     else:
                         skip_expectation = False
                         if isinstance(d["data"], list):
-                            sqlite_db_path = os.path.abspath(
-                                os.path.join(
-                                    tmp_dir,
-                                    "sqlite_db"
-                                    + "".join(
-                                        [
-                                            random.choice(
-                                                string.ascii_letters + string.digits
-                                            )
-                                            for _ in range(8)
-                                        ]
-                                    )
-                                    + ".db",
-                                )
-                            )
+                            sqlite_db_path = generate_sqlite_db_path()
                             for dataset in d["data"]:
                                 datasets.append(
                                     get_test_validator_with_data(