Skip to content

Commit

Permalink
[Internal] Fix ci test test_invoke_sync_function_in_process_set_env (#…
Browse files Browse the repository at this point in the history
…3008)

# Description

fix test test_invoke_sync_function_in_process_set_env

# All Promptflow Contribution checklist:
- [x] **The pull request does not introduce [breaking changes].**
- [ ] **CHANGELOG is updated for new features, bug fixes or other
significant changes.**
- [x] **I have read the [contribution guidelines](../CONTRIBUTING.md).**
- [ ] **Create an issue and link to the pull request to get dedicated
review from promptflow team. Learn more: [suggested
workflow](../CONTRIBUTING.md#suggested-workflow).**

## General Guidelines and Best Practices
- [x] Title of the pull request is clear and informative.
- [x] There are a small number of commits, each of which have an
informative message. This means that previously merged commits do not
appear in the history of the PR. For more information on cleaning up the
commits in your PR, [see this
page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### Testing Guidelines
- [x] Pull request includes test coverage for the included changes.
  • Loading branch information
PeiwenGaoMS authored Apr 25, 2024
1 parent 1c462b1 commit 5d24e12
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def target_function(request: int):
return request


def target_function_get_env(environment_variable: str):
return os.getenv(environment_variable)


@pytest.mark.unittest
class TestProcessUtils:
@pytest.mark.asyncio
Expand Down Expand Up @@ -77,16 +81,13 @@ async def test_invoke_sync_function_in_process_unexpected_error(self):

@pytest.mark.asyncio
async def test_invoke_sync_function_in_process_set_env(self):
def target_function_get_env(environment_variable: str):
return os.getenv(environment_variable)

with patch("promptflow.executor._service.utils.process_utils.service_logger") as mock_logger:
environment_variables = {"test_env_name": "test_env_value"}
result = await invoke_sync_function_in_process(
target_function_get_env,
args=("test_env_name",),
context_dict=MOCK_CONTEXT_DICT,
environment_variables=environment_variables
environment_variables=environment_variables,
)
assert result == "test_env_value"
assert mock_logger.info.call_count == 2
Expand Down

0 comments on commit 5d24e12

Please sign in to comment.