ValueError: 'snapshot' is not a valid ObjectType
During handling of the above exception, another exception occurred:
object_type = 'snapshot', object_id = 'da8abf3ec5203afa1561754a041aca64d7580ec2'
scheme_version = 1, metadata = {}
def gen_swhid(
object_type: ObjectType,
object_id: str,
scheme_version: int = 1,
metadata: SWHIDContext = {},
) -> str:
"""
Returns the SoftWare Heritage persistent IDentifier for a swh object based on:
* the object type
* the object id
* the SWHID scheme version
Args:
object_type: the swh object type
(content/directory/release/revision/snapshot)
object_id: the swh object id (hexadecimal representation
of its hash value)
scheme_version: the scheme version of the SWHIDs
Returns:
the SWHID of the object
Raises:
BadInputExc: if the provided parameters do not enable to
generate a valid identifier
"""
try:
decoded_object_id = hash_to_bytes(object_id)
obj_swhid = str(
QualifiedSWHID(
object_type=object_type,
object_id=decoded_object_id,
scheme_version=scheme_version,
> **metadata,
)
)
.tox/py3/lib/python3.7/site-packages/swh/web/common/identifiers.py:72:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = QualifiedSWHID(namespace='swh', scheme_version=1, object_id=b'\xda\x8a\xbf>\xc5 :\xfa\x15auJ\x04\x1a\xcad\xd7X\x0e\xc2', object_type=NOTHING, origin=NOTHING, visit=NOTHING, anchor=NOTHING, path=NOTHING, lines=NOTHING)
def __init__(self, *, namespace=attr_dict['namespace'].default, scheme_version=attr_dict['scheme_version'].default, object_id, object_type, origin=attr_dict['origin'].default, visit=attr_dict['visit'].default, anchor=attr_dict['anchor'].default, path=attr_dict['path'].default, lines=attr_dict['lines'].default):
_setattr = _cached_setattr.__get__(self, self.__class__)
_inst_dict = self.__dict__
_inst_dict['namespace'] = namespace
_inst_dict['scheme_version'] = scheme_version
_inst_dict['object_id'] = object_id
> _inst_dict['object_type'] = __attr_converter_object_type(object_type)
<attrs generated init swh.model.identifiers.QualifiedSWHID>:7:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'ObjectType'>, value = 'snapshot', names = None
def __call__(cls, value, names=None, *, module=None, qualname=None, type=None, start=1):
"""Either returns an existing member, or creates a new enum class.
This method is used both when an enum class is given a value to match
to an enumeration member (i.e. Color(3)) and for the functional API
(i.e. Color = Enum('Color', names='RED GREEN BLUE')).
When used for the functional API:
`value` will be the name of the new class.
`names` should be either a string of white-space/comma delimited names
(values will start at `start`), or an iterator/mapping of name, value pairs.
`module` should be set to the module this class is being created in;
if it is not set, an attempt to find that module will be made, but if
it fails the class will not be picklable.
`qualname` should be set to the actual location this class can be found
at in its module; by default it is set to the global scope. If this is
not correct, unpickling will fail in some circumstances.
`type`, if set, will be mixed in as the first base class.
"""
if names is None: # simple value lookup
> return cls.__new__(cls, value)
/usr/lib/python3.7/enum.py:310:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'ObjectType'>, value = 'snapshot'
def __new__(cls, value):
# all enum instances are actually created during class construction
# without calling this method; this method is called by the metaclass'
# __call__ (i.e. Color(3) ), and by pickle
if type(value) is cls:
# For lookups like Color(Color.RED)
return value
# by-value search for a matching enum member
# see if it's in the reverse mapping (for hashable values)
try:
return cls._value2member_map_[value]
except KeyError:
# Not found, no need to do long O(n) search
pass
except TypeError:
# not there, now do long search -- O(n) behavior
for member in cls._member_map_.values():
if member._value_ == value:
return member
# still not found -- try _missing_ hook
try:
exc = None
result = cls._missing_(value)
except Exception as e:
exc = e
result = None
if isinstance(result, cls):
return result
else:
ve_exc = ValueError("%r is not a valid %s" % (value, cls.__name__))
if result is None and exc is None:
raise ve_exc
elif exc is None:
exc = TypeError(
'error in %s._missing_: returned %r instead of None or a valid member'
% (cls.__name__, result)
)
exc.__context__ = ve_exc
> raise exc
/usr/lib/python3.7/enum.py:564:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'ObjectType'>, value = 'snapshot'
def __new__(cls, value):
# all enum instances are actually created during class construction
# without calling this method; this method is called by the metaclass'
# __call__ (i.e. Color(3) ), and by pickle
if type(value) is cls:
# For lookups like Color(Color.RED)
return value
# by-value search for a matching enum member
# see if it's in the reverse mapping (for hashable values)
try:
return cls._value2member_map_[value]
except KeyError:
# Not found, no need to do long O(n) search
pass
except TypeError:
# not there, now do long search -- O(n) behavior
for member in cls._member_map_.values():
if member._value_ == value:
return member
# still not found -- try _missing_ hook
try:
exc = None
> result = cls._missing_(value)
/usr/lib/python3.7/enum.py:548:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cls = <enum 'ObjectType'>, value = 'snapshot'
@classmethod
def _missing_(cls, value):
> raise ValueError("%r is not a valid %s" % (value, cls.__name__))
E ValueError: 'snapshot' is not a valid ObjectType
/usr/lib/python3.7/enum.py:577: ValueError
During handling of the above exception, another exception occurred:
self = <hypothesis.core.StateForActualGivenExecution object at 0x7fdbe3839d30>
data = ConjectureData(VALID, 0 bytes, frozen)
def _execute_once_for_engine(self, data):
"""Wrapper around ``execute_once`` that intercepts test failure
exceptions and single-test control exceptions, and turns them into
appropriate method calls to `data` instead.
This allows the engine to assume that any exception other than
``StopTest`` must be a fatal error, and should stop the entire engine.
"""
try:
> result = self.execute_once(data)
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:676:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <hypothesis.core.StateForActualGivenExecution object at 0x7fdbe3839d30>
data = ConjectureData(VALID, 0 bytes, frozen), print_example = False
is_final = False, expected_failure = None
def execute_once(
self, data, print_example=False, is_final=False, expected_failure=None
):
"""Run the test function once, using ``data`` as input.
If the test raises an exception, it will propagate through to the
caller of this method. Depending on its type, this could represent
an ordinary test failure, or a fatal error, or a control exception.
If this method returns normally, the test might have passed, or
it might have placed ``data`` in an unsuccessful state and then
swallowed the corresponding control exception.
"""
data.is_find = self.is_find
text_repr = [None]
if self.settings.deadline is None:
test = self.test
else:
@proxies(self.test)
def test(*args, **kwargs):
self.__test_runtime = None
initial_draws = len(data.draw_times)
start = time.perf_counter()
result = self.test(*args, **kwargs)
finish = time.perf_counter()
internal_draw_time = sum(data.draw_times[initial_draws:])
runtime = datetime.timedelta(
seconds=finish - start - internal_draw_time
)
self.__test_runtime = runtime
current_deadline = self.settings.deadline
if not is_final:
current_deadline = (current_deadline // 4) * 5
if runtime >= current_deadline:
raise DeadlineExceeded(runtime, self.settings.deadline)
return result
def run(data):
# Set up dynamic context needed by a single test run.
with local_settings(self.settings):
with deterministic_PRNG():
with BuildContext(data, is_final=is_final):
# Generate all arguments to the test function.
args, kwargs = data.draw(self.search_strategy)
if expected_failure is not None:
text_repr[0] = arg_string(test, args, kwargs)
if print_example or current_verbosity() >= Verbosity.verbose:
output = StringIO()
printer = RepresentationPrinter(output)
if print_example:
printer.text("Falsifying example:")
else:
printer.text("Trying example:")
if self.print_given_args:
printer.text(" ")
printer.text(test.__name__)
with printer.group(indent=4, open="(", close=""):
printer.break_()
for v in args:
printer.pretty(v)
# We add a comma unconditionally because
# generated arguments will always be
# kwargs, so there will always be more
# to come.
printer.text(",")
printer.breakable()
# We need to make sure to print these in the
# argument order for Python 2 and older versions
# of Python 3.5. In modern versions this isn't
# an issue because kwargs is ordered.
arg_order = {
v: i
for i, v in enumerate(
getfullargspec(self.test).args
)
}
for i, (k, v) in enumerate(
sorted(
kwargs.items(),
key=lambda t: (
arg_order.get(t[0], float("inf")),
t[0],
),
)
):
printer.text(k)
printer.text("=")
printer.pretty(v)
printer.text(",")
if i + 1 < len(kwargs):
printer.breakable()
printer.break_()
printer.text(")")
printer.flush()
report(output.getvalue())
return test(*args, **kwargs)
# Run the test function once, via the executor hook.
# In most cases this will delegate straight to `run(data)`.
> result = self.test_runner(data, run)
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:631:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = ConjectureData(VALID, 0 bytes, frozen)
function = <function StateForActualGivenExecution.execute_once.<locals>.run at 0x7fdbe284ad90>
def default_new_style_executor(data, function):
> return function(data)
.tox/py3/lib/python3.7/site-packages/hypothesis/executors.py:52:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = ConjectureData(VALID, 0 bytes, frozen)
def run(data):
# Set up dynamic context needed by a single test run.
with local_settings(self.settings):
with deterministic_PRNG():
with BuildContext(data, is_final=is_final):
# Generate all arguments to the test function.
args, kwargs = data.draw(self.search_strategy)
if expected_failure is not None:
text_repr[0] = arg_string(test, args, kwargs)
if print_example or current_verbosity() >= Verbosity.verbose:
output = StringIO()
printer = RepresentationPrinter(output)
if print_example:
printer.text("Falsifying example:")
else:
printer.text("Trying example:")
if self.print_given_args:
printer.text(" ")
printer.text(test.__name__)
with printer.group(indent=4, open="(", close=""):
printer.break_()
for v in args:
printer.pretty(v)
# We add a comma unconditionally because
# generated arguments will always be
# kwargs, so there will always be more
# to come.
printer.text(",")
printer.breakable()
# We need to make sure to print these in the
# argument order for Python 2 and older versions
# of Python 3.5. In modern versions this isn't
# an issue because kwargs is ordered.
arg_order = {
v: i
for i, v in enumerate(
getfullargspec(self.test).args
)
}
for i, (k, v) in enumerate(
sorted(
kwargs.items(),
key=lambda t: (
arg_order.get(t[0], float("inf")),
t[0],
),
)
):
printer.text(k)
printer.text("=")
printer.pretty(v)
printer.text(",")
if i + 1 < len(kwargs):
printer.breakable()
printer.break_()
printer.text(")")
printer.flush()
report(output.getvalue())
> return test(*args, **kwargs)
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:627:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7fdbe4be9c18>
origin = {'archives': ['highlightjs-line-numbers.js.zip', 'highlightjs-line-numbers.js_visit2.zip'], 'type': 'git', 'url': 'https://github.com/wcoder/highlightjs-line-numbers.js'}
@given(origin_with_multiple_visits())
def test_get_snapshot_context_with_origin(archive_data, origin):
origin_visits = get_origin_visits(origin)
timestamp = format_utc_iso_date(origin_visits[0]["date"], "%Y-%m-%dT%H:%M:%SZ")
visit_id = origin_visits[1]["visit"]
for browse_context, kwargs in (
("content", {"origin_url": origin["url"], "path": "/some/path"}),
("directory", {"origin_url": origin["url"]}),
("log", {"origin_url": origin["url"]}),
("directory", {"origin_url": origin["url"], "timestamp": timestamp,},),
("directory", {"origin_url": origin["url"], "visit_id": visit_id,},),
):
visit_id = kwargs["visit_id"] if "visit_id" in kwargs else None
visit_ts = kwargs["timestamp"] if "timestamp" in kwargs else None
visit_info = get_origin_visit(
{"url": kwargs["origin_url"]}, visit_ts=visit_ts, visit_id=visit_id
)
snapshot = visit_info["snapshot"]
snapshot_context = get_snapshot_context(**kwargs, browse_context=browse_context)
query_params = dict(kwargs)
branches, releases, _ = get_snapshot_content(snapshot)
releases = list(reversed(releases))
revision_id = None
root_directory = None
for branch in branches:
if branch["name"] == "HEAD":
revision_id = branch["revision"]
root_directory = branch["directory"]
branch["url"] = reverse(
f"browse-origin-{browse_context}",
query_params={"branch": branch["name"], **query_params},
)
for release in releases:
release["url"] = reverse(
f"browse-origin-{browse_context}",
query_params={"release": release["name"], **query_params},
)
query_params.pop("path", None)
branches_url = reverse("browse-origin-branches", query_params=query_params)
releases_url = reverse("browse-origin-releases", query_params=query_params)
origin_visits_url = reverse(
"browse-origin-visits", query_params={"origin_url": kwargs["origin_url"]}
)
is_empty = not branches and not releases
> snapshot_swhid = gen_swhid("snapshot", snapshot)
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/test_snapshot_context.py:226:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
object_type = 'snapshot', object_id = 'da8abf3ec5203afa1561754a041aca64d7580ec2'
scheme_version = 1, metadata = {}
def gen_swhid(
object_type: ObjectType,
object_id: str,
scheme_version: int = 1,
metadata: SWHIDContext = {},
) -> str:
"""
Returns the SoftWare Heritage persistent IDentifier for a swh object based on:
* the object type
* the object id
* the SWHID scheme version
Args:
object_type: the swh object type
(content/directory/release/revision/snapshot)
object_id: the swh object id (hexadecimal representation
of its hash value)
scheme_version: the scheme version of the SWHIDs
Returns:
the SWHID of the object
Raises:
BadInputExc: if the provided parameters do not enable to
generate a valid identifier
"""
try:
decoded_object_id = hash_to_bytes(object_id)
obj_swhid = str(
QualifiedSWHID(
object_type=object_type,
object_id=decoded_object_id,
scheme_version=scheme_version,
**metadata,
)
)
except (ValidationError, KeyError, ValueError) as e:
> raise BadInputExc("Invalid object (%s) for SWHID. %s" % (object_id, e))
E swh.web.common.exc.BadInputExc: Invalid object (da8abf3ec5203afa1561754a041aca64d7580ec2) for SWHID. 'snapshot' is not a valid ObjectType
.tox/py3/lib/python3.7/site-packages/swh/web/common/identifiers.py:76: BadInputExc
During handling of the above exception, another exception occurred:
archive_data = <swh.web.tests.conftest._ArchiveData object at 0x7fdbe4be9c18>
@given(origin_with_multiple_visits())
> def test_get_snapshot_context_with_origin(archive_data, origin):
.tox/py3/lib/python3.7/site-packages/swh/web/tests/browse/test_snapshot_context.py:173:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:722: in _execute_once_for_engine
data.mark_interesting(get_interesting_origin(e))
.tox/py3/lib/python3.7/site-packages/hypothesis/internal/escalation.py:123: in get_interesting_origin
get_interesting_origin(exception.__context__) if exception.__context__ else (),
.tox/py3/lib/python3.7/site-packages/hypothesis/internal/escalation.py:123: in get_interesting_origin
get_interesting_origin(exception.__context__) if exception.__context__ else (),
.tox/py3/lib/python3.7/site-packages/hypothesis/internal/escalation.py:115: in get_interesting_origin
tb = get_trimmed_traceback(exception)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
exception = ValueError("'snapshot' is not a valid ObjectType")
def get_trimmed_traceback(exception=None):
"""Return the current traceback, minus any frames added by Hypothesis."""
if exception is None:
_, exception, tb = sys.exc_info()
else:
tb = exception.__traceback__
# Avoid trimming the traceback if we're in verbose mode, or the error
# was raised inside Hypothesis (and is not a MultipleFailures)
if hypothesis.settings.default.verbosity >= hypothesis.Verbosity.debug or (
> is_hypothesis_file(traceback.extract_tb(tb)[-1][0])
and not isinstance(exception, MultipleFailures)
):
E IndexError: list index out of range
.tox/py3/lib/python3.7/site-packages/hypothesis/internal/escalation.py:93: IndexError
TEST RESULT
TEST RESULT
- Run At
- Mar 3 2021, 10:02 AM