Skip to content

Commit 259fde8

Browse files
committed
launch_uuid_print and print_output argument tests
1 parent c4c0d97 commit 259fde8

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

reportportal_client/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
log_batch_payload_size: int = MAX_LOG_BATCH_PAYLOAD_SIZE,
9292
mode: str = 'DEFAULT',
9393
launch_uuid_print: bool = False,
94-
print_output: TextIO = sys.stdout,
94+
print_output: Optional[TextIO] = None,
9595
**kwargs: Any
9696
) -> None:
9797
"""Initialize required attributes.
@@ -137,7 +137,7 @@ def __init__(
137137
self.mode = mode
138138
self._skip_analytics = getenv('AGENT_NO_ANALYTICS')
139139
self.launch_uuid_print = launch_uuid_print
140-
self.print_output = print_output
140+
self.print_output = print_output or sys.stdout
141141

142142
self.api_key = api_key
143143
if not self.api_key:

tests/test_client.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1111
# See the License for the specific language governing permissions and
1212
# limitations under the License
13+
import sys
1314
from io import StringIO
1415

1516
import pytest
@@ -217,3 +218,25 @@ def test_no_launch_uuid_print():
217218
client._skip_analytics = True
218219
client.start_launch('Test Launch', timestamp())
219220
assert 'Report Portal Launch UUID: ' not in str_io.getvalue()
221+
222+
223+
@mock.patch('reportportal_client.client.sys.stdout', new_callable=StringIO)
224+
def test_launch_uuid_print_default_io(mock_stdout):
225+
client = RPClient(endpoint='http://endpoint', project='project',
226+
api_key='test', launch_uuid_print=True)
227+
client.session = mock.Mock()
228+
client._skip_analytics = True
229+
client.start_launch('Test Launch', timestamp())
230+
231+
assert 'Report Portal Launch UUID: ' in mock_stdout.getvalue()
232+
233+
234+
@mock.patch('reportportal_client.client.sys.stdout', new_callable=StringIO)
235+
def test_launch_uuid_print_default_print(mock_stdout):
236+
client = RPClient(endpoint='http://endpoint', project='project',
237+
api_key='test')
238+
client.session = mock.Mock()
239+
client._skip_analytics = True
240+
client.start_launch('Test Launch', timestamp())
241+
242+
assert 'Report Portal Launch UUID: ' not in mock_stdout.getvalue()

0 commit comments

Comments
 (0)