Skip to content

Commit

Permalink
Fix pytest warnings (#342)
Browse files Browse the repository at this point in the history
b/282039726
  • Loading branch information
andrewsavage1 authored May 18, 2023
1 parent c032d09 commit c57ca6c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
name = cobalt

[tool:pytest]
python_paths=.
norecursedirs=
.*
cobalt/black_box_tests/tests
Expand Down
22 changes: 16 additions & 6 deletions starboard/tools/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
#
"""Build related constants and helper functions."""

import imp # pylint: disable=deprecated-module
import importlib
import importlib.util
import logging
import os
import sys

from starboard.build.platforms import PLATFORMS
from starboard.tools import paths

_STARBOARD_TOOLCHAINS_DIR_KEY = 'STARBOARD_TOOLCHAINS_DIR'
_STARBOARD_TOOLCHAINS_DIR_NAME = 'starboard-toolchains'
Expand Down Expand Up @@ -71,6 +70,17 @@ def _ModuleLoaded(module_name, module_path):
return extensionless_loaded_path == extensionless_module_path


def _LoadModule(module_name, module_path):
try:
spec = importlib.util.spec_from_file_location(module_name, module_path)
module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(module)
return module
except AttributeError as e:
print(sys.version)
raise e


def _LoadPlatformModule(platform_name, file_name, function_name):
"""Loads a platform module.
Expand All @@ -90,11 +100,11 @@ def _LoadPlatformModule(platform_name, file_name, function_name):
try:
logging.debug('Loading platform %s for "%s".', file_name, platform_name)
if platform_name in PLATFORMS:
platform_path = os.path.join(paths.REPOSITORY_ROOT,
PLATFORMS[platform_name])
platform_path = os.path.join(PLATFORMS[platform_name])
module_path = os.path.join(platform_path, file_name)
if not _ModuleLoaded('platform_module', module_path):
platform_module = imp.load_source('platform_module', module_path)
module_name = 'platform_module'
if not _ModuleLoaded(module_name, module_path):
platform_module = _LoadModule(module_name, module_path)
else:
platform_module = sys.modules['platform_module']
else:
Expand Down

0 comments on commit c57ca6c

Please sign in to comment.