Exemple #1
0
 def test_target_is_all_phases_or_non_act(self):
     # ACT & ASSERT #
     phase_spec__to_check_for_modifications = Phase.NON_ACT
     environs_setup = EnvironsSetupForSet(
         the_act=[NameAndValue('act_1', ' value of act_1')],
         non_act=[NameAndValue('non_act_1', ' value of non_act_1')],
     )
     for phase_spec__source in [None, Phase.NON_ACT]:
         var_to_set = NameAndValue('var_to_set', 'value_to_set')
         # ACT & ASSERT #
         CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
             self,
             SetVariableArgumentsAbsStx.of_nav(
                 var_to_set, phase_spec=phase_spec__source),
             symbol_usages=asrt.is_empty_sequence,
             execution_cases=[
                 NArrEx(
                     arr_.name,
                     arr_.value,
                     environs_setup.expectation_of_addition_to_phase(
                         phase_spec__to_check_for_modifications,
                         var_to_set),
                 ) for arr_ in _arr_for(
                     environs_setup, phase_spec__to_check_for_modifications)
             ],
             sub_test_identifiers={
                 'phase_spec__source': phase_spec__source,
             },
         )
Exemple #2
0
    def runTest(self):
        vars_before = [
            ValueWSymRefsAndVarRefs.REFERENCED_VAR_1,
            ValueWSymRefsAndVarRefs.REFERENCED_VAR_2
        ]
        var_to_set__resolved = NameAndValue(
            NameWSymRefs.RESOLVED_STR,
            ValueWSymRefsAndVarRefs.VALUE_WO_VAR_REFS)

        all_symbols = NameWSymRefs.SYMBOL_CONTEXTS + ValueWSymRefsAndVarRefs.SYMBOL_CONTEXTS

        execution_cases = _exe_cases_of_modification(
            before_modification=vars_before,
            after_modification=vars_before + [var_to_set__resolved],
            symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
        )
        # ACT & ASSERT #
        for phase_spec__source in [None, Phase.NON_ACT]:
            CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
                self,
                SetVariableArgumentsAbsStx(
                    NameWSymRefs.STRING_ABS_STX,
                    StringSourceOfStringAbsStx(
                        ValueWSymRefsAndVarRefs.STRING_ABS_STX),
                    phase_spec=phase_spec__source,
                ),
                symbol_usages=SymbolContext.usages_assertion_of_contexts(
                    all_symbols),
                execution_cases=execution_cases,
                sub_test_identifiers={
                    'phase_spec__source': phase_spec__source,
                },
            )
Exemple #3
0
    def test_a_references_to_a_non_existing_env_var_SHOULD_be_replaced_with_empty_string(
            self):
        # ARRANGE #
        existing_var = NameAndValue('existing', 'EXISTING')
        non_existing_var__name = 'non_existing'
        new_var_to_set__name = 'new_var_to_set'

        source = SetVariableArgumentsAbsStx.of_str(
            new_var_to_set__name,
            env_var_ref_syntax(non_existing_var__name),
            phase_spec=None,
        )
        # ACT & ASSERT #

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self, source,
            Arrangement.setup_phase_aware(
                process_execution_settings=proc_exe_env_for_test(
                    environ={existing_var.name: existing_var.value})),
            MultiSourceExpectation.setup_phase_aware(
                main_result=asrt.is_none,
                main_side_effect_on_environment_variables=asrt.equals({
                    existing_var.name:
                    existing_var.value,
                    new_var_to_set__name:
                    '',
                })))
