Skip to content

Commit

Permalink
Skip tests on unsupported platforms (#475)
Browse files Browse the repository at this point in the history
* Add function to check if running system is supported
* skip tests that except running on supported platforms
  • Loading branch information
itziakos committed Aug 22, 2024
1 parent 529c434 commit 9518046
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 6 additions & 1 deletion okonomiyaki/runtimes/tests/test_runtime.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import os.path
import sys
import os.path
import unittest

from okonomiyaki.platforms import EPDPlatform
from okonomiyaki.versions import RuntimeVersion
from okonomiyaki.utils.testing import known_system

from ..runtime import PythonRuntime

Expand All @@ -13,6 +14,10 @@


class TestPythonRuntime(unittest.TestCase):

@unittest.skipIf(
not known_system,
'This test should be executed only on Enthought supported platforms')
def test_simple_from_running_python(self):
# When
runtime_info = PythonRuntime.from_running_python()
Expand Down
16 changes: 16 additions & 0 deletions okonomiyaki/utils/testing.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from okonomiyaki.errors import OkonomiyakiError


class Patcher(object):
""" A dumb class to allow a mock.patch object to be used as a decorator and
a context manager
Expand Down Expand Up @@ -48,3 +51,16 @@ def __enter__(self):
def __exit__(self, *a, **kw):
for patcher in self._patchers:
patcher.__exit__(*a, **kw)


def known_system(self):
from okonomiyaki.plarforms._platform import (
_guess_os_kind, _guess_platform, _guess_platform_details)
try:
os_kind = _guess_os_kind()
_guess_platform(os_kind)
_guess_platform_details(os_kind)
except OkonomiyakiError:
return False
else:
return True

0 comments on commit 9518046

Please sign in to comment.