Skip to content

Commit

Permalink
Merge pull request psychopy#6640 from TEParsons/dev-test-vm-speed
Browse files Browse the repository at this point in the history
TEST: Skip speed-sensitive tests if running in a VM
  • Loading branch information
TEParsons committed Jul 1, 2024
2 parents d753f31 + e2cab21 commit 4ad77b2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion psychopy/tests/test_app/test_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy
from pathlib import Path

from ..utils import TESTS_DATA_PATH
from psychopy.tests.utils import TESTS_DATA_PATH, RUNNING_IN_VM

import shutil
from tempfile import mkdtemp
Expand All @@ -16,6 +16,9 @@
class TestSpeed:
def setup_method(self):
self.tmp_dir = mkdtemp(prefix='psychopy-tests-app')
# skip speed tests under vm
if RUNNING_IN_VM:
pytest.skip()

def teardown_method(self):
shutil.rmtree(self.tmp_dir, ignore_errors=True)
Expand Down
4 changes: 4 additions & 0 deletions psychopy/tests/test_hardware/test_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pytest
import time
from psychopy import logging
from psychopy.tests.utils import RUNNING_IN_VM


class _TestBaseKeyboard:
Expand Down Expand Up @@ -60,6 +61,9 @@ def testMuteOutsidePsychopyNotSlower(self):
# skip this test on Linux (as MOP *is* slower due to having to use subprocess)
if sys.platform == "linux":
pytest.skip()
# skip speed tests under vm
if RUNNING_IN_VM:
pytest.skip()

# array to store times
times = {}
Expand Down
11 changes: 6 additions & 5 deletions psychopy/tests/test_visual/test_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from psychopy import visual, colors, core
from .test_basevisual import _TestUnitsMixin
from psychopy.tests.test_experiment.test_component_compile_python import _TestBoilerplateMixin
from .. import utils

from ..utils import TESTS_DATA_PATH

from psychopy.tests import utils
import pytest

class TestImage(_TestUnitsMixin, _TestBoilerplateMixin):
"""
Expand All @@ -17,7 +15,7 @@ def setup_method(self):
self.win = visual.Window()
self.obj = visual.ImageStim(
self.win,
str(Path(TESTS_DATA_PATH) / 'testimage.jpg'),
str(Path(utils.TESTS_DATA_PATH) / 'testimage.jpg'),
colorSpace='rgb1',
)

Expand Down Expand Up @@ -187,6 +185,9 @@ def test_fps(self):
"""
Check that images can be updated sufficiently fast to create frame animations
"""
# skip speed tests under vm
if utils.RUNNING_IN_VM:
pytest.skip()
# Create clock
clock = core.Clock()
# Try at each size
Expand Down
4 changes: 4 additions & 0 deletions psychopy/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import numpy as np
import io
from psychopy import logging, colors
from psychopy.tools import systemtools

try:
from PIL import Image
Expand All @@ -14,6 +15,9 @@

import pytest

# boolean indicating whether tests are running in a VM
RUNNING_IN_VM = systemtools.isVM_CI() is not None

# define the path where to find testing data
# so tests could be ran from any location
TESTS_PATH = abspath(dirname(__file__))
Expand Down

0 comments on commit 4ad77b2

Please sign in to comment.