Exemple #4
0
    def runTest(self):
        vars_before = [
            ValueWSymRefsAndVarRefs.REFERENCED_VAR_1,
            ValueWSymRefsAndVarRefs.REFERENCED_VAR_2
        ]
        setup_before = EnvironsSetup(vars_before, vars_before)

        var_to_set__resolved = NameAndValue(
            NameWSymRefs.RESOLVED_STR,
            ValueWSymRefsAndVarRefs.VALUE_WO_VAR_REFS)

        all_symbols = NameWSymRefs.SYMBOL_CONTEXTS + ValueWSymRefsAndVarRefs.SYMBOL_CONTEXTS

        execution_cases = _exe_cases_of_modification(
            before_modification=setup_before,
            after_modification=setup_before.new_with_added(
                var_to_set__resolved, var_to_set__resolved),
            symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
        )
        # ACT & ASSERT #
        CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
            self,
            SetVariableArgumentsAbsStx(
                NameWSymRefs.STRING_ABS_STX,
                StringSourceOfStringAbsStx(
                    ValueWSymRefsAndVarRefs.STRING_ABS_STX),
                phase_spec=None,
            ),
            symbol_usages=SymbolContext.usages_assertion_of_contexts(
                all_symbols),
            execution_cases=execution_cases,
        )
Exemple #5
0
    def test_set_value_that_references_an_env_var(self):
        # ARRANGE #

        existing_env_var = NameAndValue('MY_VAR', 'MY_VAL')
        defined_env_var = NameAndValue('name', existing_env_var.value)

        environ__before = {
            existing_env_var.name: existing_env_var.value,
        }
        environ__after = {
            defined_env_var.name: defined_env_var.value,
            existing_env_var.name: existing_env_var.value,
        }

        # ACT & ASSERT #

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            SetVariableArgumentsAbsStx.of_str(defined_env_var.name,
                                              env_var_ref_syntax(
                                                  existing_env_var.name),
                                              phase_spec=None),
            arrangement=Arrangement.setup_phase_aware(
                process_execution_settings=ProcessExecutionSettings.
                with_environ(environ__before), ),
            expectation=MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after), ))
Exemple #6
0
    def test_target_is_all_phases(self):
        # ACT & ASSERT #
        setup = self.ENVIRONS_SETUP__DIFFERENT
        identical_setup = self.ENVIRONS_SETUP__IDENTICAL
        var_to_unset = self.COMMON_VAR_TO_UNSET.name

        arbitrary_phase = Phase.NON_ACT

        all_execution_cases = [
            NArrEx(
                'non-act/populated, act/populated',
                arr(
                    non_act=setup.as_dict(Phase.NON_ACT),
                    the_act=setup.as_dict(Phase.ACT),
                    defaults_getter=get_empty_environ,
                ),
                setup.expectation_of_removal_from_phase_all(var_to_unset),
            ),
            NArrEx(
                'non-act/populated, act/not populated',
                arr(
                    non_act=setup.as_dict(Phase.NON_ACT),
                    the_act=None,
                    defaults_getter=setup.defaults_getter_with_values(
                        Phase.ACT),
                ),
                setup.expectation_of_removal_from_phase_all(var_to_unset),
            ),
            NArrEx(
                'non-act/not populated, act/populated',
                arr(
                    non_act=None,
                    the_act=setup.as_dict(Phase.ACT),
                    defaults_getter=setup.defaults_getter_with_values(
                        Phase.NON_ACT),
                ),
                setup.expectation_of_removal_from_phase_all(var_to_unset),
            ),
            NArrEx(
                'non-act/not populated, act/not populated',
                arr(
                    non_act=None,
                    the_act=None,
                    defaults_getter=identical_setup.
                    defaults_getter_with_values(arbitrary_phase),
                ),
                identical_setup.expectation_of_removal_from_phase_all(
                    var_to_unset),
            ),
        ]
        # ACT & ASSERT #
        CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
            self,
            UnsetVariableArgumentsAbsStx.of_str(var_to_unset, phase_spec=None),
            symbol_usages=asrt.is_empty_sequence,
            execution_cases=all_execution_cases,
        )
Exemple #7
0
    def test_constant_string_value__current_is_not_none(self):
        # ACT & ASSERT #
        var = NameAndValue('name', 'value')

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self, SetVariableArgumentsAbsStx.of_nav(var, phase_spec=None),
            Arrangement.setup_phase_aware(
                process_execution_settings=proc_exe_env_for_test(environ={})),
            MultiSourceExpectation.setup_phase_aware(
                main_result=asrt.is_none,
                main_side_effect_on_environment_variables=asrt.equals(
                    {var.name: var.value})))
