@@ -10,6 +10,7 @@ Library used only for implementors of custom listeners for ReportPortal
10
10
11
11
- [ PyTest Framework] ( https://github.com/reportportal/agent-python-pytest )
12
12
- [ Robot Framework] ( https://github.com/reportportal/agent-Python-RobotFramework )
13
+ - [ Nose Framework] ( https://github.com/reportportal/agent-python-nosetests )
13
14
14
15
15
16
## Installation
@@ -20,13 +21,28 @@ The latest stable version is available on PyPI:
20
21
pip install reportportal-client
21
22
```
22
23
24
+ ** IMPORTANT!**
25
+ The lastest version ** does** not support Report Portal versions below 5.0.0.
26
+
27
+ Specify the last one release of the client version 3 to install or update the client for other versions of Report Portal below 5.0.0:
28
+
29
+ ```
30
+ pip install reportportal-client~=3.0
31
+ ```
32
+
33
+
34
+ ## Contribution
35
+
36
+ All the fixes for the client that supports Report Portal versions below 5.0.0 should go into the v3 branch.
37
+ The master branch will store the code base for the client for Report Portal versions 5 and above.
38
+
23
39
24
40
## Usage
25
41
26
42
Main classes are:
27
43
28
44
- reportportal_client.ReportPortalService
29
- - reportportal_client.ReportPortalServiceAsync
45
+ - reportportal_client.ReportPortalServiceAsync(Client version 3.x only)
30
46
31
47
Basic usage example:
32
48
@@ -37,8 +53,12 @@ import traceback
37
53
from mimetypes import guess_type
38
54
from time import time
39
55
56
+ # Report Portal versions below 5.0.0:
40
57
from reportportal_client import ReportPortalServiceAsync
41
58
59
+ # Report Portal versions >= 5.0.0:
60
+ from reportportal_client import ReportPortalService
61
+
42
62
43
63
def timestamp ():
44
64
return str (int (time() * 1000 ))
@@ -63,15 +83,20 @@ def my_error_handler(exc_info):
63
83
traceback.print_exception(* exc_info)
64
84
65
85
86
+ # Report Portal versions below 5.0.0:
66
87
service = ReportPortalServiceAsync(endpoint = endpoint, project = project,
67
88
token = token, error_handler = my_error_handler)
68
89
90
+ # Report Portal versions >= 5.0.0:
91
+ service = ReportPortalServiceAsync(endpoint = endpoint, project = project,
92
+ token = token)
93
+
69
94
# Start launch.
70
95
launch = service.start_launch(name = launch_name,
71
96
start_time = timestamp(),
72
97
description = launch_doc)
73
98
74
- # Start test item.
99
+ # Start test item Report Portal versions below 5.0.0:
75
100
test = service.start_test_item(name = " Test Case" ,
76
101
description = " First Test Case" ,
77
102
tags = [" Image" , " Smoke" ],
@@ -80,6 +105,15 @@ test = service.start_test_item(name="Test Case",
80
105
parameters = {" key1" : " val1" ,
81
106
" key2" : " val2" })
82
107
108
+ # Start test item Report Portal versions >= 5.0.0:
109
+ item_id = service.start_test_item(name = " Test Case" ,
110
+ description = " First Test Case" ,
111
+ start_time = timestamp(),
112
+ item_type = " STEP" ,
113
+ parameters = {" key1" : " val1" ,
114
+ " key2" : " val2" })
115
+
116
+
83
117
# Create text log message with INFO level.
84
118
service.log(time = timestamp(),
85
119
message = " Hello World!" ,
@@ -112,9 +146,12 @@ service.log(
112
146
" INFO" ,
113
147
attachment = subprocess.check_output(" ps aux" .split()))
114
148
115
- # Finish test item.
149
+ # Finish test item Report Portal versions below 5.0.0 .
116
150
service.finish_test_item(end_time = timestamp(), status = " PASSED" )
117
151
152
+ # Finish test item Report Portal versions >= 5.0.0.
153
+ service.finish_test_item(item_id = item_id, end_time = timestamp(), status = " PASSED" )
154
+
118
155
# Finish launch.
119
156
service.finish_launch(end_time = timestamp())
120
157
@@ -135,9 +172,9 @@ There are two ways to pass data as attachment:
135
172
```
136
173
with open(screenshot_file_path, "rb") as image_file:
137
174
rp_logger.info("Some Text Here",
138
- attachment={"name": "test_name_screenshot.png",
139
- "data": image_file,
140
- "mime": "image/png"})
175
+ attachment={"name": "test_name_screenshot.png",
176
+ "data": image_file,
177
+ "mime": "image/png"})
141
178
```
142
179
143
180
### Case 2 - pass file content itself (like you did)
@@ -146,9 +183,9 @@ with open(screenshot_file_path, "rb") as image_file:
146
183
file_data = image_file.read()
147
184
148
185
rp_logger.info("Some Text Here",
149
- attachment={"name": "test_name_screenshot.png",
150
- "data": file_data,
151
- "mime": "image/png"})
186
+ attachment={"name": "test_name_screenshot.png",
187
+ "data": file_data,
188
+ "mime": "image/png"})
152
189
```
153
190
154
191
0 commit comments