File tree Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Expand file tree Collapse file tree 4 files changed +47
-2
lines changed Original file line number Diff line number Diff line change
1
+ # Changelog
2
+
3
+ ## [ Unreleased]
4
+ ### Fixed
5
+ - Issue [ #180 ] ( https://github.com/reportportal/client-Python/issues/180 ) :
6
+ logger crash on attachments, by @HardNorth
7
+
8
+ ## [ 5.2.0]
9
+ ### Changed
10
+ - Client fixes, by @HardNorth
Original file line number Diff line number Diff line change 1
1
"""This module contains classes representing RP file object."""
2
2
3
+ import uuid
4
+
3
5
4
6
class RPFile (object ):
5
7
"""Class representation for a file that will be attached to the log."""
@@ -20,7 +22,7 @@ def __init__(self,
20
22
"""
21
23
self .content = content or data
22
24
self .content_type = content_type or mime
23
- self .name = name
25
+ self .name = name if name and name . strip () else str ( uuid . uuid4 ())
24
26
25
27
@property
26
28
def payload (self ):
Original file line number Diff line number Diff line change @@ -440,7 +440,7 @@ def __init__(self, log_reqs):
440
440
441
441
def __get_file (self , rp_file ):
442
442
"""Form a tuple for the single file."""
443
- return ('file' , (rp_file .name or uuid . uuid4 () ,
443
+ return ('file' , (rp_file .name ,
444
444
rp_file .content ,
445
445
rp_file .content_type or self .default_content ))
446
446
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2022 https://reportportal.io .
2
+ # Licensed under the Apache License, Version 2.0 (the "License");
3
+ # you may not use this file except in compliance with the License.
4
+ # You may obtain a copy of the License at
5
+ #
6
+ # https://www.apache.org/licenses/LICENSE-2.0
7
+ #
8
+ # Unless required by applicable law or agreed to in writing, software
9
+ # distributed under the License is distributed on an "AS IS" BASIS,
10
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ # See the License for the specific language governing permissions and
12
+ # limitations under the License
13
+
14
+ import pytest
15
+
16
+ from core .rp_file import RPFile
17
+
18
+
19
+ @pytest .mark .parametrize (
20
+ ['name' ],
21
+ [
22
+ ['' ],
23
+ [None ],
24
+ [' ' ]
25
+ ]
26
+ )
27
+ def test_rp_file_name_should_not_be_empty (name ):
28
+ file = RPFile (name , '{"test": true}' , 'application/json' )
29
+
30
+ payload = file .payload
31
+ assert payload ['name' ]
32
+ assert len (payload ['name' ]) > 10
33
+
You can’t perform that action at this time.
0 commit comments