Exemple #8
0
    def test_value_SHOULD_be_able_to_have_symbol_references(self):
        # ARRANGE #

        variable_name = 'variable_to_assign'

        my_symbol = StringConstantSymbolContext('my_symbol', 'my symbol value')
        your_symbol = StringConstantSymbolContext('your_symbol',
                                                  'your symbol value')

        value_template = 'pre {MY_SYMBOL} {YOUR_SYMBOL} post'

        expected_evaluated_value_string = value_template.format(
            MY_SYMBOL=my_symbol.str_value,
            YOUR_SYMBOL=your_symbol.str_value,
        )
        expected_environ_after_main = {
            variable_name: expected_evaluated_value_string,
        }
        value_source_string = value_template.format(
            MY_SYMBOL=symbol_reference_syntax_for_name(my_symbol.name),
            YOUR_SYMBOL=symbol_reference_syntax_for_name(your_symbol.name),
        )

        source_syntax = SetVariableArgumentsAbsStx.of_str(
            variable_name,
            value_source_string,
            phase_spec=None,
            quoting=QuoteType.SOFT)

        # ACT & ASSERT #

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            source_syntax,
            Arrangement.setup_phase_aware(
                symbols=SymbolContext.symbol_table_of_contexts(
                    [my_symbol, your_symbol]),
                process_execution_settings=ProcessExecutionSettings.
                with_environ({}),
            ),
            MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    expected_environ_after_main),
                symbol_usages=asrt.matches_sequence([
                    my_symbol.usage_assertion__w_str_rendering,
                    your_symbol.usage_assertion__w_str_rendering,
                ]),
            ),
        )
Exemple #9
0
    def test_existing_variable(self):
        var_a = NameAndValue('a', 'A')
        var_b = NameAndValue('b', 'B')

        environ__before = NameAndValue.as_dict([var_a, var_b])
        environ__after = NameAndValue.as_dict([var_b])

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            UnsetVariableArgumentsAbsStx.of_str(var_a.name, phase_spec=None),
            Arrangement.setup_phase_aware(
                process_execution_settings=ProcessExecutionSettings.
                with_environ(environ__before), ),
            MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after), ))
Exemple #10
0
 def _check_modification_of_single_phase(
         self, phase_to_modify: Phase, var_to_set: EnvVar,
         execution_cases: ExeCasesForContentsOfOtherGetter,
         contents_of_non_checked_phase__populated: EnvVarDict):
     # ARRANGE #
     all_execution_cases = (
         execution_cases(contents_of_non_checked_phase__populated) +
         execution_cases(None))
     # ACT & ASSERT #
     CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
         self,
         SetVariableArgumentsAbsStx.of_nav(var_to_set,
                                           phase_spec=phase_to_modify),
         symbol_usages=asrt.is_empty_sequence,
         execution_cases=all_execution_cases,
     )
Exemple #11
0
    def test_set_value_that_contains_text_and_references_to_env_vars(self):
        # ARRANGE #

        my_var = NameAndValue('MY_VAR', 'MY_VAL')
        your_var = NameAndValue('YOUR_VAR', 'YOUR_VAL')
        var_to_set_name = 'name'

        value_template = 'pre {my_var} {your_var} post'

        source = SetVariableArgumentsAbsStx.of_str(
            var_to_set_name,
            value_template.format(
                my_var=env_var_ref_syntax(my_var.name),
                your_var=env_var_ref_syntax(your_var.name),
            ),
            phase_spec=None,
            quoting=QuoteType.SOFT,
        )

        expected_value = value_template.format(
            my_var=my_var.value,
            your_var=your_var.value,
        )

        environ__before = {
            my_var.name: my_var.value,
            your_var.name: your_var.value,
        }

        expected_environ__after = {
            var_to_set_name: expected_value,
            my_var.name: my_var.value,
            your_var.name: your_var.value,
        }

        # ACT & ASSERT #

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            source,
            arrangement=Arrangement.setup_phase_aware(
                process_execution_settings=ProcessExecutionSettings.
                with_environ(environ__before), ),
            expectation=MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    expected_environ__after), ))
