Skip to content
Snippets Groups Projects
Commit 6fe57d45 authored by u214892's avatar u214892
Browse files

fix error by copying file from unresolved package

parent ddaac2a1
No related branches found
No related tags found
No related merge requests found
...@@ -26,9 +26,7 @@ tests: ...@@ -26,9 +26,7 @@ tests:
- apt update - apt update
- apt install -y libgl1-mesa-glx xvfb graphviz xdg-utils libcairo2-dev libjpeg-dev libgif-dev - apt install -y libgl1-mesa-glx xvfb graphviz xdg-utils libcairo2-dev libjpeg-dev libgif-dev
- pip install tox - pip install tox
- which python - xvfb-run tox -e benchmarks,profiling -v --recreate
- ls /usr/lib/python3.7/
- python -c 'from test.support import swap_attr2'
- xvfb-run tox -v --recreate - xvfb-run tox -v --recreate
build_and_deploy_docs: build_and_deploy_docs:
......
import contextlib
# Copied from https://docs.python.org/3/library/test.html
@contextlib.contextmanager
def swap_attr(obj, attr, new_val):
"""Temporary swap out an attribute with a new object.
Usage:
with swap_attr(obj, "attr", 5):
...
This will set obj.attr to 5 for the duration of the with: block,
restoring the old value at the end of the block. If `attr` doesn't
exist on `obj`, it will be created and then deleted at the end of the
block.
The old value (or None if it doesn't exist) will be assigned to the
target of the "as" clause, if there is one.
"""
if hasattr(obj, attr):
real_val = getattr(obj, attr)
setattr(obj, attr, new_val)
try:
yield real_val
finally:
setattr(obj, attr, real_val)
else:
setattr(obj, attr, new_val)
try:
yield
finally:
if hasattr(obj, attr):
delattr(obj, attr)
...@@ -2,19 +2,17 @@ import cProfile ...@@ -2,19 +2,17 @@ import cProfile
import runpy import runpy
import sys import sys
from io import StringIO from io import StringIO
from test.support import swap_attr
import importlib_resources import importlib_resources
import pkg_resources import pkg_resources
from importlib_resources import path from importlib_resources import path
from benchmarks.benchmark_utils import swap_attr
def profile(resource, entry): def profile(resource, entry):
with path(resource, entry) as file_in: with path(resource, entry) as file_in:
# we use the test package, which is meant for internal use by Python only internal and
# Any use of this package outside of Python’s standard library is discouraged as code (..)
# can change or be removed without notice between releases of Python.
# https://docs.python.org/3/library/test.html
# TODO remove input() from examples # TODO remove input() from examples
print("*****************************************************************") print("*****************************************************************")
print("Profiling {}".format(entry)) print("Profiling {}".format(entry))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment