[gnome-calculator] tests: get a screenshot if the step has failed
- From: Vadim Rutkovsky <vrutkovsky src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator] tests: get a screenshot if the step has failed
- Date: Wed, 23 Apr 2014 19:52:45 +0000 (UTC)
commit cca0bc4a6e817c4ed7c68b8b7d1288d63e11cfd4
Author: Vadim Rutkovsky <vrutkovs redhat com>
Date: Wed Apr 23 21:04:41 2014 +0200
tests: get a screenshot if the step has failed
tests/environment.py | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/tests/environment.py b/tests/environment.py
index f48d38b..7807bf0 100644
--- a/tests/environment.py
+++ b/tests/environment.py
@@ -25,6 +25,20 @@ def before_all(context):
print("Error in before_all: %s" % e.message)
+def after_step(context, step):
+ try:
+ if step.status == 'failed' and hasattr(context, "embed"):
+ # Embed screenshot if HTML report is used
+ os.system("dbus-send --print-reply --session --type=method_call " +
+ "--dest='org.gnome.Shell.Screenshot' " +
+ "'/org/gnome/Shell/Screenshot' " +
+ "org.gnome.Shell.Screenshot.Screenshot " +
+ "boolean:true boolean:false string:/tmp/screenshot.png")
+ context.embed('image/png', open("/tmp/screenshot.png", 'r').read())
+ except Exception as e:
+ print("Error in after_step: %s" % str(e))
+
+
def after_scenario(context, scenario):
"""Teardown for each scenario
Kill gnome-calculator (in order to make this reliable we send sigkill)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]