Exemple #12
0
 def test_target_is_act(self):
     # ACT & ASSERT #
     phase_spec__source = Phase.ACT
     phase_spec__to_check_for_modifications = Phase.NON_ACT
     var_in_target = NameAndValue('non_act_1', ' value of non_act_1')
     environs_setup = EnvironsSetupForUnset(
         the_act=[NameAndValue('act_1', ' value of act_1')],
         non_act=[var_in_target],
     )
     # ACT & ASSERT #
     CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
         self,
         UnsetVariableArgumentsAbsStx.of_str(var_in_target.name,
                                             phase_spec=phase_spec__source),
         symbol_usages=asrt.is_empty_sequence,
         execution_cases=_exe_cases_for_unmodified(
             environs_setup, phase_spec__to_check_for_modifications),
     )
Exemple #13
0
    def test_WHEN_var_name_is_not_an_existing_env_var_THEN_env_SHOULD_be_unmodified(
            self):
        non_existing_var_name = 'non_existing'
        existing_var = NameAndValue('existing', 'EXISTING')

        environ__before = NameAndValue.as_dict([existing_var])
        environ__after = NameAndValue.as_dict([existing_var])

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            UnsetVariableArgumentsAbsStx.of_str(non_existing_var_name,
                                                phase_spec=None),
            Arrangement.setup_phase_aware(
                process_execution_settings=ProcessExecutionSettings.
                with_environ(environ__before), ),
            MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after), ))
Exemple #14
0
    def test_multi_line_value(self):
        # ARRANGE #
        var = NameAndValue('name', 'a\nmulti\nline\nvalue\n')
        environ__before = {}
        environ__after = {var.name: var.value}

        # ACT & ASSERT #
        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            SetVariableArgumentsAbsStx.of_str(var.name,
                                              var.value,
                                              phase_spec=None,
                                              quoting=QuoteType.HARD),
            Arrangement.setup_phase_aware(
                process_execution_settings=proc_exe_env_for_test(
                    environ=environ__before)),
            MultiSourceExpectation.setup_phase_aware(
                main_result=asrt.is_none,
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after)))
Exemple #15
0
    def runTest(self):
        var_to_unset = NameAndValue(NameWSymRefs.RESOLVED_STR, 'value of var')
        vars_before = EnvironsSetup([var_to_unset], [var_to_unset])

        all_symbols = NameWSymRefs.SYMBOL_CONTEXTS

        execution_cases = _exe_cases_of_modification(
            before_modification=vars_before,
            after_modification=vars_before.new_with_removed(var_to_unset.name),
            symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
        )
        # ACT & ASSERT #
        CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
            self,
            UnsetVariableArgumentsAbsStx(NameWSymRefs.STRING_ABS_STX,
                                         phase_spec=None),
            symbol_usages=SymbolContext.usages_assertion_of_contexts(
                all_symbols),
            execution_cases=execution_cases,
        )
Exemple #16
0
    def test_current_environ_is_none(self):
        var_a = NameAndValue('a', 'A')
        var_b = NameAndValue('b', 'B')

        environ__before = NameAndValue.as_dict([var_a, var_b])
        environ__after = NameAndValue.as_dict([var_b])

        def get_default_environ() -> Dict[str, str]:
            return dict(environ__before)

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            UnsetVariableArgumentsAbsStx.of_str(var_a.name, phase_spec=None),
            Arrangement.setup_phase_aware(
                process_execution_settings=proc_exe_env_for_test(environ=None),
                default_environ_getter=get_default_environ,
            ),
            MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after), ))
Exemple #17
0
    def test_current_environ_is_none(self):
        # ACT & ASSERT #
        var_in_default = NameAndValue('var_in_default',
                                      'value of var in default')

        def get_default_environ() -> Dict[str, str]:
            return NameAndValue.as_dict([var_in_default])

        var_to_set = NameAndValue('var_to_set', 'value')

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self, SetVariableArgumentsAbsStx.of_nav(var_to_set,
                                                    phase_spec=None),
            Arrangement.setup_phase_aware(
                process_execution_settings=proc_exe_env_for_test(environ=None),
                default_environ_getter=get_default_environ,
            ),
            MultiSourceExpectation.setup_phase_aware(
                main_result=asrt.is_none,
                main_side_effect_on_environment_variables=asrt.equals(
                    NameAndValue.as_dict([var_in_default, var_to_set]))))
