From 00084a8ffbdb64e4886aeb42d0973fa34a3cc3f4 Mon Sep 17 00:00:00 2001 From: David Shrewsbury Date: Wed, 12 Jul 2023 12:28:55 -0400 Subject: [PATCH] Fix for non-str ident --- src/ansible_runner/streaming.py | 2 +- test/unit/test_streaming.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 test/unit/test_streaming.py diff --git a/src/ansible_runner/streaming.py b/src/ansible_runner/streaming.py index acbf7e7c3..2558870c0 100644 --- a/src/ansible_runner/streaming.py +++ b/src/ansible_runner/streaming.py @@ -267,7 +267,7 @@ def __init__(self, _input=None, status_handler=None, event_handler=None, else: project_artifacts = os.path.abspath(os.path.join(self.private_data_dir, 'artifacts')) if ident := kwargs.get('ident'): - self.artifact_dir = os.path.join(project_artifacts, ident) + self.artifact_dir = os.path.join(project_artifacts, str(ident)) else: self.artifact_dir = project_artifacts diff --git a/test/unit/test_streaming.py b/test/unit/test_streaming.py new file mode 100644 index 000000000..c185cf0e4 --- /dev/null +++ b/test/unit/test_streaming.py @@ -0,0 +1,16 @@ +import os + +from ansible_runner.streaming import Processor + + +class TestProcessor: + + def test_artifact_dir_with_int_ident(self, tmp_path): + kwargs = { + 'private_data_dir': str(tmp_path), + 'ident': 123, + } + p = Processor(**kwargs) + assert p.artifact_dir == os.path.join(kwargs['private_data_dir'], + 'artifacts', + str(kwargs['ident']))