From 0ef4933491c242df11a14d0646acac332548e99b Mon Sep 17 00:00:00 2001
From: Guillaume Chanel <Guillaume.Chanel@unige.ch>
Date: Thu, 13 Oct 2022 18:44:08 +0200
Subject: [PATCH] Assert shell exits with code 0

---
 test/test.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/test/test.py b/test/test.py
index 65eaf18..8a6996e 100644
--- a/test/test.py
+++ b/test/test.py
@@ -1,9 +1,10 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # -*- coding: utf-8 -*-
 #
 # Test the given TP shell
 #
 # Author: David Gonzalez (HEPIA) <david.dg.gonzalez@hesge.ch>
+# Author: Guillaume Chanel <guillaume.chanel@unige.ch>
 
 import sys
 import tempfile
@@ -153,6 +154,9 @@ class Shell:
             raise subprocess.TimeoutExpired('The exit command did not exit the shell after {}s'.format(timeout))
         #TODO: should I check if process is still running at that point (stream closed but process alive ?)
 
+        if self.shell_process.returncode != 0:
+            raise AssertionError('Shell process exited with an error code ({})'.format(self.shell_process.returncode))
+
 
     def read_stdout(self):
         if self.stdout is not None:
-- 
GitLab