Exemple #18
0
    def test_value_with_hard_quoted_value_SHOULD_skip_symbol_substitution(
            self):
        # ARRANGE #

        variable_name = 'variable_to_assign'

        my_symbol = NameAndValue('my_symbol', 'my symbol value')
        your_symbol = NameAndValue('your_symbol', 'your symbol value')

        value_template = 'pre {MY_SYMBOL} {YOUR_SYMBOL} post'

        value_source_string = value_template.format(
            MY_SYMBOL=symbol_reference_syntax_for_name(my_symbol.name),
            YOUR_SYMBOL=symbol_reference_syntax_for_name(your_symbol.name),
        )

        expected_environ_after_main = {
            variable_name: value_source_string,
        }

        source_syntax = SetVariableArgumentsAbsStx.of_str(
            variable_name,
            value_source_string,
            phase_spec=None,
            quoting=QuoteType.HARD)

        # ACT & ASSERT #

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            source_syntax,
            Arrangement.setup_phase_aware(
                process_execution_settings=ProcessExecutionSettings.
                with_environ({}), ),
            MultiSourceExpectation.setup_phase_aware(
                main_side_effect_on_environment_variables=asrt.equals(
                    expected_environ_after_main),
                symbol_usages=asrt.matches_sequence([]),
            ),
        )
Exemple #19
0
    def test_WHEN_env_contains_the_var_being_set_THEN_its_value_SHOULD_be_replaced(
            self):
        # ACT & ASSERT #
        var_name = 'ENV_VAR'
        value_before = 'before'
        value_after = 'after'

        environ__before = {var_name: value_before}

        environ__after = {var_name: value_after}

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            SetVariableArgumentsAbsStx.of_str(var_name,
                                              value_after,
                                              phase_spec=None),
            Arrangement.setup_phase_aware(
                process_execution_settings=proc_exe_env_for_test(
                    environ=environ__before)),
            MultiSourceExpectation.setup_phase_aware(
                main_result=asrt.is_none,
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after)))
Exemple #20
0
    def test_reference_should_be_resolved_in_manipulated_phase(self):
        common_var_name = 'existing_in_both_act_and_non_act'

        new_var_to_set = NameAndValue('name_of_var_to_set',
                                      env_var_ref_syntax(common_var_name))

        common_var_value = {
            Phase.NON_ACT: 'value of common var in non act',
            Phase.ACT: 'value of common var in act',
        }

        before_modification = EnvironsSetupForSet(
            non_act=[
                NameAndValue(common_var_name, common_var_value[Phase.NON_ACT]),
                NameAndValue('only_in_non_act',
                             'value of var only in non-act'),
            ],
            the_act=[
                NameAndValue(common_var_name, common_var_value[Phase.ACT]),
                NameAndValue('only_in_act', 'value of var only in act'),
            ],
        )
        after_modification = before_modification.new_with_added(
            non_act=NameAndValue(new_var_to_set.name,
                                 common_var_value[Phase.NON_ACT]),
            the_act=NameAndValue(new_var_to_set.name,
                                 common_var_value[Phase.ACT]),
        )
        all_execution_cases = _exe_cases_of_modification(
            before_modification, after_modification)
        # ACT & ASSERT #
        CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
            self,
            SetVariableArgumentsAbsStx.of_nav(new_var_to_set, phase_spec=None),
            symbol_usages=asrt.is_empty_sequence,
            execution_cases=all_execution_cases,
        )
