From 78b4476c024623621e8f17dd18cb45c10d47addc Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Mon, 2 May 2016 19:11:22 +0300 Subject: [PATCH] Attempt to fix random errors on Appveyor --- test/cli_test.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/cli_test.py b/test/cli_test.py index b706cea..f939600 100644 --- a/test/cli_test.py +++ b/test/cli_test.py @@ -1,6 +1,7 @@ import os import shutil import subprocess +import time import unittest class TestCLI(unittest.TestCase): @@ -9,6 +10,13 @@ class TestCLI(unittest.TestCase): subprocess.check_call(["coverage", "erase"]) def setUp(self): + if os.name == "nt": + # On Windows tests randomly fail here with errors such as 'can not remove here\bin: directory not empty'. + # Supposedly this happens because a file in the directory is still open, and on NFS + # deleting an open file leaves a file in the same directory. Waiting before attempting + # to remove directories seems to help. + time.sleep(1) + for subdir in ["here", "builds"]: if os.path.exists(os.path.join("test", subdir)): shutil.rmtree(os.path.join("test", subdir))