From 34db3b001156521c8fad0af3b4f7ac4908cdcdad Mon Sep 17 00:00:00 2001
From: Paul McCarthy <pauldmccarthy@gmail.com>
Date: Wed, 26 May 2021 21:06:42 +0100
Subject: [PATCH] TEST: Try and avoid conflicts in parallel tests in docker

---
 tests/test_platform.py | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/tests/test_platform.py b/tests/test_platform.py
index a38408175..e845148a2 100644
--- a/tests/test_platform.py
+++ b/tests/test_platform.py
@@ -10,6 +10,7 @@ import               os
 import               gc
 import os.path    as op
 import               sys
+import               time
 import               shutil
 import               tempfile
 import               pytest
@@ -41,8 +42,22 @@ def test_haveGui():
 
     import wx
 
-    p      = fslplatform.Platform()
-    app    = wx.App()
+    p = fslplatform.Platform()
+
+    # We can get weird conflicts w.r.t. access to
+    # the display when multiple tests are running
+    # simultaneously within docker on the same
+    # machine.
+    app = None
+    for _ in range(5):
+        try:
+            app = wx.App()
+            break
+        except Exception:
+            time.sleep(1)
+    if app is None:
+        assert False
+
     frame  = wx.Frame(None)
     passed = [False]
     frame.Show()
-- 
GitLab