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/core/batch.py b/great_expectations/core/batch.py
--- a/great_expectations/core/batch.py
+++ b/great_expectations/core/batch.py
@@ -547,12 +547,17 @@ def __init__(
         self._data = data
         if batch_request is None:
             batch_request = {}
+
         self._batch_request = batch_request
+
         if batch_definition is None:
             batch_definition = IDDict()
+
         self._batch_definition = batch_definition
+
         if batch_spec is None:
             batch_spec = BatchSpec()
+
         self._batch_spec = batch_spec
 
         if batch_markers is None:
@@ -563,6 +568,7 @@ def __init__(
                     ).strftime("%Y%m%dT%H%M%S.%fZ")
                 }
             )
+
         self._batch_markers = batch_markers
 
         # The remaining parameters are for backward compatibility.
@@ -645,11 +651,16 @@ def to_json_dict(self) -> dict:
     @property
     def id(self):
         batch_definition = self._batch_definition
-        return (
-            batch_definition.id
-            if isinstance(batch_definition, BatchDefinition)
-            else batch_definition.to_id()
-        )
+        if isinstance(batch_definition, BatchDefinition):
+            return batch_definition.id
+
+        if isinstance(batch_definition, IDDict):
+            return batch_definition.to_id()
+
+        if isinstance(batch_definition, dict):
+            return IDDict(batch_definition).to_id()
+
+        return IDDict({}).to_id()
 
     def __str__(self):
         return json.dumps(self.to_json_dict(), indent=2)


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2232,10 +2232,6 @@ def data_context_with_simple_sql_datasource_for_testing_get_batch(
 
 @pytest.fixture
 def basic_datasource(tmp_path_factory):
-    base_directory: str = str(
-        tmp_path_factory.mktemp("basic_datasource_runtime_data_connector")
-    )
-
     basic_datasource: Datasource = instantiate_class_from_config(
         config=yaml.load(
             """
diff --git a/tests/expectations/metrics/test_map_metric.py b/tests/expectations/metrics/test_map_metric.py
--- a/tests/expectations/metrics/test_map_metric.py
+++ b/tests/expectations/metrics/test_map_metric.py
@@ -5,11 +5,14 @@
 from great_expectations.core import (
     ExpectationConfiguration,
     ExpectationValidationResult,
+    IDDict,
 )
-from great_expectations.core.batch import Batch, BatchRequest
+from great_expectations.core.batch import Batch, BatchDefinition, BatchRequest
 from great_expectations.core.batch_spec import SqlAlchemyDatasourceBatchSpec
 from great_expectations.core.util import convert_to_json_serializable
+from great_expectations.data_context import AbstractDataContext
 from great_expectations.data_context.util import file_relative_path
+from great_expectations.datasource import Datasource
 from great_expectations.datasource.data_connector import ConfiguredAssetSqlDataConnector
 from great_expectations.execution_engine import (
     PandasExecutionEngine,
@@ -155,7 +158,9 @@ def expected_evr_without_unexpected_rows():
 
 
 def _expecation_configuration_to_validation_result_pandas(
-    expectation_configuration: ExpectationConfiguration, dataframe: pd.DataFrame
+    expectation_configuration: ExpectationConfiguration,
+    dataframe: pd.DataFrame,
+    context: AbstractDataContext,
 ) -> ExpectationValidationResult:
     """
     Helper method used by pandas tests in this suite. Takes in a ExpectationConfiguration and returns an EVR
@@ -166,10 +171,21 @@ def _expecation_configuration_to_validation_result_pandas(
 
     """
     expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=dataframe)
+    batch_definition = BatchDefinition(
+        datasource_name="pandas_datasource",
+        data_connector_name="runtime_data_connector",
+        data_asset_name="my_asset",
+        batch_identifiers=IDDict({}),
+        batch_spec_passthrough=None,
+    )
+    batch = Batch(
+        data=dataframe,
+        batch_definition=batch_definition,
+    )
     engine = PandasExecutionEngine()
     validator = Validator(
         execution_engine=engine,
+        data_context=context,
         batches=[
             batch,
         ],
@@ -180,6 +196,7 @@ def _expecation_configuration_to_validation_result_pandas(
 
 def _expecation_configuration_to_validation_result_sql(
     expectation_configuration: ExpectationConfiguration,
+    context: AbstractDataContext,
 ) -> ExpectationValidationResult:
     """
     Helper method used by sql tests in this suite. Takes in a ExpectationConfiguration and returns an EVR
@@ -192,7 +209,10 @@ def _expecation_configuration_to_validation_result_sql(
     expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
     sqlite_path = file_relative_path(__file__, "../../test_sets/metrics_test.db")
     connection_string = f"sqlite:///{sqlite_path}"
-    engine = SqlAlchemyExecutionEngine(connection_string=connection_string)
+    engine = SqlAlchemyExecutionEngine(
+        connection_string=connection_string,
+        create_temp_table=False,
+    )
     execution_engine = engine
     my_data_connector: ConfiguredAssetSqlDataConnector = (
         ConfiguredAssetSqlDataConnector(
@@ -206,6 +226,22 @@ def _expecation_configuration_to_validation_result_sql(
             },
         )
     )
+
+    context.datasources["my_test_datasource"] = Datasource(
+        name="my_test_datasource",
+        execution_engine=execution_engine.config,
+        data_connectors={
+            "my_sql_data_connector": {
+                "class_name": "ConfiguredAssetSqlDataConnector",
+                "assets": {
+                    "my_asset": {
+                        "table_name": "animal_names",
+                    },
+                },
+            },
+        },
+    )
+
     batch_definition_list = (
         my_data_connector.get_batch_definition_list_from_batch_request(
             batch_request=BatchRequest(
@@ -222,8 +258,14 @@ def _expecation_configuration_to_validation_result_sql(
     batch_data, batch_markers = execution_engine.get_batch_data_and_markers(
         batch_spec=batch_spec
     )
-    batch = Batch(data=batch_data)
-    validator = Validator(execution_engine, batches=[batch])
+    batch = Batch(data=batch_data, batch_definition=batch_definition_list[0])
+    validator = Validator(
+        execution_engine=engine,
+        data_context=context,
+        batches=[
+            batch,
+        ],
+    )
     result = expectation.validate(validator)
     return result
 
@@ -353,6 +395,7 @@ def test_is_sqlalchemy_metric_selectable():
 
 
 def test_pandas_unexpected_rows_basic_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -367,18 +410,13 @@ def test_pandas_unexpected_rows_basic_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -397,6 +435,7 @@ def test_pandas_unexpected_rows_basic_result_format(
 
 
 def test_pandas_unexpected_rows_summary_result_format_unexpected_rows_explicitly_false(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -411,18 +450,13 @@ def test_pandas_unexpected_rows_summary_result_format_unexpected_rows_explicitly
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -442,6 +476,7 @@ def test_pandas_unexpected_rows_summary_result_format_unexpected_rows_explicitly
 
 
 def test_pandas_unexpected_rows_summary_result_format_unexpected_rows_including_unexpected_rows(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -456,18 +491,13 @@ def test_pandas_unexpected_rows_summary_result_format_unexpected_rows_including_
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -492,6 +522,7 @@ def test_pandas_unexpected_rows_summary_result_format_unexpected_rows_including_
 
 
 def test_pandas_unexpected_rows_complete_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -505,17 +536,13 @@ def test_pandas_unexpected_rows_complete_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -542,6 +569,7 @@ def test_pandas_unexpected_rows_complete_result_format(
 
 
 def test_pandas_default_complete_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -554,17 +582,13 @@ def test_pandas_default_complete_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -586,6 +610,7 @@ def test_pandas_default_complete_result_format(
 
 
 def test_pandas_single_unexpected_index_column_names_complete_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -599,17 +624,13 @@ def test_pandas_single_unexpected_index_column_names_complete_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -639,6 +660,7 @@ def test_pandas_single_unexpected_index_column_names_complete_result_format(
 
 
 def test_pandas_multiple_unexpected_index_column_names_complete_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -652,17 +674,13 @@ def test_pandas_multiple_unexpected_index_column_names_complete_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -692,6 +710,7 @@ def test_pandas_multiple_unexpected_index_column_names_complete_result_format(
 
 
 def test_pandas_multiple_unexpected_index_column_names_complete_result_format_limit_1(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -706,17 +725,13 @@ def test_pandas_multiple_unexpected_index_column_names_complete_result_format_li
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -738,6 +753,7 @@ def test_pandas_multiple_unexpected_index_column_names_complete_result_format_li
 
 
 def test_pandas_multiple_unexpected_index_column_names_summary_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -751,17 +767,13 @@ def test_pandas_multiple_unexpected_index_column_names_summary_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -785,6 +797,7 @@ def test_pandas_multiple_unexpected_index_column_names_summary_result_format(
 
 
 def test_pandas_multiple_unexpected_index_column_names_summary_result_format_limit_1(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -799,17 +812,13 @@ def test_pandas_multiple_unexpected_index_column_names_summary_result_format_lim
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -827,6 +836,7 @@ def test_pandas_multiple_unexpected_index_column_names_summary_result_format_lim
 
 
 def test_pandas_multiple_unexpected_index_column_names_basic_result_format(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -840,17 +850,13 @@ def test_pandas_multiple_unexpected_index_column_names_basic_result_format(
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -864,6 +870,7 @@ def test_pandas_multiple_unexpected_index_column_names_basic_result_format(
 
 
 def test_pandas_single_unexpected_index_column_names_complete_result_format_non_existing_column(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -877,17 +884,13 @@ def test_pandas_single_unexpected_index_column_names_complete_result_format_non_
             },
         },
     )
-
-    expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
-    engine = PandasExecutionEngine()
-    validator = Validator(
-        execution_engine=engine,
-        batches=[
-            batch,
-        ],
+    result: ExpectationValidationResult = (
+        _expecation_configuration_to_validation_result_pandas(
+            expectation_configuration=expectation_configuration,
+            dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
+        )
     )
-    result = expectation.validate(validator)
     assert result.success is False
     assert result.exception_info
     assert (
@@ -897,6 +900,7 @@ def test_pandas_single_unexpected_index_column_names_complete_result_format_non_
 
 
 def test_pandas_multiple_unexpected_index_column_names_complete_result_format_non_existing_column(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index: pd.DataFrame,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -917,6 +921,7 @@ def test_pandas_multiple_unexpected_index_column_names_complete_result_format_no
         _expecation_configuration_to_validation_result_pandas(
             expectation_configuration=expectation_configuration,
             dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
         )
     )
     assert result.success is False
@@ -928,6 +933,7 @@ def test_pandas_multiple_unexpected_index_column_names_complete_result_format_no
 
 
 def test_pandas_default_to_not_include_unexpected_rows(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
     expected_evr_without_unexpected_rows,
 ):
@@ -941,17 +947,18 @@ def test_pandas_default_to_not_include_unexpected_rows(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_pandas(
             expectation_configuration=expectation_configuration,
             dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
         )
     )
     assert result.result == expected_evr_without_unexpected_rows.result
 
 
 def test_pandas_specify_not_include_unexpected_rows(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
     expected_evr_without_unexpected_rows,
 ):
@@ -966,17 +973,18 @@ def test_pandas_specify_not_include_unexpected_rows(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_pandas(
             expectation_configuration=expectation_configuration,
             dataframe=pandas_animals_dataframe_for_unexpected_rows_and_index,
+            context=in_memory_runtime_context,
         )
     )
     assert result.result == expected_evr_without_unexpected_rows.result
 
 
 def test_include_unexpected_rows_without_explicit_result_format_raises_error(
+    in_memory_runtime_context,
     pandas_animals_dataframe_for_unexpected_rows_and_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -991,10 +999,21 @@ def test_include_unexpected_rows_without_explicit_result_format_raises_error(
     )
 
     expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch = Batch(data=pandas_animals_dataframe_for_unexpected_rows_and_index)
+    batch_definition = BatchDefinition(
+        datasource_name="pandas_datasource",
+        data_connector_name="runtime_data_connector",
+        data_asset_name="my_asset",
+        batch_identifiers=IDDict({}),
+        batch_spec_passthrough=None,
+    )
+    batch = Batch(
+        data=pandas_animals_dataframe_for_unexpected_rows_and_index,
+        batch_definition=batch_definition,
+    )
     engine = PandasExecutionEngine()
     validator = Validator(
         execution_engine=engine,
+        data_context=in_memory_runtime_context,
         batches=[
             batch,
         ],
@@ -1005,6 +1024,7 @@ def test_include_unexpected_rows_without_explicit_result_format_raises_error(
 
 # Spark
 def test_spark_single_column_complete_result_format(
+    in_memory_runtime_context,
     spark_dataframe_for_unexpected_rows_with_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -1018,10 +1038,21 @@ def test_spark_single_column_complete_result_format(
         },
     )
     expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=spark_dataframe_for_unexpected_rows_with_index)
+    batch_definition = BatchDefinition(
+        datasource_name="spark_datasource",
+        data_connector_name="runtime_data_connector",
+        data_asset_name="my_asset",
+        batch_identifiers=IDDict({}),
+        batch_spec_passthrough=None,
+    )
+    batch = Batch(
+        data=spark_dataframe_for_unexpected_rows_with_index,
+        batch_definition=batch_definition,
+    )
     engine = SparkDFExecutionEngine()
     validator = Validator(
         execution_engine=engine,
+        data_context=in_memory_runtime_context,
         batches=[
             batch,
         ],
@@ -1046,6 +1077,7 @@ def test_spark_single_column_complete_result_format(
 
 
 def test_spark_single_column_summary_result_format(
+    in_memory_runtime_context,
     spark_dataframe_for_unexpected_rows_with_index,
 ):
     expectation_configuration = ExpectationConfiguration(
@@ -1059,10 +1091,21 @@ def test_spark_single_column_summary_result_format(
         },
     )
     expectation = ExpectColumnValuesToBeInSet(expectation_configuration)
-    batch: Batch = Batch(data=spark_dataframe_for_unexpected_rows_with_index)
+    batch_definition = BatchDefinition(
+        datasource_name="spark_datasource",
+        data_connector_name="runtime_data_connector",
+        data_asset_name="my_asset",
+        batch_identifiers=IDDict({}),
+        batch_spec_passthrough=None,
+    )
+    batch = Batch(
+        data=spark_dataframe_for_unexpected_rows_with_index,
+        batch_definition=batch_definition,
+    )
     engine = SparkDFExecutionEngine()
     validator = Validator(
         execution_engine=engine,
+        data_context=in_memory_runtime_context,
         batches=[
             batch,
         ],
@@ -1086,7 +1129,9 @@ def test_spark_single_column_summary_result_format(
 
 
 def test_sqlite_single_column_complete_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa,
+    in_memory_runtime_context,
+    sqlite_table_for_unexpected_rows_with_index,
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1100,7 +1145,8 @@ def test_sqlite_single_column_complete_result_format(
     )
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
     assert convert_to_json_serializable(result.result) == {
@@ -1122,7 +1168,7 @@ def test_sqlite_single_column_complete_result_format(
 
 
 def test_sqlite_single_column_summary_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1134,45 +1180,12 @@ def test_sqlite_single_column_summary_result_format(
             },
         },
     )
-    result = _expecation_configuration_to_validation_result_sql(
-        expectation_configuration=expectation_configuration
-    )
-    assert convert_to_json_serializable(result.result) == {
-        "element_count": 6,
-        "missing_count": 0,
-        "missing_percent": 0.0,
-        "partial_unexpected_counts": [
-            {"count": 1, "value": "giraffe"},
-            {"count": 1, "value": "lion"},
-            {"count": 1, "value": "zebra"},
-        ],
-        "partial_unexpected_list": ["giraffe", "lion", "zebra"],
-        "unexpected_count": 3,
-        "unexpected_percent": 50.0,
-        "unexpected_percent_nonmissing": 50.0,
-        "unexpected_percent_total": 50.0,
-    }
-
-
-def test_sqlite_single_column_complete_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
-):
-    expectation_configuration = ExpectationConfiguration(
-        expectation_type="expect_column_values_to_be_in_set",
-        kwargs={
-            "column": "animals",
-            "value_set": ["cat", "fish", "dog"],
-            "result_format": {
-                "result_format": "COMPLETE",
-            },
-        },
-    )
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -1184,7 +1197,6 @@ def test_sqlite_single_column_complete_result_format(
         ],
         "partial_unexpected_list": ["giraffe", "lion", "zebra"],
         "unexpected_count": 3,
-        "unexpected_list": ["giraffe", "lion", "zebra"],
         "unexpected_percent": 50.0,
         "unexpected_percent_nonmissing": 50.0,
         "unexpected_percent_total": 50.0,
@@ -1192,7 +1204,7 @@ def test_sqlite_single_column_complete_result_format(
 
 
 def test_sqlite_single_unexpected_index_column_names_complete_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1205,13 +1217,12 @@ def test_sqlite_single_unexpected_index_column_names_complete_result_format(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -1237,7 +1248,7 @@ def test_sqlite_single_unexpected_index_column_names_complete_result_format(
 
 
 def test_sqlite_single_unexpected_index_column_names_summary_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1250,13 +1261,12 @@ def test_sqlite_single_unexpected_index_column_names_summary_result_format(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -1276,7 +1286,7 @@ def test_sqlite_single_unexpected_index_column_names_summary_result_format(
 
 
 def test_sqlite_multiple_unexpected_index_column_names_complete_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1289,13 +1299,12 @@ def test_sqlite_multiple_unexpected_index_column_names_complete_result_format(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -1329,7 +1338,7 @@ def test_sqlite_multiple_unexpected_index_column_names_complete_result_format(
 
 
 def test_sql_multiple_unexpected_index_column_names_complete_result_format_limit_1(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1343,13 +1352,12 @@ def test_sql_multiple_unexpected_index_column_names_complete_result_format_limit
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
-
     assert convert_to_json_serializable(result.result) == {
         "element_count": 6,
         "missing_count": 0,
@@ -1373,7 +1381,7 @@ def test_sql_multiple_unexpected_index_column_names_complete_result_format_limit
 
 
 def test_sql_multiple_unexpected_index_column_names_summary_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1386,10 +1394,10 @@ def test_sql_multiple_unexpected_index_column_names_summary_result_format(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
     assert convert_to_json_serializable(result.result) == {
@@ -1415,7 +1423,7 @@ def test_sql_multiple_unexpected_index_column_names_summary_result_format(
 
 
 def test_sql_multiple_unexpected_index_column_names_summary_result_format_limit_1(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
 
     expectation_configuration = ExpectationConfiguration(
@@ -1430,10 +1438,10 @@ def test_sql_multiple_unexpected_index_column_names_summary_result_format_limit_
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
     assert convert_to_json_serializable(result.result) == {
@@ -1451,7 +1459,7 @@ def test_sql_multiple_unexpected_index_column_names_summary_result_format_limit_
 
 
 def test_sql_multiple_unexpected_index_column_names_basic_result_format(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1464,10 +1472,10 @@ def test_sql_multiple_unexpected_index_column_names_basic_result_format(
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
     assert convert_to_json_serializable(result.result) == {
@@ -1483,7 +1491,7 @@ def test_sql_multiple_unexpected_index_column_names_basic_result_format(
 
 
 def test_sql_single_unexpected_index_column_names_complete_result_format_non_existing_column(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1496,10 +1504,10 @@ def test_sql_single_unexpected_index_column_names_complete_result_format_non_exi
             },
         },
     )
-
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
     assert result.success is False
@@ -1511,7 +1519,7 @@ def test_sql_single_unexpected_index_column_names_complete_result_format_non_exi
 
 
 def test_sql_multiple_unexpected_index_column_names_complete_result_format_non_existing_column(
-    sa, sqlite_table_for_unexpected_rows_with_index
+    sa, in_memory_runtime_context, sqlite_table_for_unexpected_rows_with_index
 ):
     expectation_configuration = ExpectationConfiguration(
         expectation_type="expect_column_values_to_be_in_set",
@@ -1529,10 +1537,10 @@ def test_sql_multiple_unexpected_index_column_names_complete_result_format_non_e
     )
     result: ExpectationValidationResult = (
         _expecation_configuration_to_validation_result_sql(
-            expectation_configuration=expectation_configuration
+            expectation_configuration=expectation_configuration,
+            context=in_memory_runtime_context,
         )
     )
-
     assert result.success is False
     assert result.exception_info
     assert (
diff --git a/tests/rule_based_profiler/conftest.py b/tests/rule_based_profiler/conftest.py
--- a/tests/rule_based_profiler/conftest.py
+++ b/tests/rule_based_profiler/conftest.py
@@ -1,7 +1,5 @@
-import datetime
 from typing import Any, Dict
 
-import pandas as pd
 import pytest
 from ruamel.yaml import YAML
 
diff --git a/tests/validator/test_validator.py b/tests/validator/test_validator.py
--- a/tests/validator/test_validator.py
+++ b/tests/validator/test_validator.py
@@ -663,7 +663,8 @@ def test_instantiate_validator_with_a_list_of_batch_requests(
 
 
 @pytest.mark.integration
-def test_graph_validate(basic_datasource):
+def test_graph_validate(in_memory_runtime_context, basic_datasource):
+    in_memory_runtime_context.datasources["my_datasource"] = basic_datasource
     df = pd.DataFrame({"a": [1, 5, 22, 3, 5, 10], "b": [1, 2, 3, 4, 5, None]})
 
     batch = basic_datasource.get_single_batch_from_batch_request(
@@ -694,7 +695,9 @@ def test_graph_validate(basic_datasource):
         },
     )
     result = Validator(
-        execution_engine=PandasExecutionEngine(), batches=[batch]
+        execution_engine=basic_datasource.execution_engine,
+        data_context=in_memory_runtime_context,
+        batches=[batch],
     ).graph_validate(configurations=[expectation_configuration])
     assert result == [
         ExpectationValidationResult(
@@ -717,7 +720,10 @@ def test_graph_validate(basic_datasource):
 
 # Tests that runtime configuration actually works during graph validation
 @pytest.mark.integration
-def test_graph_validate_with_runtime_config(basic_datasource):
+def test_graph_validate_with_runtime_config(
+    in_memory_runtime_context, basic_datasource
+):
+    in_memory_runtime_context.datasources["my_datasource"] = basic_datasource
     df = pd.DataFrame(
         {"a": [1, 5, 22, 3, 5, 10, 2, 3], "b": [97, 332, 3, 4, 5, 6, 7, None]}
     )
@@ -747,7 +753,9 @@ def test_graph_validate_with_runtime_config(basic_datasource):
     try:
         # noinspection PyTypeChecker
         result = Validator(
-            execution_engine=PandasExecutionEngine(), batches=(batch,)
+            execution_engine=basic_datasource.execution_engine,
+            data_context=in_memory_runtime_context,
+            batches=[batch],
         ).graph_validate(
             configurations=[expectation_configuration],
             runtime_configuration={"result_format": "COMPLETE"},
@@ -836,7 +844,10 @@ def mock_error(*args, **kwargs):
 
 
 @pytest.mark.integration
-def test_graph_validate_with_bad_config_catch_exceptions_false(basic_datasource):
+def test_graph_validate_with_bad_config_catch_exceptions_false(
+    in_memory_runtime_context, basic_datasource
+):
+    in_memory_runtime_context.datasources["my_datasource"] = basic_datasource
     df = pd.DataFrame({"a": [1, 5, 22, 3, 5, 10], "b": [1, 2, 3, 4, 5, None]})
 
     batch = basic_datasource.get_single_batch_from_batch_request(
@@ -861,10 +872,16 @@ def test_graph_validate_with_bad_config_catch_exceptions_false(basic_datasource)
         expectation_type="expect_column_max_to_be_between",
         kwargs={"column": "not_in_table", "min_value": 1, "max_value": 29},
     )
-    with pytest.raises(ge_exceptions.MetricResolutionError) as eee:
+    with pytest.raises(
+        tuple(
+            [ge_exceptions.MetricResolutionError, ge_exceptions.ProfilerExecutionError]
+        )
+    ) as eee:
         # noinspection PyUnusedLocal
         result = Validator(
-            execution_engine=PandasExecutionEngine(), batches=[batch]
+            execution_engine=basic_datasource.execution_engine,
+            data_context=in_memory_runtime_context,
+            batches=[batch],
         ).graph_validate(
             configurations=[expectation_configuration],
             runtime_configuration={