repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
buiapp/reaktiv
import pytest import asyncio from reaktiv import Signal, Effect, ComputeSignal @pytest.mark.asyncio async def test_computed_signal_custom_equality(): """Test that computed signals work with custom equality functions.""" # Define a simpler custom equality function for testing def within_tolerance(a, b, tol...
[]
assert
collection
tests/test_custom_equality.py
test_computed_signal_custom_equality
119
null
buiapp/reaktiv
import pytest from unittest.mock import Mock from reaktiv import Signal, ComputeSignal from reaktiv._debug import set_debug set_debug(True) def test_dependency_tracking(): """Test dependencies are only tracked after first access""" source = Signal(10) compute_fn = Mock(side_effect=lambda: source.get() * 2...
computed._dependencies
assert
complex_expr
tests/test_lazy_computed.py
test_dependency_tracking
40
null
buiapp/reaktiv
from reaktiv import Signal, Computed, Effect def test_decorator_approximate_equality() -> None: """Test decorator with approximate floating-point equality.""" value = Signal(1.0) def approx_equal(a: float, b: float) -> bool: return abs(a - b) < 0.0001 @Computed(equal=approx_equal) def com...
2.0
assert
numeric_literal
tests/test_computed_decorator.py
test_decorator_approximate_equality
154
null
buiapp/reaktiv
from reaktiv import Signal, Linked, Effect def test_linked_decorator_with_equality() -> None: """Test @Linked decorator with custom equality function.""" source = Signal(5) def int_equal(a: int, b: int) -> bool: return a == b @Linked(equal=int_equal) def derived() -> int: return s...
50
assert
numeric_literal
tests/test_linked_decorator.py
test_linked_decorator_with_equality
44
null
buiapp/reaktiv
import pytest from reaktiv import Signal, Computed, Effect def test_circular_dependency_error_message(): """Test that the error message for circular dependency is clear and helpful.""" def compute_a(): return b() + 1 def compute_b(): return a() + 1 a = Computed(compute_a) b = Com...
RuntimeError)
pytest.raises
variable
tests/test_circular_dependency.py
test_circular_dependency_error_message
198
null
buiapp/reaktiv
import pytest import asyncio from reaktiv import Signal, Effect, ComputeSignal, batch, untracked from reaktiv.linked import LinkedSignal from reaktiv._debug import set_debug set_debug(True) def test_linked_signal_dependency_tracking(): """Test that LinkedSignal properly tracks dependencies""" a = Signal(1) ...
3
assert
numeric_literal
tests/test_linked_signal.py
test_linked_signal_dependency_tracking
263
null
buiapp/reaktiv
import pytest import asyncio from unittest.mock import Mock from reaktiv import Signal, ComputeSignal, Effect, batch class TestBatchPerformance: @pytest.mark.asyncio async def test_no_unnecessary_computations_in_batch(self): """Test that computed signals don't recompute unnecessarily during batch proc...
3
assert
numeric_literal
tests/test_batch_performance.py
test_no_unnecessary_computations_in_batch
TestBatchPerformance
32
null
buiapp/reaktiv
from reaktiv import Signal, Linked, Effect def test_linked_decorator_basic() -> None: """Test basic @Linked decorator usage.""" source = Signal(5) @Linked def derived() -> int: return source() * 2 assert derived() == 10 # Can be read like computed source.set(10) assert derive...
30
assert
numeric_literal
tests/test_linked_decorator.py
test_linked_decorator_basic
26
null
buiapp/reaktiv
import pytest import asyncio from reaktiv import Signal, Effect, ComputeSignal @pytest.mark.asyncio async def test_signal_default_equality(): """Test that a Signal without custom equality uses identity comparison by default.""" # Create a regular signal with default equality data = Signal([1, 2, 3]) #...
3
assert
numeric_literal
tests/test_custom_equality.py
test_signal_default_equality
74
null
buiapp/reaktiv
import asyncio import pytest import pytest_asyncio from reaktiv import ( Signal, Resource, ResourceStatus, Computed, ) _resources = [] async def cleanup_resources(): """Automatically clean up resources after each test.""" _resources.clear() yield # Cancel all pending tasks from resourc...
"user2"
assert
string_literal
tests/test_resource.py
test_resource_params_change
97
null
buiapp/reaktiv
import pytest import asyncio from reaktiv import Signal, Computed, Effect, batch @pytest.mark.asyncio async def test_batch_effect_notifications(): """Test that effects are only triggered once after a batch update completes.""" # Setup simple counter signals x = Signal(5) y = Signal(10) sum_xy = Co...
(15, 50)
assert
collection
tests/test_batch_notifications.py
test_batch_effect_notifications
30
null
buiapp/reaktiv
import gc from reaktiv import Signal, Effect def test_effect_gc_cleans_up_edges(): """When an effect is GC'd, it should clean up its edges from signals.""" signal = Signal(0) # Create and GC an effect Effect(lambda: signal()) gc.collect() # The signal's targets list should be empty or...
[1]
assert
collection
tests/test_weakref_effects.py
test_effect_gc_cleans_up_edges
93
null
buiapp/reaktiv
import pytest import threading import time from concurrent.futures import ThreadPoolExecutor, as_completed from reaktiv import ( Signal, ComputeSignal, Effect, set_thread_safety, is_thread_safety_enabled, ) class TestThreadSafetyStressTests: def test_complex_reactive_system_stress(self): ...
3
assert
numeric_literal
tests/test_thread_safety.py
test_complex_reactive_system_stress
TestThreadSafetyStressTests
793
null
buiapp/reaktiv
import pytest import threading import time from concurrent.futures import ThreadPoolExecutor, as_completed from reaktiv import ( Signal, ComputeSignal, Effect, set_thread_safety, is_thread_safety_enabled, ) class TestThreadPoolIntegration: def test_thread_pool_computed_signals(self): ...
50
assert
numeric_literal
tests/test_thread_safety.py
test_thread_pool_computed_signals
TestThreadPoolIntegration
1,029
null
buiapp/reaktiv
import pytest from reaktiv import Signal, Computed, Effect def test_indirect_circular_dependency(): """Test detection of a more complex circular dependency with valid dependencies mixed in.""" # Create a valid base signal base = Signal(10) # Create some valid computed signals valid1 = Computed(lam...
25
assert
numeric_literal
tests/test_circular_dependency.py
test_indirect_circular_dependency
89
null
buiapp/reaktiv
import pytest from reaktiv import Signal, Computed, Effect def test_indirect_circular_dependency(): """Test detection of a more complex circular dependency with valid dependencies mixed in.""" # Create a valid base signal base = Signal(10) # Create some valid computed signals valid1 = Computed(lam...
20
assert
numeric_literal
tests/test_circular_dependency.py
test_indirect_circular_dependency
88
null
buiapp/reaktiv
from reaktiv import Signal, Linked, Effect def test_linked_decorator_chaining() -> None: """Test chaining multiple linked signals.""" base = Signal(1) @Linked def first() -> int: return base() * 2 @Linked def second() -> int: return first() * 3 assert second() == 6 #...
12
assert
numeric_literal
tests/test_linked_decorator.py
test_linked_decorator_chaining
142
null
bethgelab/foolbox
from typing import Tuple, Union, List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten from foolbox.attacks.brendel_bethge import BrendelBethgeAttack import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: Tuple[BrendelBethgeA...
fbn.accuracy(fmodel, x, y)
assert
func_call
tests/test_hsj_attack.py
test_hsj_untargeted_attack
81
null
bethgelab/foolbox
from typing import List, Optional, NamedTuple import pytest import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.gradient_estimators import es_gradient_estimator from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf FGSM_GE = es_gradient_estimator( ...
asr
assert
variable
tests/test_attacks.py
test_targeted_attacks
305
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_dataset_attack_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmo...
n
assert
variable
tests/test_attacks_raise.py
test_dataset_attack_raises
178
null
bethgelab/foolbox
from typing import List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: fa.Attack) -> str: return repr(x) @pytest.mark.parametrize("attack", attacks, ids=get_attack...
fbn.accuracy( fmodel, x, target_classes )
assert
func_call
tests/test_pointwise_attack.py
test_pointwise_targeted_attack
94
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_newtonfool_run_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmo...
ValueError, match="expected labels to have shape")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_newtonfool_run_raises
93
null
bethgelab/foolbox
import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription attacks = [ fbn.attacks.InversionAttack(distance=fbn.distances.l2), fbn.attacks.InversionAttack(distance=fbn.distances.l2).repeat(3), fbn.attacks.L2ContrastReductionAttack(), fbn.attacks.L2ContrastR...
2
assert
numeric_literal
tests/test_attacks_base.py
test_get_channel_axis
43
null
bethgelab/foolbox
from typing import Any import sys import pytest import foolbox as fbn from foolbox.zoo.model_loader import ModelLoader def unload_foolbox_model_module() -> None: # reload foolbox_model from scratch for every run # to ensure atomic tests without side effects module_names = ["foolbox_model", "model"] fo...
ValueError)
pytest.raises
variable
tests/test_zoo.py
test_non_default_module_throws_error
78
null
bethgelab/foolbox
from typing import Tuple, Union, List import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten from foolbox.attacks.fast_minimum_norm import FMNAttackLp import pytest import numpy as np from conftest import ModeAndDataAndDescription def get_attack_id(x: Tuple[FMNAtt...
1.0
assert
numeric_literal
tests/test_fast_minimum_norm_attack.py
test_fast_minimum_norm_targeted_attack
97
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] @pytest.mark.parametrize("bounds", [(0, 1), (-1.0, 1.0), (0, 255), (-32768, 32767)]) def test_transform_bounds( fmodel_and_data: ModelAndData...
logits1c.numpy())
assert_*
func_call
tests/test_models.py
test_transform_bounds
115
null
bethgelab/foolbox
from typing import List, Tuple import pytest import foolbox as fbn import foolbox.attacks as fa from conftest import ModeAndDataAndDescription def get_attack_id(x: fbn.Attack) -> str: return repr(x) @pytest.mark.parametrize("attack_grad_real", attacks, ids=get_attack_id) def test_spatial_attacks( fmodel_and_...
0
assert
numeric_literal
tests/test_spatial_attack.py
test_spatial_attacks
37
null
bethgelab/foolbox
import pytest from foolbox import accuracy from foolbox.models import ThresholdingWrapper from foolbox.devutils import flatten from foolbox.attacks import BinarySearchContrastReductionAttack from foolbox.attacks import BinarizationRefinementAttack from conftest import ModeAndDataAndDescription def test_binarization_...
acc
assert
variable
tests/test_binarization_attack.py
test_binarization_attack
32
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_ead_init_raises() -> None: with pytest.raises(
ValueError, match="invalid decision rule")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_ead_init_raises
13
null
bethgelab/foolbox
import pytest import foolbox as fbn from conftest import ModeAndDataAndDescription def test_dataset_attack( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmodel_and_data_ext_for_attacks x = (x - fmodel.bounds.lower) / (fmodel.bounds.upper - fmodel.bounds.l...
(len(x),)
assert
collection
tests/test_dataset_attack.py
test_dataset_attack
22
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] @pytest.mark.parametrize("bounds", [(0, 1), (-1.0, 1.0), (0, 255), (-32768, 32767)]) @pytest.mark.parametrize("manual", [True, False]) def test_t...
logits2b.numpy())
assert_*
func_call
tests/test_models.py
test_transform_bounds_wrapper
177
null
bethgelab/foolbox
import pytest import eagerpy as ep from foolbox import accuracy from foolbox.attacks import ( LinfBasicIterativeAttack, L1BasicIterativeAttack, L2BasicIterativeAttack, ) from foolbox.models import ExpectationOverTransformationWrapper from foolbox.types import L2, Linf from conftest import ModeAndDataAndD...
0
assert
numeric_literal
tests/test_eot_wrapper.py
test_eot_wrapper
33
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_pytorch_invalid_model(request: Any) -> None: backend = request.config.option.backend if backend != "pytorch": pytest.ski...
ValueError, match="torch.nn.Module")
pytest.raises
complex_expr
tests/test_models.py
test_pytorch_invalid_model
74
null
bethgelab/foolbox
import pytest from foolbox import accuracy from foolbox.models import ThresholdingWrapper from foolbox.devutils import flatten from foolbox.attacks import BinarySearchContrastReductionAttack from foolbox.attacks import BinarizationRefinementAttack from conftest import ModeAndDataAndDescription def test_binarization_...
ValueError, match="does not match")
pytest.raises
complex_expr
tests/test_binarization_attack.py
test_binarization_attack
64
null
bethgelab/foolbox
from typing import Tuple, Any, Dict, Callable, TypeVar import numpy as np import pytest import foolbox as fbn import eagerpy as ep distances = { 0: fbn.distances.l0, 1: fbn.distances.l1, 2: fbn.distances.l2, ep.inf: fbn.distances.linf, } data: Dict[str, Callable[..., Tuple[ep.Tensor, ep.Tensor]]] = {}...
desired)
assert_*
variable
tests/test_distances.py
test_distance
56
null
bethgelab/foolbox
import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription attacks = [ fbn.attacks.InversionAttack(distance=fbn.distances.l2), fbn.attacks.InversionAttack(distance=fbn.distances.l2).repeat(3), fbn.attacks.L2ContrastReductionAttack(), fbn.attacks.L2ContrastR...
1
assert
numeric_literal
tests/test_attacks_base.py
test_get_channel_axis
41
null
bethgelab/foolbox
import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription attacks = [ fbn.attacks.InversionAttack(distance=fbn.distances.l2), fbn.attacks.InversionAttack(distance=fbn.distances.l2).repeat(3), fbn.attacks.L2ContrastReductionAttack(), fbn.attacks.L2ContrastR...
ValueError)
pytest.raises
variable
tests/test_attacks_base.py
test_get_channel_axis
45
null
bethgelab/foolbox
from typing import Tuple, Union, List import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten from foolbox.attacks.fast_minimum_norm import FMNAttackLp import pytest import numpy as np from conftest import ModeAndDataAndDescription def get_attack_id(x: Tuple[FMNAtt...
fbn.accuracy(fmodel, init_advs, y)
assert
func_call
tests/test_fast_minimum_norm_attack.py
test_fast_minimum_norm_untargeted_attack
53
null
bethgelab/foolbox
from typing import List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: fa.Attack) -> str: return repr(x) @pytest.mark.parametrize("attack", attacks, ids=get_attack...
fbn.accuracy( fmodel, init_advs, target_classes )
assert
func_call
tests/test_pointwise_attack.py
test_pointwise_targeted_attack
97
null
bethgelab/foolbox
from typing import Tuple import foolbox as fbn import eagerpy as ep import pytest ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_accuracy(fmodel_and_data: ModelAndData) -> None: fmodel, x, y = fmodel_and_data accuracy = fbn.accuracy(fmodel, x, y) assert 0 <=
accuracy
assert
variable
tests/test_utils.py
test_accuracy
12
null
bethgelab/foolbox
from typing import Tuple import foolbox as fbn import eagerpy as ep import pytest ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_accuracy(fmodel_and_data: ModelAndData) -> None: fmodel, x, y = fmodel_and_data accuracy = fbn.accuracy(fmodel, x, y) assert 0 <= accuracy <= 1 assert accur...
0.5
assert
numeric_literal
tests/test_utils.py
test_accuracy
13
null
bethgelab/foolbox
from typing import List, Optional, NamedTuple import pytest import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.gradient_estimators import es_gradient_estimator from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf FGSM_GE = es_gradient_estimator( ...
acc
assert
variable
tests/test_attacks.py
test_untargeted_attacks
211
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_forward_unwrapped(fmodel_and_data: ModelAndData) -> None: fmodel, x, y = fmodel_and_data logits = ep.astensor(fmodel(x.raw)) ...
len(x)
assert
func_call
tests/test_models.py
test_forward_unwrapped
24
null
bethgelab/foolbox
from typing import Tuple, Union, List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten from foolbox.attacks.brendel_bethge import BrendelBethgeAttack import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: Tuple[BrendelBethgeA...
fbn.accuracy(fmodel, init_advs, y)
assert
func_call
tests/test_hsj_attack.py
test_hsj_untargeted_attack
82
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] @pytest.mark.parametrize("bounds", [(0, 1), (-1.0, 1.0), (0, 255), (-32768, 32767)]) def test_transform_bounds( fmodel_and_data: ModelAndData...
logits2.numpy())
assert_*
func_call
tests/test_models.py
test_transform_bounds
107
null
bethgelab/foolbox
from typing import Tuple import foolbox as fbn import eagerpy as ep import pytest ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_accuracy(fmodel_and_data: ModelAndData) -> None: fmodel, x, y = fmodel_and_data accuracy = fbn.accuracy(fmodel, x, y) assert 0 <= accuracy <= 1 assert accura...
1
assert
numeric_literal
tests/test_utils.py
test_accuracy
16
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_blended_noise_init_raises() -> None: with pytest.raises(
ValueError, match="directions must be larger than 0")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_blended_noise_init_raises
127
null
bethgelab/foolbox
from typing import List, Tuple import pytest import foolbox as fbn import foolbox.attacks as fa from conftest import ModeAndDataAndDescription def get_attack_id(x: fbn.Attack) -> str: return repr(x) @pytest.mark.parametrize("attack_grad_real", attacks, ids=get_attack_id) def test_spatial_attacks( fmodel_and_...
acc
assert
variable
tests/test_spatial_attack.py
test_spatial_attacks
39
null
bethgelab/foolbox
from typing import Any import sys import pytest import foolbox as fbn from foolbox.zoo.model_loader import ModelLoader def unload_foolbox_model_module() -> None: # reload foolbox_model from scratch for every run # to ensure atomic tests without side effects module_names = ["foolbox_model", "model"] fo...
0.9
assert
numeric_literal
tests/test_zoo.py
test_loading_model
61
null
bethgelab/foolbox
from typing import Tuple, Union, List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten from foolbox.attacks.brendel_bethge import BrendelBethgeAttack import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: Tuple[BrendelBethgeA...
fbn.accuracy(fmodel, init_advs, y)
assert
func_call
tests/test_brendel_bethge_attack.py
test_brendel_bethge_untargeted_attack
58
null
bethgelab/foolbox
import pytest from foolbox import accuracy from foolbox.models import ThresholdingWrapper from foolbox.devutils import flatten from foolbox.attacks import BinarySearchContrastReductionAttack from foolbox.attacks import BinarizationRefinementAttack from conftest import ModeAndDataAndDescription def test_binarization_...
0
assert
numeric_literal
tests/test_binarization_attack.py
test_binarization_attack
27
null
bethgelab/foolbox
from typing import Optional, Callable, Tuple, Dict, Any, List, NamedTuple import functools import pytest import eagerpy as ep import foolbox import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] CallableModelAndDataAndDescription = NamedTuple( "CallableModelAndDataAndDescription", [ ...
ValueError)
pytest.raises
variable
tests/conftest.py
numpy_simple_model
307
null
bethgelab/foolbox
from typing import Tuple, Union, List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten from foolbox.attacks.brendel_bethge import BrendelBethgeAttack import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: Tuple[BrendelBethgeA...
fbn.accuracy(fmodel, x, y)
assert
func_call
tests/test_brendel_bethge_attack.py
test_brendel_bethge_untargeted_attack
57
null
bethgelab/foolbox
from typing import Tuple import foolbox as fbn import eagerpy as ep import pytest ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] @pytest.mark.parametrize("batchsize", [1, 8]) @pytest.mark.parametrize( "dataset", ["imagenet", "cifar10", "cifar100", "mnist", "fashionMNIST"] ) def test_samples(fmodel_and_data...
ValueError)
pytest.raises
variable
tests/test_utils.py
test_samples
35
null
bethgelab/foolbox
import pytest import eagerpy as ep import foolbox as fbn def test_plot(dummy: ep.Tensor) -> None: # just tests that the calls don't throw any errors images = ep.zeros(dummy, (10, 3, 32, 32)) fbn.plot.images(images) fbn.plot.images(images, n=3) fbn.plot.images(images, n=3, data_format="channels_firs...
ValueError)
pytest.raises
variable
tests/test_plot.py
test_plot
19
null
bethgelab/foolbox
import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription attacks = [ fbn.attacks.InversionAttack(distance=fbn.distances.l2), fbn.attacks.InversionAttack(distance=fbn.distances.l2).repeat(3), fbn.attacks.L2ContrastReductionAttack(), fbn.attacks.L2ContrastR...
(len(x),)
assert
collection
tests/test_attacks_base.py
test_call_one_epsilon
32
null
bethgelab/foolbox
from typing import List, Any import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.devutils import flatten import pytest from conftest import ModeAndDataAndDescription def get_attack_id(x: fa.Attack) -> str: return repr(x) @pytest.mark.parametrize("attack", attacks, ids=get_attack...
fbn.accuracy(fmodel, init_advs, y)
assert
func_call
tests/test_pointwise_attack.py
test_pointwise_untargeted_attack
51
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_deepfool_run_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmode...
ValueError, match="expected loss to")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_deepfool_run_raises
52
null
bethgelab/foolbox
from foolbox.zoo import fetch_weights from foolbox.zoo.common import home_directory_path, sha256_hash from foolbox.zoo.weights_fetcher import FOLDER import os import pytest import shutil import responses import io import zipfile @responses.activate def test_fetch_weights_returns_404() -> None: weights_uri = "htt...
RuntimeError)
pytest.raises
variable
tests/test_fetch_weights.py
test_fetch_weights_returns_404
74
null
bethgelab/foolbox
from typing import Union, Any from typing_extensions import Literal import pytest import eagerpy as ep import foolbox as fbn @pytest.mark.parametrize("logdir", [False, "temp"]) def test_tensorboard( logdir: Union[Literal[False], None, str], tmp_path: Any, dummy: ep.Tensor ) -> None: if logdir == "temp": ...
before
assert
variable
tests/test_tensorboard.py
test_tensorboard
52
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_genattack_numpy(request: Any) -> None: class Model: def __call__(self, inputs: Any) -> Any: return input...
ValueError, match="data_format")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_genattack_numpy
33
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] @pytest.mark.parametrize("bounds", [(0, 1), (-1.0, 1.0), (0, 255), (-32768, 32767)]) @pytest.mark.parametrize("manual", [True, False]) def test_t...
logits1.numpy())
assert_*
func_call
tests/test_models.py
test_transform_bounds_wrapper
181
null
bethgelab/foolbox
import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription attacks = [ fbn.attacks.InversionAttack(distance=fbn.distances.l2), fbn.attacks.InversionAttack(distance=fbn.distances.l2).repeat(3), fbn.attacks.L2ContrastReductionAttack(), fbn.attacks.L2ContrastR...
AssertionError)
pytest.raises
variable
tests/test_attacks_base.py
test_model_bounds
55
null
bethgelab/foolbox
from typing import Tuple import foolbox as fbn import eagerpy as ep import pytest ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] @pytest.mark.parametrize("batchsize", [42]) @pytest.mark.parametrize("dataset", ["imagenet"]) def test_samples_large_batch( fmodel_and_data: ModelAndData, batchsize: int, dataset...
len(y)
assert
func_call
tests/test_utils.py
test_samples_large_batch
61
null
bethgelab/foolbox
from typing import List, Optional, NamedTuple import pytest import eagerpy as ep import foolbox as fbn import foolbox.attacks as fa from foolbox.gradient_estimators import es_gradient_estimator from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf FGSM_GE = es_gradient_estimator( ...
0
assert
numeric_literal
tests/test_attacks.py
test_untargeted_attacks
199
null
bethgelab/foolbox
import pytest import foolbox as fbn import eagerpy as ep def test_flatten_2d(dummy: ep.Tensor) -> None: x = ep.zeros(dummy, (4, 5)) x = fbn.devutils.flatten(x) assert x.shape ==
(4, 5)
assert
collection
tests/test_devutils.py
test_flatten_2d
25
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_blur_run_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmodel_an...
ValueError, match="to be 1 or 3")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_blur_run_raises
135
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_preprocessing(fmodel_and_data: ModelAndData) -> None: fmodel, x, y = fmodel_and_data if not isinstance(fmodel, fbn.models.base.M...
ValueError)
pytest.raises
variable
tests/test_models.py
test_preprocessing
207
null
bethgelab/foolbox
from typing import Optional, Callable, Tuple, Dict, Any, List, NamedTuple import functools import pytest import eagerpy as ep import foolbox import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] CallableModelAndDataAndDescription = NamedTuple( "CallableModelAndDataAndDescription", [ ...
ValueError, match="data_format")
pytest.raises
complex_expr
tests/conftest.py
numpy_simple_model
311
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_boundary_attack_run_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ ...
ValueError, match="init_attack failed for")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_boundary_attack_run_raises
75
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_dataset_attack_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmo...
ValueError, match="feed")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_dataset_attack_raises
167
null
bethgelab/foolbox
from typing import Tuple, Any, Dict, Callable, TypeVar import numpy as np import pytest import foolbox as fbn import eagerpy as ep distances = { 0: fbn.distances.l0, 1: fbn.distances.l1, 2: fbn.distances.l2, ep.inf: fbn.distances.linf, } data: Dict[str, Callable[..., Tuple[ep.Tensor, ep.Tensor]]] = {}...
str(distances[p])
assert
func_call
tests/test_distances.py
test_distance_repr_str
62
null
bethgelab/foolbox
import pytest import foolbox as fbn import eagerpy as ep def test_flatten_4d(dummy: ep.Tensor) -> None: x = ep.zeros(dummy, (4, 5, 6, 7)) x = fbn.devutils.flatten(x) assert x.shape ==
(4, 210)
assert
collection
tests/test_devutils.py
test_flatten_4d
37
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_jax_no_data_format(request: Any) -> None: backend = request.config.option.backend if backend != "jax": pytest.skip() ...
AttributeError)
pytest.raises
variable
tests/test_models.py
test_jax_no_data_format
90
null
bethgelab/foolbox
from typing import Any import sys import pytest import foolbox as fbn from foolbox.zoo.model_loader import ModelLoader def unload_foolbox_model_module() -> None: # reload foolbox_model from scratch for every run # to ensure atomic tests without side effects module_names = ["foolbox_model", "model"] fo...
fbn.zoo.GitCloneError)
pytest.raises
complex_expr
tests/test_zoo.py
test_loading_invalid_model
73
null
bethgelab/foolbox
from foolbox.zoo import fetch_weights from foolbox.zoo.common import home_directory_path, sha256_hash from foolbox.zoo.weights_fetcher import FOLDER import os import pytest import shutil import responses import io import zipfile @responses.activate def test_fetch_weights_unzipped() -> None: weights_uri = "http:/...
file_path
assert
variable
tests/test_fetch_weights.py
test_fetch_weights_unzipped
31
null
bethgelab/foolbox
import pytest import foolbox as fbn import eagerpy as ep def test_flatten_3d(dummy: ep.Tensor) -> None: x = ep.zeros(dummy, (4, 5, 6)) x = fbn.devutils.flatten(x) assert x.shape ==
(4, 30)
assert
collection
tests/test_devutils.py
test_flatten_3d
31
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_newtonfool_run_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmo...
ValueError, match="unsupported criterion")
pytest.raises
complex_expr
tests/test_attacks_raise.py
test_newtonfool_run_raises
89
null
bethgelab/foolbox
from typing import List, Tuple, Any import pytest import eagerpy as ep import foolbox as fbn from conftest import ModeAndDataAndDescription L2 = fbn.types.L2 Linf = fbn.types.Linf def test_dataset_attack_raises( fmodel_and_data_ext_for_attacks: ModeAndDataAndDescription, ) -> None: (fmodel, x, y), _, _ = fmo...
None
assert
none_literal
tests/test_attacks_raise.py
test_dataset_attack_raises
172
null
bethgelab/foolbox
from typing import Tuple, Any import pytest import eagerpy as ep import numpy as np import copy import foolbox as fbn ModelAndData = Tuple[fbn.Model, ep.Tensor, ep.Tensor] def test_bounds(fmodel_and_data: ModelAndData) -> None: fmodel, x, y = fmodel_and_data min_, max_ = fmodel.bounds assert min_ <
max_
assert
variable
tests/test_models.py
test_bounds
15
null
bethgelab/foolbox
import pytest import foolbox as fbn import eagerpy as ep @pytest.mark.parametrize("k", [1, 2, 3, 4]) def test_atleast_kd_3d(dummy: ep.Tensor, k: int) -> None: x = ep.zeros(dummy, (10, 5, 3)) x = fbn.devutils.atleast_kd(x, k) assert x.shape[:3] == (10, 5, 3) assert x.ndim ==
max(k, 3)
assert
func_call
tests/test_devutils.py
test_atleast_kd_3d
19
null
taylorwilsdon/google_workspace_mcp
import sys import os import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from auth.permissions import ( get_scopes_for_permission, parse_permissions_arg, SERVICE_PERMISSION_LEVELS, ) from auth.scopes import ( GMAIL_READONLY_SCOPE, GMAIL_LABELS_SCOPE, ...
{}
assert
collection
tests/test_permissions.py
test_empty_list_returns_empty
TestParsePermissionsArg
64
null
taylorwilsdon/google_workspace_mcp
import pytest from starlette.requests import Request from starlette.responses import FileResponse, JSONResponse from core.server import serve_attachment def _build_request(file_id: str) -> Request: scope = { "type": "http", "asgi": {"version": "3.0"}, "http_version": "1.1", "method...
404
assert
numeric_literal
tests/core/test_attachment_route.py
test_serve_attachment_404_when_metadata_missing
68
null
taylorwilsdon/google_workspace_mcp
import os import sys import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) import main def test_permissions_and_tools_flags_are_rejected(monkeypatch, capsys): monkeypatch.setattr(main, "configure_safe_logging", lambda: None) monkeypatch.setattr( sys, ...
captured.err
assert
complex_expr
tests/test_main_permissions_tier.py
test_permissions_and_tools_flags_are_rejected
60
null
taylorwilsdon/google_workspace_mcp
import os import sys import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) import main def test_resolve_permissions_mode_selection_with_tier_filters_services(monkeypatch): def fake_resolve_tools_from_tier(tier, services): assert tier == "core" assert se...
["gmail"]
assert
collection
tests/test_main_permissions_tier.py
test_resolve_permissions_mode_selection_with_tier_filters_services
31
null
taylorwilsdon/google_workspace_mcp
import pytest from unittest.mock import AsyncMock, Mock from gdocs.docs_helpers import ( build_paragraph_style, create_update_paragraph_style_request, ) from gdocs.managers.validation_manager import ValidationManager class TestBuildParagraphStyle: def test_heading_out_of_range_raises(self): with...
ValueError)
pytest.raises
variable
tests/gdocs/test_paragraph_style.py
test_heading_out_of_range_raises
TestBuildParagraphStyle
32
null
taylorwilsdon/google_workspace_mcp
import os import socket import sys import httpx import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gdrive import drive_tools @pytest.mark.asyncio async def test_fetch_url_with_pinned_ip_uses_pinned_target_and_host_header(monkeypatch): """Requests should targ...
"example.com"
assert
string_literal
tests/gdrive/test_ssrf_protections.py
test_fetch_url_with_pinned_ip_uses_pinned_target_and_host_header
122
null
taylorwilsdon/google_workspace_mcp
import pytest from unittest.mock import AsyncMock, Mock from gdocs.docs_helpers import ( build_paragraph_style, create_update_paragraph_style_request, ) from gdocs.managers.validation_manager import ValidationManager class TestBatchManagerIntegration: def manager(self): from gdocs.managers.batch_...
desc
assert
variable
tests/gdocs/test_paragraph_style.py
test_build_request_and_description
TestBatchManagerIntegration
121
null
taylorwilsdon/google_workspace_mcp
import base64 import os import sys import pytest def test_os_open_with_o_binary_preserves_bytes(tmp_path): """os.open with O_BINARY writes binary data correctly on all platforms.""" payload = b"\x89PNG\r\n\x1a\n" + b"\x00" * 50 tmp = str(tmp_path / "test_with_binary.bin") flags = os.O_WRONLY | os.O_C...
payload
assert
variable
tests/gmail/test_attachment_fix.py
test_os_open_with_o_binary_preserves_bytes
55
null
taylorwilsdon/google_workspace_mcp
import os import socket import sys import httpx import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gdrive import drive_tools @pytest.mark.asyncio async def test_fetch_url_with_pinned_ip_uses_pinned_target_and_host_header(monkeypatch): """Requests should targ...
"GET"
assert
string_literal
tests/gdrive/test_ssrf_protections.py
test_fetch_url_with_pinned_ip_uses_pinned_target_and_host_header
120
null
taylorwilsdon/google_workspace_mcp
import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from auth.scopes import ( BASE_SCOPES, CALENDAR_READONLY_SCOPE, CALENDAR_SCOPE, CONTACTS_READONLY_SCOPE, CONTACTS_SCOPE, DRIVE_FILE_SCOPE, DRIVE_READONLY_SCOPE, DRIVE_SCOPE, GMAI...
expected
assert
variable
tests/test_scopes.py
test_permissions_mode_returns_base_plus_permission_scopes
TestGranularPermissionsScopes
221
null
taylorwilsdon/google_workspace_mcp
import os import socket import sys import httpx import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gdrive import drive_tools def test_resolve_and_validate_host_fails_closed_on_dns_error(monkeypatch): """DNS resolution failures must fail closed.""" def f...
ValueError, match="Refusing request \\(fail-closed\\)")
pytest.raises
func_call
tests/gdrive/test_ssrf_protections.py
test_resolve_and_validate_host_fails_closed_on_dns_error
25
null
taylorwilsdon/google_workspace_mcp
import pytest from unittest.mock import Mock import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gsheets.sheets_tools import _format_sheet_range_impl def create_mock_service(): """Create a properly configured mock Google Sheets service.""" mock_serv...
12
assert
numeric_literal
tests/gsheets/test_format_sheet_range.py
test_format_all_new_params_with_existing
322
null
taylorwilsdon/google_workspace_mcp
import pytest from unittest.mock import Mock import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gsheets.sheets_tools import _format_sheet_range_impl def create_mock_service(): """Create a properly configured mock Google Sheets service.""" mock_serv...
14
assert
numeric_literal
tests/gsheets/test_format_sheet_range.py
test_format_font_size
247
null
taylorwilsdon/google_workspace_mcp
import sys import os import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from auth.permissions import ( get_scopes_for_permission, parse_permissions_arg, SERVICE_PERMISSION_LEVELS, ) from auth.scopes import ( GMAIL_READONLY_SCOPE, GMAIL_LABELS_SCOPE, ...
scopes
assert
variable
tests/test_permissions.py
test_gmail_readonly_returns_readonly_scope
TestGetScopesForPermission
77
null
taylorwilsdon/google_workspace_mcp
import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) from auth.scopes import ( BASE_SCOPES, CALENDAR_READONLY_SCOPE, CALENDAR_SCOPE, CONTACTS_READONLY_SCOPE, CONTACTS_SCOPE, DRIVE_FILE_SCOPE, DRIVE_READONLY_SCOPE, DRIVE_SCOPE, GMAI...
without_permissions
assert
variable
tests/test_scopes.py
test_permissions_mode_overrides_read_only_and_full_maps
TestGranularPermissionsScopes
226
null
taylorwilsdon/google_workspace_mcp
import os import sys import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))) import main def test_resolve_permissions_mode_selection_without_tier(): services = ["gmail", "drive"] resolved_services, tier_tool_filter = main.resolve_permissions_mode_selection( s...
services
assert
variable
tests/test_main_permissions_tier.py
test_resolve_permissions_mode_selection_without_tier
16
null
taylorwilsdon/google_workspace_mcp
import os import socket import sys import httpx import pytest sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gdrive import drive_tools def test_resolve_and_validate_host_rejects_ipv6_private(monkeypatch): """IPv6 internal addresses must be rejected.""" def fake_g...
ValueError, match="private/internal networks")
pytest.raises
complex_expr
tests/gdrive/test_ssrf_protections.py
test_resolve_and_validate_host_rejects_ipv6_private
45
null
taylorwilsdon/google_workspace_mcp
import sys import os sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../.."))) from gdocs.docs_markdown import ( convert_doc_to_markdown, format_comments_appendix, format_comments_inline, parse_drive_comments, ) SIMPLE_DOC = { "title": "Simple Test", "body": { ...
""
assert
string_literal
tests/gdocs/test_docs_markdown.py
test_empty
TestEmptyDoc
339
null
taylorwilsdon/google_workspace_mcp
import pytest from unittest.mock import AsyncMock, Mock from gdocs.docs_helpers import ( build_paragraph_style, create_update_paragraph_style_request, ) from gdocs.managers.validation_manager import ValidationManager class TestValidateParagraphStyleParams: def vm(self): return ValidationManager()...
msg
assert
variable
tests/gdocs/test_paragraph_style.py
test_negative_indent_start_rejected
TestValidateParagraphStyleParams
80
null