Skip to content

Commit

Permalink
Merge pull request #1936 from apache/juerg/update-fixes
Browse files Browse the repository at this point in the history
Fix tests after dependency updates
  • Loading branch information
juergbi authored Jul 29, 2024
2 parents 518a34e + 52b7212 commit 3926137
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ parentdir_prefix = BuildStream-

[tool:pytest]
addopts = --verbose --basetemp ./tmp --durations=20 --timeout=1800
testpaths = tests
norecursedirs = src tests/integration/project tests/plugins/loading tests/plugins/sample-plugins integration-cache tmp __pycache__ .eggs
python_files = tests/*/*.py
env =
Expand All @@ -42,7 +43,7 @@ warn_no_return = True

# Ignore missing stubs for third-party packages.
# In future, these should be re-enabled if/when stubs for them become available.
[mypy-copyreg,grpc,pluginbase,psutil,pyroaring,ruamel,multiprocessing.forkserver]
[mypy-copyreg,grpc,pluginbase,psutil,pyroaring,ruamel,multiprocessing.forkserver,pkg_resources.extern]
ignore_missing_imports=True

# Ignore issues with generated files and vendored code
Expand Down
9 changes: 8 additions & 1 deletion src/buildstream/_pluginfactory/pluginoriginpip.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ def get_plugin_paths(self, kind, plugin_type):

import pkg_resources

try:
# For setuptools >= 70
import packaging
except ImportError:
# For setuptools < 70
from pkg_resources.extern import packaging

# Sources and elements are looked up in separate
# entrypoint groups from the same package.
#
Expand Down Expand Up @@ -66,7 +73,7 @@ def get_plugin_paths(self, kind, plugin_type):
# For setuptools < 49.0.0
pkg_resources.RequirementParseError,
# For setuptools >= 49.0.0
pkg_resources.extern.packaging.requirements.InvalidRequirement,
packaging.requirements.InvalidRequirement,
) as e:
raise PluginError(
"{}: Malformed package-name '{}' encountered: {}".format(
Expand Down
19 changes: 3 additions & 16 deletions src/buildstream/_testing/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,10 @@ def sourcetests_collection_hook(session):
"""

def should_collect_tests(config):
args = config.args
rootdir = config.rootdir
# When no args are supplied, pytest defaults the arg list to
# just include the session's root_dir. We want to collect
# When no args are supplied, pytest defaults the arg list to the
# value of the `testpaths` configuration option. We want to collect
# tests as part of the default collection
if args == [str(rootdir)]:
return True

# If specific tests are passed, don't collect
# everything. Pytest will handle this correctly without
# modification.
if len(args) > 1 or rootdir not in args:
return False

# If in doubt, collect them, this will be an easier bug to
# spot and is less likely to result in bug not being found.
return True
return config.args_source != pytest.Config.ArgsSource.ARGS

from . import _sourcetests

Expand Down
2 changes: 1 addition & 1 deletion src/buildstream/_testing/runcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def run_project_config(self, *, project_config=None, **kwargs):

temp_project = os.path.join(scratchdir, "project.conf")
with open(temp_project, "w", encoding="utf-8") as f:
yaml.safe_dump(project_config, f)
_yaml.roundtrip_dump(project_config, f)

project_config = _yaml.load(temp_project, shortname="project.conf")

Expand Down

0 comments on commit 3926137

Please sign in to comment.