test-reporting 3.6.2__tar.gz → 3.6.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. {test_reporting-3.6.2/test_reporting.egg-info → test_reporting-3.6.4}/PKG-INFO +1 -1
  2. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/plugin.py +3 -0
  3. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/storage.py +50 -3
  4. {test_reporting-3.6.2 → test_reporting-3.6.4}/setup.py +1 -1
  5. {test_reporting-3.6.2 → test_reporting-3.6.4/test_reporting.egg-info}/PKG-INFO +1 -1
  6. {test_reporting-3.6.2 → test_reporting-3.6.4}/LICENSE +0 -0
  7. {test_reporting-3.6.2 → test_reporting-3.6.4}/README.md +0 -0
  8. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/__init__.py +0 -0
  9. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/classifier.py +0 -0
  10. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/cli.py +0 -0
  11. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/config.py +0 -0
  12. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/publisher.py +0 -0
  13. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/templates/index.html +0 -0
  14. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/templates/project.html +0 -0
  15. {test_reporting-3.6.2 → test_reporting-3.6.4}/reporting/templates/run.html +0 -0
  16. {test_reporting-3.6.2 → test_reporting-3.6.4}/setup.cfg +0 -0
  17. {test_reporting-3.6.2 → test_reporting-3.6.4}/test_reporting.egg-info/SOURCES.txt +0 -0
  18. {test_reporting-3.6.2 → test_reporting-3.6.4}/test_reporting.egg-info/dependency_links.txt +0 -0
  19. {test_reporting-3.6.2 → test_reporting-3.6.4}/test_reporting.egg-info/entry_points.txt +0 -0
  20. {test_reporting-3.6.2 → test_reporting-3.6.4}/test_reporting.egg-info/requires.txt +0 -0
  21. {test_reporting-3.6.2 → test_reporting-3.6.4}/test_reporting.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: test-reporting
3
- Version: 3.6.2
3
+ Version: 3.6.4
4
4
  Summary: Multi-project test reporting dashboard — collect results locally or push to S3
5
5
  Home-page: https://github.com/amahdy77/test-reporting.git
6
6
  Author: Ashfaqur Mahdy
@@ -248,6 +248,9 @@ class TestReportingPlugin:
248
248
  logging.info(f"[Reporting] Published run: {run_id}")
249
249
  except Exception as e:
250
250
  logging.warning(f"[Reporting] Auto-publish failed: {e}")
251
+
252
+ # Close database connection to prevent ResourceWarning
253
+ self.storage.close()
251
254
 
252
255
  def _save_latest_json(self):
253
256
  """Save latest run data as JSON for dashboard."""
@@ -18,15 +18,49 @@ class TestResultStorage:
18
18
  self.config = config or ReportingConfig()
19
19
  self.db_path = db_path or self.config.DB_PATH
20
20
  self.db_path.parent.mkdir(parents=True, exist_ok=True)
21
+ self._connection = None
21
22
  self._init_database()
22
23
 
24
+ def __enter__(self):
25
+ """Context manager entry."""
26
+ return self
27
+
28
+ def __exit__(self, exc_type, exc_val, exc_tb):
29
+ """Context manager exit - ensure connection is closed."""
30
+ self.close()
31
+ return False
32
+
33
+ def close(self):
34
+ """Close any open database connections."""
35
+ if self._connection is not None:
36
+ try:
37
+ self._connection.close()
38
+ except Exception:
39
+ pass
40
+ finally:
41
+ self._connection = None
42
+
43
+ def _execute_with_connection(self, func):
44
+ """Execute a function with a database connection, ensuring it's closed."""
45
+ conn = sqlite3.connect(self.db_path)
46
+ try:
47
+ result = func(conn)
48
+ conn.commit()
49
+ return result
50
+ finally:
51
+ conn.close()
52
+
23
53
  def _init_database(self):
24
54
  """Initialize database with WAL mode and create tables."""
25
- with sqlite3.connect(self.db_path) as conn:
55
+ conn = sqlite3.connect(self.db_path)
56
+ try:
26
57
  # Enable WAL mode for concurrent access
27
58
  conn.execute('PRAGMA journal_mode=WAL')
28
59
  conn.execute('PRAGMA busy_timeout=5000') # Wait 5s if locked
29
60
  self._create_tables(conn)
61
+ conn.commit()
62
+ finally:
63
+ conn.close()
30
64
 
31
65
  def _create_tables(self, conn: sqlite3.Connection):
32
66
  """Create database tables if they don't exist."""
@@ -153,10 +187,18 @@ class TestResultStorage:
153
187
  except sqlite3.OperationalError:
154
188
  conn.execute('ALTER TABLE test_results ADD COLUMN is_retry BOOLEAN DEFAULT 0')
155
189
  print("[Reporting] Migration: Added 'is_retry' column to test_results")
190
+
191
+ # Migration: Add run_tag to test_runs
192
+ try:
193
+ conn.execute('SELECT run_tag FROM test_runs LIMIT 1')
194
+ except sqlite3.OperationalError:
195
+ conn.execute('ALTER TABLE test_runs ADD COLUMN run_tag TEXT')
196
+ print("[Reporting] Migration: Added 'run_tag' column to test_runs")
156
197
 
157
198
  def save_test_run(self, run_data: Dict[str, Any]) -> int:
158
199
  """Save a test run and return the run ID."""
159
- with sqlite3.connect(self.db_path) as conn:
200
+ conn = sqlite3.connect(self.db_path)
201
+ try:
160
202
  cursor = conn.execute('''
161
203
  INSERT INTO test_runs (
162
204
  project_name, timestamp, suite_name, build_number, build_url, run_tag,
@@ -180,10 +222,13 @@ class TestResultStorage:
180
222
  ))
181
223
  conn.commit()
182
224
  return cursor.lastrowid
225
+ finally:
226
+ conn.close()
183
227
 
184
228
  def save_test_result(self, run_id: int, result_data: Dict[str, Any]) -> int:
185
229
  """Save a test result and return the result ID."""
186
- with sqlite3.connect(self.db_path) as conn:
230
+ conn = sqlite3.connect(self.db_path)
231
+ try:
187
232
  cursor = conn.execute('''
188
233
  INSERT INTO test_results (
189
234
  run_id, project_name, file_name, test_name, full_name, status,
@@ -211,6 +256,8 @@ class TestResultStorage:
211
256
  ))
212
257
  conn.commit()
213
258
  return cursor.lastrowid
259
+ finally:
260
+ conn.close()
214
261
 
215
262
  def save_test_step(self, result_id: int, step_data: Dict[str, Any]):
216
263
  """Save a test step."""
@@ -9,7 +9,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
9
9
 
10
10
  setup(
11
11
  name='test-reporting',
12
- version='3.6.2',
12
+ version='3.6.4',
13
13
  description='Multi-project test reporting dashboard — collect results locally or push to S3',
14
14
  long_description=long_description,
15
15
  long_description_content_type="text/markdown",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: test-reporting
3
- Version: 3.6.2
3
+ Version: 3.6.4
4
4
  Summary: Multi-project test reporting dashboard — collect results locally or push to S3
5
5
  Home-page: https://github.com/amahdy77/test-reporting.git
6
6
  Author: Ashfaqur Mahdy
File without changes
File without changes
File without changes