Exemple #21
0
    def test_reference_should_be_resolved_in_the_manipulated_phase(self):
        existing_var = NameAndValue('existing_name', 'value of existing')
        new_var_to_set_w_ref = NameAndValue(
            'name_of_var_to_set', env_var_ref_syntax(existing_var.name))

        vars_before = [existing_var]
        execution_cases = _exe_cases_of_modification(
            before_modification=vars_before,
            after_modification=[
                existing_var,
                NameAndValue(new_var_to_set_w_ref.name, existing_var.value)
            ])
        # ACT & ASSERT #
        for phase_spec__source in [None, Phase.NON_ACT]:
            CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
                self,
                SetVariableArgumentsAbsStx.of_nav(
                    new_var_to_set_w_ref, phase_spec=phase_spec__source),
                symbol_usages=asrt.is_empty_sequence,
                execution_cases=execution_cases,
                sub_test_identifiers={
                    'phase_spec__source': phase_spec__source,
                },
            )
Exemple #22
0
    def runTest(self):
        vars_before = [NameAndValue(NameWSymRefs.RESOLVED_STR, 'value of var')]
        vars_after = []

        all_symbols = NameWSymRefs.SYMBOL_CONTEXTS

        execution_cases = _exe_cases_of_modification(
            before_modification=vars_before,
            after_modification=vars_after,
            symbols=SymbolContext.symbol_table_of_contexts(all_symbols),
        )
        # ACT & ASSERT #
        for phase_spec__source in [None, Phase.NON_ACT]:
            CHECKER.check__abs_stx__multi__std_layouts_and_source_variants(
                self,
                UnsetVariableArgumentsAbsStx(NameWSymRefs.STRING_ABS_STX,
                                             phase_spec=phase_spec__source),
                symbol_usages=SymbolContext.usages_assertion_of_contexts(
                    all_symbols),
                execution_cases=execution_cases,
                sub_test_identifiers={
                    'phase_spec__source': phase_spec__source,
                },
            )
Exemple #23
0
    def runTest(self):
        # ACT & ASSERT #
        name = StringLiteralAbsStx('name')

        for phase_spec in PHASE_SPECS:
            for validation_case in str_src_validation_cases.failing_validation_cases(
            ):
                CHECKER.check__abs_stx__std_layouts_and_source_variants(
                    self,
                    SetVariableArgumentsAbsStx(name,
                                               validation_case.value.syntax,
                                               phase_spec=phase_spec),
                    Arrangement.setup_phase_aware(
                        symbols=validation_case.value.symbol_context.
                        symbol_table),
                    MultiSourceExpectation.setup_phase_aware(
                        symbol_usages=validation_case.value.symbol_context.
                        usages_assertion,
                        validation=validation_case.value.assertion,
                    ),
                    sub_test_identifiers={
                        'phase_spec': phase_spec,
                        'validation_case': validation_case.name,
                    })
Exemple #24
0
    def test_set_value_that_references_an_env_var_in_string_ref_value(self):
        # ARRANGE #

        existing_env_var = NameAndValue('MY_VAR', 'MY_VAL')
        defined_env_var = NameAndValue('name', existing_env_var.value)

        source_string_symbol_w_env_var_ref = StringSourceSymbolContext.of_primitive_constant(
            'SYMBOL_W_ENV_VAR_REF', env_var_ref_syntax(existing_env_var.name))

        environ__before = {
            existing_env_var.name: existing_env_var.value,
        }
        environ__after = {
            defined_env_var.name: defined_env_var.value,
            existing_env_var.name: existing_env_var.value,
        }

        # ACT & ASSERT #

        CHECKER.check__abs_stx__std_layouts_and_source_variants(
            self,
            SetVariableArgumentsAbsStx(
                StringLiteralAbsStx(defined_env_var.name),
                source_string_symbol_w_env_var_ref.abstract_syntax,
                phase_spec=None),
            arrangement=Arrangement.setup_phase_aware(
                symbols=source_string_symbol_w_env_var_ref.symbol_table,
                process_execution_settings=ProcessExecutionSettings.
                with_environ(environ__before),
            ),
            expectation=MultiSourceExpectation.setup_phase_aware(
                symbol_usages=source_string_symbol_w_env_var_ref.
                references_assertion,
                main_side_effect_on_environment_variables=asrt.equals(
                    environ__after),
            ))