File: default_timeout_as_env_var.patch

package info (click to toggle)
pytest-mpi 0.6-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 404 kB
  • sloc: python: 2,070; makefile: 28; sh: 22
file content (84 lines) | stat: -rw-r--r-- 3,209 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
diff --git a/tests/conftest.py b/tests/conftest.py
index 07422c0..13bd875 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -13,6 +13,11 @@ else:
     MPI_ARGS = ("mpirun", "-n")
 PYTEST_ARGS = (sys.executable, "-mpytest")
 
+default_timeout_option = os.environ.get("DEFAULT_TIMEOUT", "")
+if default_timeout_option != "":
+    DEFAULT_TIMEOUT = int(default_timeout_option)
+else:
+    DEFAULT_TIMEOUT = 5
 
 @pytest.fixture
 def has_mpi4py():
@@ -67,7 +72,7 @@ class MPITestdir(object):
             return self._run_pytester(*args, **kwargs)
         return self._run_testdir(*args, **kwargs)
 
-    def _run_testdir(self, *args, timeout=60, mpi_procs=2, max_retries=5):
+    def _run_testdir(self, *args, timeout=None, mpi_procs=2, max_retries=5):
         retries = 0
         p = py.path.local.make_numbered_dir(
             prefix="runpytest-", keep=None, rootdir=self._testdir.tmpdir
@@ -77,6 +82,8 @@ class MPITestdir(object):
         if plugins:
             args = ("-p", plugins[0]) + args
         args = MPI_ARGS + (str(mpi_procs),) + PYTEST_ARGS + args
+        if timeout is None:
+            timeout = DEFAULT_TIMEOUT
         while retries < max_retries:
             try:
                 return self._testdir.run(*args, timeout=timeout)
@@ -86,7 +93,7 @@ class MPITestdir(object):
                     raise
         raise e
 
-    def _run_pytester(self, *args, timeout=60, mpi_procs=2, max_retries=5):
+    def _run_pytester(self, *args, timeout=None, mpi_procs=2, max_retries=5):
         retries = 0
         p = _to_pathlib(py.path.local.make_numbered_dir(
             prefix="runpytest-", keep=None,
@@ -97,6 +104,8 @@ class MPITestdir(object):
         if plugins:
             args = ("-p", plugins[0]) + args
         args = MPI_ARGS + (str(mpi_procs),) + PYTEST_ARGS + args
+        if timeout is None:
+            timeout = DEFAULT_TIMEOUT
         while retries < max_retries:
             try:
                 return self._pytester.run(*args, timeout=timeout)
diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py
index a44d8e5..44e03ee 100644
--- a/tests/test_fixtures.py
+++ b/tests/test_fixtures.py
@@ -53,7 +53,7 @@ MPI_TMP_PATH_TEST_CODE = """
 def test_mpi_file_name(mpi_testdir, has_mpi4py):
     mpi_testdir.makepyfile(MPI_FILE_NAME_TEST_CODE)
 
-    result = mpi_testdir.runpytest("--with-mpi", timeout=5)
+    result = mpi_testdir.runpytest("--with-mpi", timeout=None)
 
     if has_mpi4py:
         result.assert_outcomes(passed=1)
@@ -64,7 +64,8 @@ def test_mpi_file_name(mpi_testdir, has_mpi4py):
 def test_mpi_tmpdir(mpi_testdir, has_mpi4py):
     mpi_testdir.makepyfile(MPI_TMPDIR_TEST_CODE)
 
-    result = mpi_testdir.runpytest("--with-mpi", timeout=5)
+    result = mpi_testdir.runpytest("--with-mpi", timeout=None)
+
 
     if has_mpi4py:
         result.assert_outcomes(passed=1)
@@ -75,7 +76,7 @@ def test_mpi_tmpdir(mpi_testdir, has_mpi4py):
 def test_mpi_tmp_path(mpi_testdir, has_mpi4py):
     mpi_testdir.makepyfile(MPI_TMP_PATH_TEST_CODE)
 
-    result = mpi_testdir.runpytest("--with-mpi", timeout=5)
+    result = mpi_testdir.runpytest("--with-mpi", timeout=None)
 
     if has_mpi4py:
         result.assert_outcomes(passed=1)