self = <hypothesis.core.StateForActualGivenExecution object at 0x7fc0ad356b70>
data = ConjectureData(INTERESTING, 209 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:
trace = frozenset()
if (
self.failed_normally
and not self.failed_due_to_deadline
and Phase.shrink in self.settings.phases
and Phase.explain in self.settings.phases
and sys.gettrace() is None
and not PYPY
): # pragma: no cover
# This is in fact covered by our *non-coverage* tests, but due to the
# settrace() contention *not* by our coverage tests. Ah well.
tracer = Tracer()
try:
sys.settrace(tracer.trace)
result = self.execute_once(data)
if data.status == Status.VALID:
self.explain_traces[None].add(frozenset(tracer.branches))
finally:
sys.settrace(None)
trace = frozenset(tracer.branches)
else:
> result = self.execute_once(data)
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:749:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <hypothesis.core.StateForActualGivenExecution object at 0x7fc0ad356b70>
data = ConjectureData(INTERESTING, 209 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.
"""
self.ever_executed = True
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:
nonlocal text_repr
text_repr = repr_call(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()
for i, (k, v) in enumerate(kwargs.items()):
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:688:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = ConjectureData(INTERESTING, 209 bytes, frozen)
function = <function StateForActualGivenExecution.execute_once.<locals>.run at 0x7fc0ad6a3598>
def default_new_style_executor(data, function):
> return function(data)
.tox/py3/lib/python3.7/site-packages/hypothesis/executors.py:47:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
data = ConjectureData(INTERESTING, 209 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:
nonlocal text_repr
text_repr = repr_call(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()
for i, (k, v) in enumerate(kwargs.items()):
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:684:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.storage.tests.test_postgresql.TestStorage object at 0x7fc30c454518>
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7fc0ad3c6c88>
directories = [Directory(entries=(DirectoryEntry(name=b'\x02', type='rev', target=hash_to_bytes('31f1f8c904027d4af32d1ecb90811c7e189...2a1fe9bb2b3c367'), perms=0o120053),), id=hash_to_bytes('d22676aede597eb89e16adb91db0b3e00e13409e'), raw_manifest=None)]
@settings(
> suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large]
+ function_scoped_fixture_check,
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:771:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
args = (<swh.storage.tests.test_postgresql.TestStorage object at 0x7fc30c454518>, <swh.storage.postgresql.storage.Storage obj...a1fe9bb2b3c367'), perms=0o120053),), id=hash_to_bytes('d22676aede597eb89e16adb91db0b3e00e13409e'), raw_manifest=None)])
kwargs = {}, initial_draws = 1, start = 11997810.94289064
@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)
.tox/py3/lib/python3.7/site-packages/hypothesis/core.py:625:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <swh.storage.tests.test_postgresql.TestStorage object at 0x7fc30c454518>
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7fc0ad3c6c88>
directories = [Directory(entries=(DirectoryEntry(name=b'\x02', type='rev', target=hash_to_bytes('31f1f8c904027d4af32d1ecb90811c7e189...2a1fe9bb2b3c367'), perms=0o120053),), id=hash_to_bytes('d22676aede597eb89e16adb91db0b3e00e13409e'), raw_manifest=None)]
@settings(
suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large]
+ function_scoped_fixture_check,
)
@given(
strategies.lists(hypothesis_strategies.directories(), min_size=1, max_size=10)
)
def test_directory_add_get_arbitrary(self, swh_storage, directories):
swh_storage.directory_add(directories)
for directory in directories:
> assert directory == Directory(
id=directory.id,
entries=tuple(
stream_results(swh_storage.directory_get_entries, directory.id)
),
raw_manifest=swh_storage.directory_get_raw_manifest([directory.id])[
directory.id
],
)
E assert Directory(ent..._manifest=b'') == Directory(ent..._manifest=b'')
E
E Omitting 2 identical items, use -vv to show
E Differing attributes:
E ['entries']
E
E Drill down into differing attribute entries:
E entries: (DirectoryEntry(name=b"'\xa0%\x17\xaeI\x9bq", type='rev', target=hash_to_bytes('288870c31602dea8eeed86e8098eee5f04409050'), perms=0o160000),) != (DirectoryEntry(name=b'', type='file', target=hash_to_bytes('f515d5f91a7abb7d3bf4f6710d1168258b11ade2'), perms=0o120305),)...
E
E ...Full output truncated (5 lines hidden), use '-vv' to show
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:781: AssertionError
During handling of the above exception, another exception occurred:
self = <swh.storage.tests.test_postgresql.TestStorage object at 0x7fc30c454518>
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7fc0ad3c6c88>
@settings(
> suppress_health_check=[HealthCheck.too_slow, HealthCheck.data_too_large]
+ function_scoped_fixture_check,
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:771:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <hypothesis.internal.conjecture.datatree.TreeRecordingObserver object at 0x7fc0e229ff60>
status = Status.INTERESTING
interesting_origin = (<class 'AssertionError'>, '/var/lib/jenkins/workspace/DSTO/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py', 781, (), ())
def conclude_test(self, status, interesting_origin):
"""Says that ``status`` occurred at node ``node``. This updates the
node if necessary and checks for consistency."""
if status == Status.OVERRUN:
return
i = self.__index_in_current_node
node = self.__current_node
if i < len(node.values) or isinstance(node.transition, Branch):
inconsistent_generation()
new_transition = Conclusion(status, interesting_origin)
if node.transition is not None and node.transition != new_transition:
# As an, I'm afraid, horrible bodge, we deliberately ignore flakiness
# where tests go from interesting to valid, because it's much easier
# to produce good error messages for these further up the stack.
if isinstance(node.transition, Conclusion) and (
node.transition.status != Status.INTERESTING
or new_transition.status != Status.VALID
):
raise Flaky(
> f"Inconsistent test results! Test case was {node.transition!r} "
f"on first run but {new_transition!r} on second"
)
E hypothesis.errors.Flaky: Inconsistent test results! Test case was Conclusion(status=Status.INTERESTING, interesting_origin=(<class 'psycopg2.errors.UniqueViolation'>, '/var/lib/jenkins/workspace/DSTO/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/core/db/db_utils.py', 46, (), ())) on first run but Conclusion(status=Status.INTERESTING, interesting_origin=(<class 'AssertionError'>, '/var/lib/jenkins/workspace/DSTO/tests-on-diff/.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py', 781, (), ())) on second
.tox/py3/lib/python3.7/site-packages/hypothesis/internal/conjecture/datatree.py:407: Flaky
TEST RESULT
TEST RESULT
- Run At
- Aug 4 2022, 2:25 PM