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/validator/validator.py b/great_expectations/validator/validator.py
--- a/great_expectations/validator/validator.py
+++ b/great_expectations/validator/validator.py
@@ -208,11 +208,22 @@ def inst_expectation(*args, **kwargs):
                         )
 
                 # this is used so that exceptions are caught appropriately when they occur in expectation config
-                basic_runtime_configuration = {
+                basic_configuration_keys = {
+                    "result_format",
+                    "include_config",
+                    "catch_exceptions",
+                }
+                basic_default_expectation_args = {
                     k: v
-                    for k, v in kwargs.items()
-                    if k in ("result_format", "include_config", "catch_exceptions")
+                    for k, v in self.default_expectation_args.items()
+                    if k in basic_configuration_keys
                 }
+                basic_runtime_configuration = copy.deepcopy(
+                    basic_default_expectation_args
+                )
+                basic_runtime_configuration.update(
+                    {k: v for k, v in kwargs.items() if k in basic_configuration_keys}
+                )
 
                 configuration = ExpectationConfiguration(
                     expectation_type=name, kwargs=expectation_kwargs, meta=meta
@@ -1137,9 +1148,6 @@ def validate(
 
             self._active_validation = True
 
-            if result_format is None:
-                result_format = {"result_format": "BASIC"}
-
             # If a different validation data context was provided, override
             validate__data_context = self._data_context
             if data_context is None and self._data_context is not None:
@@ -1237,12 +1245,17 @@ def validate(
             for col in columns:
                 expectations_to_evaluate.extend(columns[col])
 
+            runtime_configuration = copy.deepcopy(self.default_expectation_args)
+
+            if catch_exceptions is not None:
+                runtime_configuration.update({"catch_exceptions": catch_exceptions})
+
+            if result_format is not None:
+                runtime_configuration.update({"result_format": result_format})
+
             results = self.graph_validate(
                 expectations_to_evaluate,
-                runtime_configuration={
-                    "catch_exceptions": catch_exceptions,
-                    "result_format": result_format,
-                },
+                runtime_configuration=runtime_configuration,
             )
             statistics = _calc_validation_statistics(results)
 


Test patch:
diff --git a/tests/expectations/test_expectation_arguments.py b/tests/expectations/test_expectation_arguments.py
--- a/tests/expectations/test_expectation_arguments.py
+++ b/tests/expectations/test_expectation_arguments.py
@@ -324,3 +324,140 @@ def test_catch_exceptions_exception_occurred_catch_exceptions_true(
     assert "exception_traceback" in result.exception_info
     assert "exception_message" in result.exception_info
     assert result.exception_info["exception_message"] == expected_exception_message
+
+
+def test_result_format_configured_no_set_default_override(
+    in_memory_runtime_context, test_spark_df
+):
+    catch_exceptions: bool = False  # expect exceptions to be raised
+    result_format: str = "SUMMARY"
+    runtime_environment_arguments = {
+        "catch_exceptions": catch_exceptions,
+        "result_format": result_format,
+    }
+
+    expectation_arguments: dict = {
+        "include_config": True,
+        "column": "Name",  # use correct column to avoid error
+    }
+    expectation_meta: dict = {"Notes": "Some notes"}
+
+    expectation_arguments_without_meta: dict = dict(
+        **runtime_environment_arguments, **expectation_arguments
+    )
+
+    expectation_configuration: ExpectationConfiguration = ExpectationConfiguration(
+        expectation_type="expect_column_values_to_not_be_null",
+        kwargs=expectation_arguments_without_meta,
+        meta=expectation_meta,
+    )
+
+    suite: ExpectationSuite = in_memory_runtime_context.create_expectation_suite(
+        "test_suite", overwrite_existing=True
+    )
+    suite.add_expectation(expectation_configuration=expectation_configuration)
+
+    runtime_batch_request = RuntimeBatchRequest(
+        datasource_name="spark_datasource",
+        data_connector_name="runtime_data_connector",
+        data_asset_name="insert_your_data_asset_name_here",
+        runtime_parameters={"batch_data": test_spark_df},
+        batch_identifiers={
+            "id_key_0": "id_value_0",
+            "id_key_1": "id_value_1",
+        },
+    )
+
+    validator: Validator = in_memory_runtime_context.get_validator(
+        batch_request=runtime_batch_request,
+        expectation_suite=suite,
+    )
+
+    # Test calling "validator.validate()" explicitly.
+
+    validator_validation: ExpectationSuiteValidationResult = validator.validate(
+        **runtime_environment_arguments
+    )
+    results: List[ExpectationValidationResult] = validator_validation.results
+    assert len(results) == 1
+
+    result: ExpectationValidationResult = results[0]
+    assert len(result.result.keys()) > 0
+
+    # Test calling "validator.expect_*" through "validator.validate_expectation()".
+
+    expectation_parameters: dict = dict(
+        **expectation_arguments_without_meta, **expectation_meta
+    )
+
+    result: ExpectationValidationResult = validator.expect_column_values_to_not_be_null(
+        **expectation_parameters
+    )
+    assert len(result.result.keys()) > 0
+
+
+def test_result_format_configured_with_set_default_override(
+    in_memory_runtime_context, test_spark_df
+):
+    catch_exceptions: bool = False  # expect exceptions to be raised
+    result_format: str = "SUMMARY"
+    runtime_environment_arguments = {
+        "catch_exceptions": catch_exceptions,
+        "result_format": result_format,
+    }
+
+    expectation_arguments: dict = {
+        "include_config": True,
+        "column": "Name",  # use correct column to avoid error
+    }
+    expectation_meta: dict = {"Notes": "Some notes"}
+
+    expectation_arguments_without_meta: dict = dict(
+        **runtime_environment_arguments, **expectation_arguments
+    )
+
+    expectation_configuration: ExpectationConfiguration = ExpectationConfiguration(
+        expectation_type="expect_column_values_to_not_be_null",
+        kwargs=expectation_arguments_without_meta,
+        meta=expectation_meta,
+    )
+
+    suite: ExpectationSuite = in_memory_runtime_context.create_expectation_suite(
+        "test_suite", overwrite_existing=True
+    )
+    suite.add_expectation(expectation_configuration=expectation_configuration)
+
+    runtime_batch_request = RuntimeBatchRequest(
+        datasource_name="spark_datasource",
+        data_connector_name="runtime_data_connector",
+        data_asset_name="insert_your_data_asset_name_here",
+        runtime_parameters={"batch_data": test_spark_df},
+        batch_identifiers={
+            "id_key_0": "id_value_0",
+            "id_key_1": "id_value_1",
+        },
+    )
+
+    validator: Validator = in_memory_runtime_context.get_validator(
+        batch_request=runtime_batch_request,
+        expectation_suite=suite,
+    )
+
+    validator.set_default_expectation_argument("result_format", "BOOLEAN_ONLY")
+
+    # Test calling "validator.validate()" explicitly.
+    validator_validation: ExpectationSuiteValidationResult = validator.validate()
+    results: List[ExpectationValidationResult] = validator_validation.results
+    assert len(results) == 1
+
+    result: ExpectationValidationResult = results[0]
+    assert len(result.result.keys()) == 0
+
+    # Test calling "validator.expect_*" through "validator.validate_expectation()".
+
+    expectation_parameters: dict = dict(**expectation_arguments, **expectation_meta)
+
+    result: ExpectationValidationResult = validator.expect_column_values_to_not_be_null(
+        **expectation_parameters
+    )
+    assert len(result.result.keys()) == 0