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
syrupy-project/syrupy
import datetime import pytest from syrupy.filters import ( paths, paths_include, props, ) def test_includes_nested_path(snapshot): actual = { "ignore-me": True, "include-me": False, "layer1": {"layer2": [0, True]}, } assert actual ==
snapshot( include=paths_include(["include-me"], ["layer1", "layer2", "1"]) )
assert
func_call
tests/syrupy/extensions/amber/test_amber_filters.py
test_includes_nested_path
60
null
syrupy-project/syrupy
from syrupy.assertion import DiffMode def test_can_be_stringified(snapshot): assert snapshot == str(DiffMode.DETAILED) assert snapshot ==
str(DiffMode.DISABLED)
assert
func_call
tests/syrupy/test_diff_mode.py
test_can_be_stringified
6
null
syrupy-project/syrupy
from pathlib import Path from unittest.mock import MagicMock import pytest from syrupy.constants import PYTEST_NODE_SEP from syrupy.location import PyTestLocation def mock_pytest_item(node_id: str, method_name: str) -> "pytest.Item": mock_node = MagicMock(spec=pytest.Item) mock_node.nodeid = node_id [fil...
expected_filename
assert
variable
tests/syrupy/test_location.py
test_location_properties
57
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_empty_snapshot(snapsho...
None
assert
none_literal
tests/syrupy/extensions/json/test_json_serializer.py
test_empty_snapshot
27
null
syrupy-project/syrupy
from pathlib import Path import pytest from syrupy.exceptions import FailedToLoadModuleMember from syrupy.utils import ( import_module_member, walk_snapshot_dir, ) def makefiles(testdir, filetree, root=""): for filename, contents in filetree.items(): filepath = Path(root).joinpath(filename) ...
{ str(snap_folder.joinpath("snapfile1.ambr")), str(snap_folder.joinpath("snapfolder", "snapfile2.svg")), }
assert
collection
tests/syrupy/test_utils.py
test_walk_dir_skips_non_snapshot_path
44
null
syrupy-project/syrupy
import base64 import pytest from syrupy.extensions.image import PNGImageSnapshotExtension actual_png = base64.b64decode( b"iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAG1BMVEXMzMy" b"Wlpaqqqq3t7exsbGcnJy+vr6jo6PFxcUFpPI/AAAACXBIWXMAAA7EAAAOxA" b"GVKw4bAAAAQUlEQVQ4jWNgGAWjgP6ASdncAEaiAhaGiACmFhCJLsMaIi...
snapshot(extension_class=PNGImageSnapshotExtension)
assert
func_call
tests/syrupy/extensions/image/test_image_png.py
test_multiple_snapshot_extensions
30
null
syrupy-project/syrupy
import pytest def testfile(testdir) -> pytest.Testdir: testdir.makepyfile( test_file=( """ def test_case(snapshot): assert snapshot == "some-value" """ ), ) return testdir def test_diff_mode_disabled_does_not_print_diff( testfile, ): ...
0
assert
numeric_literal
tests/integration/test_snapshot_option_diff_mode.py
test_diff_mode_disabled_does_not_print_diff
23
null
syrupy-project/syrupy
import datetime import pytest from syrupy.filters import ( paths, paths_include, props, ) def test_only_includes_expected_props(snapshot): actual = { 0: "some value", "date": "utc", "nested": {"id": 4, "other": "value"}, "list": [1, 2], } # Note that "id" won't...
snapshot(include=paths("0", "date", "nested", "nested.id"))
assert
func_call
tests/syrupy/extensions/amber/test_amber_filters.py
test_only_includes_expected_props
51
null
syrupy-project/syrupy
from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.filters import props from syrupy.matchers import path_type def test_snapshot_custom_class(snapshot): assert MyCustomClass() ==
snapshot
assert
variable
tests/examples/test_custom_object_repr.py
test_snapshot_custom_class
13
null
syrupy-project/syrupy
import pytest def testcases_initial(testdir): testdir.makeconftest( """ import pytest from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.extensions.image import ( PNGImageSnapshotExtension, SVGImageSnapshotExtension, ) fro...
result.stdout.str()
assert
func_call
tests/integration/test_snapshot_use_extension.py
test_generated_snapshots
117
null
syrupy-project/syrupy
from pathlib import Path def test_multiple_file_extensions(testdir, plugin_args_fails_xdist): file_extension = "ext2.ext1" testcase = f""" import pytest from syrupy.extensions.single_file import SingleFileSnapshotExtension class DotInFileExtension(SingleFileSnapshotExtension): file_extens...
result.stdout.str()
assert
func_call
tests/integration/test_single_file_multiple_extensions.py
test_multiple_file_extensions
26
null
syrupy-project/syrupy
import datetime import uuid import pytest from syrupy.extensions.amber.serializer import ( AmberDataSerializer, Repr, ) from syrupy.matchers import ( PathTypeError, compose_matchers, path_type, path_value, ) def test_multiple_matchers(snapshot): data = {"number": 1, "datetime": datetime.d...
snapshot( matcher=compose_matchers( path_type(types=(list,), replacer=lambda *_: "DO_NOT_MATCH"), path_type(types=(int, float), replacer=lambda *_: "MATCHER_1"), path_type(types=(datetime.datetime,), replacer=lambda *_: "MATCHER_2"), ), )
assert
func_call
tests/syrupy/extensions/amber/test_amber_matchers.py
test_multiple_matchers
137
null
syrupy-project/syrupy
import datetime import uuid import pytest from syrupy.extensions.amber.serializer import ( AmberDataSerializer, Repr, ) from syrupy.matchers import ( PathTypeError, compose_matchers, path_type, path_value, ) def test_raises_unexpected_type(snapshot): kwargs = { "mapping": { ...
snapshot(matcher=path_type(**kwargs, strict=False))
assert
func_call
tests/syrupy/extensions/amber/test_amber_matchers.py
test_raises_unexpected_type
51
null
syrupy-project/syrupy
import pytest from syrupy.extensions.single_file import SingleFileAmberSnapshotExtension def snapshot_single(snapshot): return snapshot.use_extension(SingleFileAmberSnapshotExtension) def test_amber_single_file(snapshot_single): assert snapshot_single == 1 assert snapshot_single ==
{"a": "b"}
assert
collection
tests/syrupy/extensions/test_amber_single_file.py
test_amber_single_file
13
null
syrupy-project/syrupy
import pytest from syrupy.extensions.amber import AmberSnapshotExtension DIFFERENT_DIRECTORY = "__snaps_example__" def snapshot(snapshot): return snapshot.use_extension(DifferentDirectoryExtension) def test_case_1(snapshot): assert "Syrupy is amazing!" ==
snapshot
assert
variable
tests/examples/test_custom_snapshot_directory.py
test_case_1
30
null
syrupy-project/syrupy
import pytest def testfile(testdir) -> pytest.Testdir: testdir.makepyfile( test_file=( """ def test_case(snapshot): assert snapshot == "some-value" """ ), ) return testdir def test_diff_mode_disabled_does_not_print_diff( testfile, ): ...
1
assert
numeric_literal
tests/integration/test_snapshot_option_diff_mode.py
test_diff_mode_disabled_does_not_print_diff
43
null
syrupy-project/syrupy
from pathlib import Path def test_multiple_file_extensions(testdir, plugin_args_fails_xdist): file_extension = "ext2.ext1" testcase = f""" import pytest from syrupy.extensions.single_file import SingleFileSnapshotExtension class DotInFileExtension(SingleFileSnapshotExtension): file_extens...
0
assert
numeric_literal
tests/integration/test_single_file_multiple_extensions.py
test_multiple_file_extensions
27
null
syrupy-project/syrupy
import pytest from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.location import PyTestLocation from syrupy.types import SnapshotIndex def snapshot(snapshot): return snapshot.use_extension(CanadianNameExtension) def test_canadian_name(snapshot): assert "Name should be test_canadian_name�...
snapshot
assert
variable
tests/examples/test_custom_snapshot_name.py
test_canadian_name
29
null
syrupy-project/syrupy
import pytest from syrupy.constants import DIFF_LINE_COUNT_LIMIT from syrupy.extensions.base import SnapshotReporter class TestSnapshotReporter: @pytest.mark.parametrize( "a, b", [ ( "line 0\nline 1\nline 02\nline 3\nline 4\r\nline 5\nline 6\nline 7", "l...
snapshot
assert
variable
tests/syrupy/extensions/test_base.py
test_diff_lines
TestSnapshotReporter
35
null
syrupy-project/syrupy
def test_trailing_no_newline_in_repr(snapshot): assert ReprWithNewline(0) ==
snapshot
assert
variable
tests/syrupy/extensions/amber/test_amber_newlines.py
test_trailing_no_newline_in_repr
11
null
syrupy-project/syrupy
import pytest from syrupy.extensions.image import SVGImageSnapshotExtension actual_svg = ( '<?xml version="1.0" encoding="UTF-8"?>' '<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">' '<g><rect width="50" height="50" fill="#fff"/>' '<g><g fill="#fff" stroke="#707070">' '<rect width="50"...
snapshot()
assert
func_call
tests/syrupy/extensions/image/test_image_svg.py
test_multiple_snapshot_extensions
33
null
syrupy-project/syrupy
import pytest from syrupy.extensions.image import SVGImageSnapshotExtension actual_svg = ( '<?xml version="1.0" encoding="UTF-8"?>' '<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">' '<g><rect width="50" height="50" fill="#fff"/>' '<g><g fill="#fff" stroke="#707070">' '<rect width="50"...
None
assert
none_literal
tests/syrupy/extensions/image/test_image_svg.py
test_multiple_snapshot_extensions
34
null
syrupy-project/syrupy
from pathlib import Path from typing import TYPE_CHECKING import pytest from syrupy.data import ( Snapshot, SnapshotCollection, ) from syrupy.extensions.single_file import ( SingleFileSnapshotExtension, WriteMode, ) def snapshot_single(snapshot): return snapshot.use_extension(SingleFileSnapshotEx...
content
assert
variable
tests/syrupy/extensions/test_single_file.py
test_special_characters
66
null
syrupy-project/syrupy
import pytest def testcases_initial(testdir): testdir.makeconftest( """ import pytest from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.extensions.image import ( PNGImageSnapshotExtension, SVGImageSnapshotExtension, ) fro...
1
assert
numeric_literal
tests/integration/test_snapshot_use_extension.py
test_unsaved_snapshots
104
null
syrupy-project/syrupy
import pytest def testcases(): return { "base": ( """ def test_a(snapshot): assert snapshot(name="xyz") == "case 1" assert snapshot(name="zyx") == "case 2" """ ), "modified": ( """ def test_a(snapsho...
str(result.stdout)
assert
func_call
tests/integration/test_snapshot_option_name.py
test_update
54
null
syrupy-project/syrupy
import base64 import pytest from syrupy.extensions.image import PNGImageSnapshotExtension def snapshot(snapshot): return snapshot.use_extension(PNGImageSnapshotExtension) def test_png_image_with_custom_name_suffix(snapshot): reddish_square = base64.b64decode( b"iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAA...
snapshot(name="reddish")
assert
func_call
tests/examples/test_custom_image_name_suffix.py
test_png_image_with_custom_name_suffix
25
null
syrupy-project/syrupy
import datetime import pytest from syrupy.filters import ( paths, paths_include, props, ) def test_filters_path_noop(): with pytest.raises(
TypeError, match="At least 1 path argument is required.")
pytest.raises
complex_expr
tests/syrupy/extensions/amber/test_amber_filters.py
test_filters_path_noop
13
null
syrupy-project/syrupy
from types import MappingProxyType import pytest def test_snapshot_diff(snapshot): my_dict = { "field_0": True, "field_1": "no_value", "nested": { "field_0": 1, }, } assert my_dict == snapshot my_dict["field_1"] = "yes_value" assert my_dict ==
snapshot(diff=0)
assert
func_call
tests/syrupy/extensions/amber/test_amber_snapshot_diff.py
test_snapshot_diff
16
null
syrupy-project/syrupy
import datetime import uuid import pytest from syrupy.extensions.amber.serializer import ( AmberDataSerializer, Repr, ) from syrupy.matchers import ( PathTypeError, compose_matchers, path_type, path_value, ) def test_raises_unexpected_type(snapshot): kwargs = { "mapping": { ...
snapshot(matcher=path_type(**kwargs))
assert
func_call
tests/syrupy/extensions/amber/test_amber_matchers.py
test_raises_unexpected_type
53
null
syrupy-project/syrupy
import datetime import uuid import pytest from syrupy.extensions.amber.serializer import ( AmberDataSerializer, Repr, ) from syrupy.matchers import ( PathTypeError, compose_matchers, path_type, path_value, ) def test_matches_non_deterministic_snapshots(snapshot): def matcher(data, path): ...
snapshot
assert
variable
tests/syrupy/extensions/amber/test_amber_matchers.py
test_matches_non_deterministic_snapshots
71
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) @pytest.mark.parametrize( "...
actual
assert
variable
tests/syrupy/extensions/json/test_json_serializer.py
test_string
87
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_numbers(snapshot_json)...
3.5
assert
numeric_literal
tests/syrupy/extensions/json/test_json_serializer.py
test_numbers
143
null
syrupy-project/syrupy
from pathlib import Path import pytest from syrupy.extensions.json import JSONSnapshotExtension from syrupy.location import PyTestLocation def create_versioned_fixture(version: int): class VersionedJSONExtension(JSONSnapshotExtension): snapshot_dirname = Path("__snapshots__") / Path(f"v{version}") ...
snapshot_v2
assert
variable
tests/examples/test_custom_snapshot_directory_2.py
test_case_v2
55
null
syrupy-project/syrupy
import pytest from syrupy.extensions.image import SVGImageSnapshotExtension actual_svg = ( '<?xml version="1.0" encoding="UTF-8"?>' '<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">' '<g><rect width="50" height="50" fill="#fff"/>' '<g><g fill="#fff" stroke="#707070">' '<rect width="50"...
snapshot_svg
assert
variable
tests/syrupy/extensions/image/test_image_svg.py
test_image
24
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_multiple_snapshots(sna...
"Second.")
assert_*
string_literal
tests/syrupy/extensions/json/test_json_serializer.py
test_multiple_snapshots
92
null
syrupy-project/syrupy
import base64 import pytest from syrupy.extensions.single_file import SingleFileSnapshotExtension def snapshot(snapshot): return snapshot.use_extension(JPEGImageExtension) def test_jpeg_image(snapshot): reddish_square = base64.b64decode( b"/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAP//////////////////////////...
snapshot
assert
variable
tests/examples/test_custom_image_extension.py
test_jpeg_image
42
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer def test_numbers(snapshot): assert snapshot ==
3.5
assert
numeric_literal
tests/syrupy/extensions/amber/test_amber_serializer.py
test_numbers
139
null
syrupy-project/syrupy
import traceback from collections import namedtuple from collections.abc import Callable from dataclasses import ( dataclass, field, ) from enum import Enum from gettext import gettext from typing import ( TYPE_CHECKING, Any, Optional, ) from .exceptions import ( SnapshotDoesNotExist, Taint...
data
assert
variable
src/syrupy/assertion.py
assert_match
SnapshotAssertion
211
null
syrupy-project/syrupy
from dataclasses import dataclass import attr import pytest from pydantic import BaseModel from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.extensions.amber.attrs_plugin import AttrsPlugin from syrupy.extensions.amber.dataclasses_plugin import DataclassPlugin from syrupy.extensions.amber.pydanti...
snapshot_pydantic
assert
variable
tests/syrupy/extensions/amber/test_amber_serializer_plugins.py
test_pydantic_plugin
149
null
syrupy-project/syrupy
from syrupy.assertion import DiffMode def test_can_be_stringified(snapshot): assert snapshot ==
str(DiffMode.DETAILED)
assert
func_call
tests/syrupy/test_diff_mode.py
test_can_be_stringified
5
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_numbers(snapshot_json)...
7
assert
numeric_literal
tests/syrupy/extensions/json/test_json_serializer.py
test_numbers
144
null
syrupy-project/syrupy
from pathlib import Path import pytest from syrupy.extensions.json import JSONSnapshotExtension from syrupy.location import PyTestLocation def create_versioned_fixture(version: int): class VersionedJSONExtension(JSONSnapshotExtension): snapshot_dirname = Path("__snapshots__") / Path(f"v{version}") ...
snapshot_v1
assert
variable
tests/examples/test_custom_snapshot_directory_2.py
test_case_v1
51
null
syrupy-project/syrupy
import pytest def testcases(testdir, tmp_path, request): dirname = tmp_path.joinpath(request.param) testdir.makeconftest( f""" import pytest from syrupy.extensions.amber import AmberSnapshotExtension class CustomSnapshotExtension(AmberSnapshotExtension): @classmeth...
1
assert
numeric_literal
tests/integration/test_snapshot_outside_directory.py
test_unmatched_snapshots
65
null
syrupy-project/syrupy
import pytest def testcases(): return { "used": ( """ def test_used(snapshot): assert snapshot == 'used' """ ), "unused": ( """ def test_unused(snapshot): assert snapshot == 'unused' """ ...
0
assert
numeric_literal
tests/integration/test_snapshot_option_include_details.py
test_unused_snapshots_details_no_details_on_deletion
148
null
syrupy-project/syrupy
import pytest from syrupy.extensions.image import SVGImageSnapshotExtension actual_svg = ( '<?xml version="1.0" encoding="UTF-8"?>' '<svg viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">' '<g><rect width="50" height="50" fill="#fff"/>' '<g><g fill="#fff" stroke="#707070">' '<rect width="50"...
snapshot(extension_class=SVGImageSnapshotExtension)
assert
func_call
tests/syrupy/extensions/image/test_image_svg.py
test_multiple_snapshot_extensions
32
null
syrupy-project/syrupy
import pytest def testcases_initial(testdir): testdir.makeconftest( """ import pytest from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.extensions.image import ( PNGImageSnapshotExtension, SVGImageSnapshotExtension, ) fro...
0
assert
numeric_literal
tests/integration/test_snapshot_use_extension.py
test_generated_snapshots
118
null
syrupy-project/syrupy
import pytest from syrupy.extensions.json import JSONSnapshotExtension from syrupy.filters import paths from syrupy.matchers import path_type def snapshot_matcher(snapshot): return snapshot.with_defaults(matcher=path_type(mapping={"my-field": (str, int)})) def snapshot_exclude(snapshot_matcher): return snaps...
snapshot_json
assert
variable
tests/examples/test_custom_defaults.py
test_asserting_multiple_times_chained_json
42
null
syrupy-project/syrupy
from pathlib import Path import pytest from syrupy.exceptions import FailedToLoadModuleMember from syrupy.utils import ( import_module_member, walk_snapshot_dir, ) def makefiles(testdir, filetree, root=""): for filename, contents in filetree.items(): filepath = Path(root).joinpath(filename) ...
discovered_files
assert
variable
tests/syrupy/test_utils.py
test_walk_dir_ignores_ignored_extensions
77
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer def test_numbers(snapshot): assert snapshot == 3.5 assert snapshot ==
7
assert
numeric_literal
tests/syrupy/extensions/amber/test_amber_serializer.py
test_numbers
140
null
syrupy-project/syrupy
import datetime import pytest from syrupy.filters import ( paths, paths_include, props, ) def test_only_includes_expected_props(snapshot): actual = { 0: "some value", "date": "utc", "nested": {"id": 4, "other": "value"}, "list": [1, 2], } # Note that "id" won't...
snapshot(include=props("0", "date", "id"))
assert
func_call
tests/syrupy/extensions/amber/test_amber_filters.py
test_only_includes_expected_props
50
null
syrupy-project/syrupy
from dataclasses import dataclass import attr import pytest from pydantic import BaseModel from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.extensions.amber.attrs_plugin import AttrsPlugin from syrupy.extensions.amber.dataclasses_plugin import DataclassPlugin from syrupy.extensions.amber.pydanti...
snapshot_mixed
assert
variable
tests/syrupy/extensions/amber/test_amber_serializer_plugins.py
test_mixed_plugins
163
null
syrupy-project/syrupy
import pytest from syrupy.extensions.single_file import SingleFileAmberSnapshotExtension def snapshot_single(snapshot): return snapshot.use_extension(SingleFileAmberSnapshotExtension) def test_amber_single_file(snapshot_single): assert snapshot_single ==
1
assert
numeric_literal
tests/syrupy/extensions/test_amber_single_file.py
test_amber_single_file
12
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_numbers(snapshot_json)...
2 / 6
assert
complex_expr
tests/syrupy/extensions/json/test_json_serializer.py
test_numbers
145
null
syrupy-project/syrupy
import pytest def testcases_initial(testdir): testdir.makeconftest( """ import pytest import math from syrupy.extensions.amber import AmberSnapshotExtension class CustomSnapshotExtension(AmberSnapshotExtension): def matches(self, *, serialized_data, snapshot_da...
result.stdout.str()
assert
func_call
tests/integration/test_custom_comparator.py
test_generated_snapshots
55
null
syrupy-project/syrupy
from pathlib import Path from typing import TYPE_CHECKING import pytest from syrupy.data import ( Snapshot, SnapshotCollection, ) from syrupy.extensions.single_file import ( SingleFileSnapshotExtension, WriteMode, ) def snapshot_single(snapshot): return snapshot.use_extension(SingleFileSnapshotEx...
b"apple"
assert
string_literal
tests/syrupy/extensions/test_single_file.py
test_underscore
55
null
syrupy-project/syrupy
import sys from pathlib import Path import pytest def testcases_initial(): return { "test_used": ( """ import pytest @pytest.mark.parametrize("actual", [1, 2, 3]) def test_used(snapshot, actual): assert snapshot == actual def te...
1
assert
numeric_literal
tests/integration/test_snapshot_option_update.py
test_update_failure_shows_snapshot_diff
183
null
syrupy-project/syrupy
from pathlib import Path from typing import TYPE_CHECKING import pytest from syrupy.data import ( Snapshot, SnapshotCollection, ) from syrupy.extensions.single_file import ( SingleFileSnapshotExtension, WriteMode, ) def snapshot_single(snapshot): return snapshot.use_extension(SingleFileSnapshotEx...
b"this is in a test class"
assert
string_literal
tests/syrupy/extensions/test_single_file.py
test_class_method_name
TestClass
47
null
syrupy-project/syrupy
from pathlib import Path import pytest from syrupy.exceptions import FailedToLoadModuleMember from syrupy.utils import ( import_module_member, walk_snapshot_dir, ) def makefiles(testdir, filetree, root=""): for filename, contents in filetree.items(): filepath = Path(root).joinpath(filename) ...
{ str(Path("__snapshots__").joinpath("snapfile1.ambr")), str(Path("__snapshots__").joinpath("snapfolder", "snapfile2.svg")), }
assert
collection
tests/syrupy/test_utils.py
test_walk_dir_ignores_ignored_extensions
72
null
syrupy-project/syrupy
from pathlib import Path def test_ignore_file_extensions(testdir): # Generate initial snapshot file testdir.makepyfile( test_file=( """ def test_case(snapshot): assert snapshot == "some-value" """ ), ) result = testdir.runpytest("-v", ...
0
assert
numeric_literal
tests/integration/test_snapshot_option_ignore_file_extensions.py
test_ignore_file_extensions
16
null
syrupy-project/syrupy
import datetime import pytest from syrupy.filters import ( paths, paths_include, props, ) @pytest.mark.parametrize( "predicate", [paths("exclude_me", "nested.exclude_me"), props("exclude_me")] ) def test_filters_error_prop(snapshot, predicate): class CustomClass: @property def inc...
snapshot(exclude=predicate)
assert
func_call
tests/syrupy/extensions/amber/test_amber_filters.py
test_filters_error_prop
81
null
syrupy-project/syrupy
def test_does_not_print_empty_snapshot_report(testdir, plugin_args_fails_xdist): testdir.makeconftest("") testcase_no_snapshots = """ def test_example(snapshot): assert 1 """ testcase_yes_snapshots = """ def test_example(snapshot): assert snapshot == 1 ...
result.stdout.str()
assert
func_call
tests/integration/test_pytest_extension.py
test_does_not_print_empty_snapshot_report
67
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer @pytest.mark.parametrize( "actual", [ "", r"Raw string", r"Escaped \n", r"Backslash \u U", "🥞🐍🍯", "singleline:", ...
actual
assert
variable
tests/syrupy/extensions/amber/test_amber_serializer.py
test_string
84
null
syrupy-project/syrupy
import base64 import pytest from syrupy.extensions.image import PNGImageSnapshotExtension def snapshot(snapshot): return snapshot.use_extension(PNGImageSnapshotExtension) def test_png_image_with_custom_name_suffix(snapshot): reddish_square = base64.b64decode( b"iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAIAAA...
snapshot(name="blueish")
assert
func_call
tests/examples/test_custom_image_name_suffix.py
test_png_image_with_custom_name_suffix
24
null
syrupy-project/syrupy
from pathlib import Path from typing import TYPE_CHECKING import pytest from syrupy.data import ( Snapshot, SnapshotCollection, ) from syrupy.extensions.single_file import ( SingleFileSnapshotExtension, WriteMode, ) def snapshot_single(snapshot): return snapshot.use_extension(SingleFileSnapshotEx...
TypeError, match="Expected 'bytes', got 'str'")
pytest.raises
complex_expr
tests/syrupy/extensions/test_single_file.py
test_does_not_write_non_binary
38
null
syrupy-project/syrupy
import pytest def testcases(): return { "base": ( """ def test_a(snapshot): assert snapshot(name="xyz") == "case 1" assert snapshot(name="zyx") == "case 2" """ ), "modified": ( """ def test_a(snapsho...
1
assert
numeric_literal
tests/integration/test_snapshot_option_name.py
test_failure
47
null
syrupy-project/syrupy
from dataclasses import dataclass import attr import pytest from pydantic import BaseModel from syrupy.extensions.amber import AmberSnapshotExtension from syrupy.extensions.amber.attrs_plugin import AttrsPlugin from syrupy.extensions.amber.dataclasses_plugin import DataclassPlugin from syrupy.extensions.amber.pydanti...
snapshot_dataclass
assert
variable
tests/syrupy/extensions/amber/test_amber_serializer_plugins.py
test_dataclasses_plugin
143
null
syrupy-project/syrupy
import pytest from syrupy.extensions.json import JSONSnapshotExtension from syrupy.filters import paths from syrupy.matchers import path_type def snapshot_matcher(snapshot): return snapshot.with_defaults(matcher=path_type(mapping={"my-field": (str, int)})) def snapshot_exclude(snapshot_matcher): return snaps...
snapshot_exclude
assert
variable
tests/examples/test_custom_defaults.py
test_asserting_multiple_times_chained
37
null
syrupy-project/syrupy
import pytest def testcases(testdir, tmp_path, request): dirname = tmp_path.joinpath(request.param) testdir.makeconftest( f""" import pytest from syrupy.extensions.amber import AmberSnapshotExtension class CustomSnapshotExtension(AmberSnapshotExtension): @classmeth...
0
assert
numeric_literal
tests/integration/test_snapshot_outside_directory.py
test_generated_snapshots
57
null
syrupy-project/syrupy
import base64 import pytest from syrupy.extensions.image import PNGImageSnapshotExtension actual_png = base64.b64decode( b"iVBORw0KGgoAAAANSUhEUgAAADIAAAAyBAMAAADsEZWCAAAAG1BMVEXMzMy" b"Wlpaqqqq3t7exsbGcnJy+vr6jo6PFxcUFpPI/AAAACXBIWXMAAA7EAAAOxA" b"GVKw4bAAAAQUlEQVQ4jWNgGAWjgP6ASdncAEaiAhaGiACmFhCJLsMaIi...
snapshot()
assert
func_call
tests/syrupy/extensions/image/test_image_png.py
test_multiple_snapshot_extensions
31
null
syrupy-project/syrupy
import datetime import uuid import pytest from syrupy.extensions.amber.serializer import ( AmberDataSerializer, Repr, ) from syrupy.matchers import ( PathTypeError, compose_matchers, path_type, path_value, ) def test_matches_expected_type(snapshot): my_matcher = path_type( {"date_...
snapshot(matcher=my_matcher)
assert
func_call
tests/syrupy/extensions/amber/test_amber_matchers.py
test_matches_expected_type
33
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_tuple(snapshot_json): ...
()
assert
collection
tests/syrupy/extensions/json/test_json_serializer.py
test_tuple
102
null
syrupy-project/syrupy
import pytest def testcases_initial(testdir): testdir.makeconftest( """ import pytest import math from syrupy.extensions.amber import AmberSnapshotExtension class CustomSnapshotExtension(AmberSnapshotExtension): def matches(self, *, serialized_data, snapshot_da...
0
assert
numeric_literal
tests/integration/test_custom_comparator.py
test_generated_snapshots
56
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer from syrupy.extensions.json import JSONSnapshotExtension def snapshot_json(snapshot): return snapshot.use_extension(JSONSnapshotExtension) def test_reflection(snapshot_js...
snapshot_json
assert
variable
tests/syrupy/extensions/json/test_json_serializer.py
test_reflection
23
null
syrupy-project/syrupy
from collections import ( OrderedDict, namedtuple, ) import pytest from syrupy.extensions.amber.serializer import AmberDataSerializer def test_numbers(snapshot): assert snapshot == 3.5 assert snapshot == 7 assert snapshot ==
2 / 6
assert
complex_expr
tests/syrupy/extensions/amber/test_amber_serializer.py
test_numbers
141
null
asteroid-team/asteroid
import torch import pytest from torch.testing import assert_close import numpy as np import soundfile as sf import asteroid from asteroid import models from asteroid_filterbanks import make_enc_dec from asteroid.dsp import LambdaOverlapAdd from asteroid.models.fasnet import FasNetTAC from asteroid.separate import separ...
TypeError)
pytest.raises
variable
tests/models/models_test.py
test_no_sample_rate_raises
37
null
asteroid-team/asteroid
import itertools import argparse from collections.abc import MutableMapping import torch from torch.testing import assert_close import pytest import numpy as np from asteroid import utils from asteroid.utils import prepare_parser_from_dict, parse_args_as_dict def parser(): # Create dictionary as from .yml file ...
type(inp)
assert
func_call
tests/utils/utils_test.py
test_none_default
38
null
asteroid-team/asteroid
import pytest import torch from asteroid.masknn import TDConvNet, TDConvNetpp @pytest.mark.parametrize("mask_act", ["relu", "softmax"]) @pytest.mark.parametrize("out_chan", [None, 10]) @pytest.mark.parametrize("skip_chan", [0, 12]) @pytest.mark.parametrize("causal", [True, False]) def test_tdconvnet(mask_act, out_chan...
(batch, n_src, out_chan, n_frames)
assert
collection
tests/masknn/convolutional_test.py
test_tdconvnet
29
null
asteroid-team/asteroid
import pytest import torch from asteroid.losses import MixITLossWrapper from asteroid.losses import pairwise_neg_sisdr, multisrc_neg_sisdr def good_batch_loss_func(y_pred, y_true): batch, *_ = y_true.shape return torch.randn(batch) @pytest.mark.parametrize("batch_size", [1, 8]) @pytest.mark.parametrize("fact...
ValueError)
pytest.raises
variable
tests/losses/mixit_wrapper_test.py
test_mixitwrapper_checks_loss_shape
74
null
asteroid-team/asteroid
import torch import pytest from torch.testing import assert_close import numpy as np import soundfile as sf import asteroid from asteroid import models from asteroid_filterbanks import make_enc_dec from asteroid.dsp import LambdaOverlapAdd from asteroid.models.fasnet import FasNetTAC from asteroid.separate import separ...
new_model.in_channels
assert
complex_expr
tests/models/models_test.py
test_multichannel_model_loading
56
null
asteroid-team/asteroid
import pytest from torch import nn, optim from asteroid.engine import optimizers from torch_optimizer import Ranger def optim_mapping(): mapping_list = [ (optim.Adam, "adam"), (optim.SGD, "sgd"), (optim.RMSprop, "rmsprop"), (Ranger, "ranger"), ] return mapping_list def test...
ValueError)
pytest.raises
variable
tests/engine/optimizers_test.py
test_register
87
null
asteroid-team/asteroid
import torch from torch.testing import assert_close import pytest import math from asteroid import complex_nn as cnn from asteroid.utils.deprecation_utils import VisibleDeprecationWarning from asteroid_filterbanks import transforms def test_onreim(): inp = torch.randn(10, 10, dtype=torch.complex64) # Identity...
cnn.torch_complex_from_reim(inp.real.abs(), inp.imag.abs()))
assert_*
func_call
tests/complex_nn_test.py
test_onreim
36
null
asteroid-team/asteroid
import pytest import torch from asteroid.masknn import recurrent as rec @pytest.mark.parametrize("rnn_type", ["LSTM", "GRU", "RNN"]) @pytest.mark.parametrize("dropout", [0.0, 0.2]) def test_res_rnn(rnn_type, dropout): n_units, n_layers = 20, 3 model = rec.StackedResidualRNN( rnn_type, n_units, n_layers...
(batch, n_frames, n_units)
assert
collection
tests/masknn/recurrent_test.py
test_res_rnn
42
null
asteroid-team/asteroid
import torch import pytest from torch import nn from asteroid import torch_utils def test_get_device(): # We have only CPU in CI so can't test with real devices. class FakeTensor: device = "dev1" class FakeModule: def parameters(self): yield FakeTensor() class UnknownObje...
TypeError)
pytest.raises
variable
tests/utils/torch_utils_test.py
test_get_device
89
null
asteroid-team/asteroid
import os import pytest from asteroid.utils import hub_utils HF_EXAMPLE_MODEL_IDENTIFER = "julien-c/DPRNNTasNet-ks16_WHAM_sepclean" HF_EXAMPLE_MODEL_IDENTIFER_URL = "https://huggingface.co/julien-c/DPRNNTasNet-ks16_WHAM_sepclean" REVISION_ID_ONE_SPECIFIC_COMMIT = "8ab5ef18ef2eda141dd11a5d037a8bede7804ce4" def test_d...
path2
assert
variable
tests/utils/hub_utils_test.py
test_download
20
null
asteroid-team/asteroid
import pytest import torch from asteroid.masknn import recurrent as rec @pytest.mark.parametrize("mask_act", ["relu", "softmax"]) @pytest.mark.parametrize("out_chan", [None, 10]) @pytest.mark.parametrize("hop_size", [None, 5]) @pytest.mark.parametrize("use_mulcat", [True, False]) def test_dprnn(mask_act, out_chan, hop...
(batch, n_src, out_chan, n_frames)
assert
collection
tests/masknn/recurrent_test.py
test_dprnn
29
null
asteroid-team/asteroid
import itertools import argparse from collections.abc import MutableMapping import torch from torch.testing import assert_close import pytest import numpy as np from asteroid import utils from asteroid.utils import prepare_parser_from_dict, parse_args_as_dict def parser(): # Create dictionary as from .yml file ...
plain_args.key3
assert
complex_expr
tests/utils/utils_test.py
test_namespace_dic
29
null
asteroid-team/asteroid
import itertools import argparse from collections.abc import MutableMapping import torch from torch.testing import assert_close import pytest import numpy as np from asteroid import utils from asteroid.utils import prepare_parser_from_dict, parse_args_as_dict def parser(): # Create dictionary as from .yml file ...
start + min(sig_len, desired)
assert
func_call
tests/utils/utils_test.py
test_get_start_stop
103
null
asteroid-team/asteroid
import pytest import warnings from asteroid.utils import deprecation_utils as dp def test_deprecated(): class Foo: def new_func(self): pass @dp.mark_deprecated("Please use `new_func`", "0.5.0") def old_func(self): pass @dp.mark_deprecated("Please use `new_f...
1
assert
numeric_literal
tests/utils/deprecation_utils_test.py
test_deprecated
34
null
asteroid-team/asteroid
import pytest import itertools import torch from torch import nn, optim from torch.utils import data from torch.testing import assert_close import pytorch_lightning as pl from pytorch_lightning import Trainer from asteroid.losses import PITLossWrapper from asteroid.losses import sdr from asteroid.losses import single...
step
assert
variable
tests/losses/sinkpit_wrapper_test.py
on_train_batch_end
_TestCallback
104
null
asteroid-team/asteroid
from glob import glob import os.path as osp import re import pytest import torch from torch.testing import assert_close from asteroid.models import DeMask def test_sample_rate(): demask = DeMask(hidden_dims=(16,), kernel_size=8, n_filters=8, stride=4, sample_rate=9704) assert demask.sample_rate ==
9704
assert
numeric_literal
tests/models/demask_test.py
test_sample_rate
110
null
asteroid-team/asteroid
import torch import pytest from torch import nn from asteroid import torch_utils def test_pad(): x = torch.randn(10, 1, 16000) y = torch.randn(10, 1, 16234) padded_x = torch_utils.pad_x_to_y(x, y) assert padded_x.shape ==
y.shape
assert
complex_expr
tests/utils/torch_utils_test.py
test_pad
11
null
asteroid-team/asteroid
import pytest import warnings from asteroid.utils import deprecation_utils as dp def test_deprecated(): class Foo: def new_func(self): pass @dp.mark_deprecated("Please use `new_func`", "0.5.0") def old_func(self): pass @dp.mark_deprecated("Please use `new_f...
record[0].message.args[0]
assert
complex_expr
tests/utils/deprecation_utils_test.py
test_deprecated
36
null
asteroid-team/asteroid
import pytest import warnings from asteroid.utils import deprecation_utils as dp def test_is_overidden(): class Foo: def some_func(self): return None class Bar(Foo): def some_func(self): something_changed = None return None class Ho(Bar): pass ...
RuntimeError)
pytest.raises
variable
tests/utils/deprecation_utils_test.py
test_is_overidden
75
null
asteroid-team/asteroid
import itertools import argparse from collections.abc import MutableMapping import torch from torch.testing import assert_close import pytest import numpy as np from asteroid import utils from asteroid.utils import prepare_parser_from_dict, parse_args_as_dict def parser(): # Create dictionary as from .yml file ...
d_should_be
assert
variable
tests/utils/utils_test.py
test_average_array_in_dic
91
null
asteroid-team/asteroid
import torch import pytest from torch import nn from asteroid import torch_utils def test_get_device(): # We have only CPU in CI so can't test with real devices. class FakeTensor: device = "dev1" class FakeModule: def parameters(self): yield FakeTensor() class UnknownObje...
"dev1"
assert
string_literal
tests/utils/torch_utils_test.py
test_get_device
87
null
asteroid-team/asteroid
import torch import pytest import numpy as np from asteroid.dsp.spatial import xcorr @pytest.mark.parametrize("seq_len_input", [1390]) @pytest.mark.parametrize("seq_len_ref", [1390, 1290]) @pytest.mark.parametrize("batch_size", [1, 2]) @pytest.mark.parametrize("n_mics_input", [1]) @pytest.mark.parametrize("n_mics_ref"...
npy_result)
assert_*
variable
tests/dsp/spatial_test.py
test_xcorr
23
null
asteroid-team/asteroid
from glob import glob import os.path as osp import re import pytest import torch from torch.testing import assert_close from asteroid.models import DeMask def test_get_model_args(): demask = DeMask() expected = { "activation": "relu", "dropout": 0, "fb_name": "STFTFB", "hidden...
expected
assert
variable
tests/models/demask_test.py
test_get_model_args
129
null
asteroid-team/asteroid
from torch import nn, optim from torch.utils import data from pytorch_lightning import Trainer from asteroid.engine.system import System from asteroid.utils.test_utils import DummyDataset from asteroid.engine.schedulers import NoamScheduler, DPTNetScheduler def common_setup(): model = nn.Sequential(nn.Linear(10, ...
state_dict_c
assert
variable
tests/engine/scheduler_test.py
test_state_dict
27
null
asteroid-team/asteroid
import pytest import itertools import torch from torch.testing import assert_close from asteroid.losses import PITLossWrapper, pairwise_mse def bad_loss_func_ndim0(y_pred, y_true): return torch.randn(1).mean() def bad_loss_func_ndim1(y_pred, y_true): return torch.randn(1) def good_batch_loss_func(y_pred, y_...
ValueError)
pytest.raises
variable
tests/losses/pit_wrapper_test.py
test_raises_wrong_pit_from
131
null
asteroid-team/asteroid
import pytest import itertools import torch from torch import nn, optim from torch.utils import data from torch.testing import assert_close import pytorch_lightning as pl from pytorch_lightning import Trainer from asteroid.losses import PITLossWrapper from asteroid.losses import sdr from asteroid.losses import single...
mean_loss_hungarian)
assert_*
variable
tests/losses/sinkpit_wrapper_test.py
test_proximity_sinkhorn_hungarian
93
null