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 |
|---|---|---|---|---|---|---|---|---|---|
manzt/anywidget | import pathlib
import time
import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, ClassVar, Generator, Set, Union
from unittest.mock import MagicMock, patch
import anywidget._descriptor
import pytest
import watchfiles
from anywidget._descriptor import (
_COMMS,
MimeBundleD... | None | assert | none_literal | tests/test_descriptor.py | test_comm_cleanup | 178 | null | |
manzt/anywidget | from anywidget._file_contents import _VIRTUAL_FILES, VirtualFileContents
from IPython.testing.globalipapp import get_ipython
maybe_ipython = get_ipython()
ip = maybe_ipython
ip.run_line_magic("load_ext", "anywidget")
def test_creates_virtual_file_contents() -> None:
ip.run_cell_magic("vfile", "data.txt", "Hello,... | "Hello, world!\n" | assert | string_literal | tests/test_cellmagic.py | test_creates_virtual_file_contents | 14 | null | |
manzt/anywidget | from anywidget._file_contents import _VIRTUAL_FILES, VirtualFileContents
from IPython.testing.globalipapp import get_ipython
maybe_ipython = get_ipython()
ip = maybe_ipython
ip.run_line_magic("load_ext", "anywidget")
def test_creates_virtual_file_contents() -> None:
ip.run_cell_magic("vfile", "data.txt", "Hello,... | _VIRTUAL_FILES | assert | variable | tests/test_cellmagic.py | test_creates_virtual_file_contents | 12 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | {} | assert | collection | tests/test_widget.py | test_patched_repr_ipywidget_v8 | 135 | null | |
manzt/anywidget | import pathlib
import sys
from unittest.mock import MagicMock, patch
import pytest
from anywidget._file_contents import FileContents
from anywidget._util import (
get_repr_metadata,
put_buffers,
remove_buffers,
try_file_contents,
)
from anywidget._version import get_semver_version
def enable_hmr(): #... | FileNotFoundError) | pytest.raises | variable | tests/test_utils.py | test_try_file_contents_development | 111 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | 0 | assert | numeric_literal | tests/test_widget.py | test_command_not_registered_by_default | 286 | null | |
manzt/anywidget | import pathlib
import time
from collections import deque
from typing import Generator
from unittest.mock import MagicMock, Mock, patch
import pytest
import watchfiles
from anywidget._file_contents import FileContents, VirtualFileContents
from watchfiles import Change
def test_virtual_file_contents() -> None:
str_... | "blah") | assert_* | string_literal | tests/test_file_contents.py | test_virtual_file_contents | 153 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | css | assert | variable | tests/test_widget.py | test_infer_traitlets_partial | 125 | null | |
manzt/anywidget | import pathlib
import time
from collections import deque
from typing import Generator
from unittest.mock import MagicMock, Mock, patch
import pytest
import watchfiles
from anywidget._file_contents import FileContents, VirtualFileContents
from watchfiles import Change
def test_file_contents_thread(tmp_path: pathlib.Pa... | thread | assert | variable | tests/test_file_contents.py | test_file_contents_thread | 89 | null | |
manzt/anywidget | import pathlib
import time
import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, ClassVar, Generator, Set, Union
from unittest.mock import MagicMock, patch
import anywidget._descriptor
import pytest
import watchfiles
from anywidget._descriptor import (
_COMMS,
MimeBundleD... | target_value | assert | variable | tests/test_descriptor.py | test_descriptor_with_psygnal | 233 | null | |
manzt/anywidget | import pathlib
import time
import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, ClassVar, Generator, Set, Union
from unittest.mock import MagicMock, patch
import anywidget._descriptor
import pytest
import watchfiles
from anywidget._descriptor import (
_COMMS,
MimeBundleD... | _COMMS | assert | variable | tests/test_descriptor.py | test_comm_cleanup | 172 | null | |
manzt/anywidget | import pathlib
import time
import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, ClassVar, Generator, Set, Union
from unittest.mock import MagicMock, patch
import anywidget._descriptor
import pytest
import watchfiles
from anywidget._descriptor import (
_COMMS,
MimeBundleD... | foo.value | assert | complex_expr | tests/test_descriptor.py | test_descriptor | 101 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | _DEFAULT_ESM | assert | variable | tests/test_widget.py | test_default_esm | 57 | null | |
manzt/anywidget | import pathlib
import time
import weakref
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, ClassVar, Generator, Set, Union
from unittest.mock import MagicMock, patch
import anywidget._descriptor
import pytest
import watchfiles
from anywidget._descriptor import (
_COMMS,
MimeBundleD... | state) | assert_* | variable | tests/test_descriptor.py | test_state_setter | 130 | null | |
manzt/anywidget | import pathlib
import sys
from unittest.mock import MagicMock, patch
import pytest
from anywidget._file_contents import FileContents
from anywidget._util import (
get_repr_metadata,
put_buffers,
remove_buffers,
try_file_contents,
)
from anywidget._version import get_semver_version
def enable_hmr(): #... | state | assert | variable | tests/test_utils.py | test_remove_and_put_buffers | 39 | null | |
manzt/anywidget | import pathlib
import sys
from unittest.mock import MagicMock, patch
import pytest
from anywidget._file_contents import FileContents
from anywidget._util import (
get_repr_metadata,
put_buffers,
remove_buffers,
try_file_contents,
)
from anywidget._version import get_semver_version
def enable_hmr(): #... | {} | assert | collection | tests/test_utils.py | test_remove_and_put_buffers | 42 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | result | assert | variable | tests/test_widget.py | test_repr_uses_object_repr_by_default | 360 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | "bar" | assert | string_literal | tests/test_widget.py | test_infer_traitlets_partial | 122 | null | |
manzt/anywidget | from __future__ import annotations
import json
import pathlib
import sys
import time
from typing import Generator, NoReturn
from unittest.mock import MagicMock, patch
import anywidget
import pytest
import traitlets.traitlets as t
import watchfiles
from anywidget._file_contents import FileContents
from anywidget._util... | bundle[0] | assert | complex_expr | tests/test_widget.py | test_patched_repr_ipywidget_v8 | 134 | null | |
manzt/anywidget | import pathlib
import sys
from unittest.mock import MagicMock, patch
import pytest
from anywidget._file_contents import FileContents
from anywidget._util import (
get_repr_metadata,
put_buffers,
remove_buffers,
try_file_contents,
)
from anywidget._version import get_semver_version
def enable_hmr(): #... | { "application/vnd.jupyter.widget-view+json": { "colab": {"custom_widget_manager": {"url": "foo"}}, }, } | assert | collection | tests/test_utils.py | test_get_metadata | 101 | null | |
manzt/anywidget | import pathlib
import sys
from unittest.mock import MagicMock, patch
import pytest
from anywidget._file_contents import FileContents
from anywidget._util import (
get_repr_metadata,
put_buffers,
remove_buffers,
try_file_contents,
)
from anywidget._version import get_semver_version
def enable_hmr(): #... | expected | assert | variable | tests/test_utils.py | test_get_semver_version | 186 | null | |
pytries/marisa-trie | from __future__ import annotations
import pickle
from functools import partial
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, settings, HealthCheck
import marisa_trie
from .utils import text, records, run_threaded
pytestmark = [pytest.mark.thread_unsafe(reason... | contents | assert | variable | tests/test_threading.py | make_trie | 60 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
text = st.binary()
@given(st.sets(text))
def test_get(keys):
trie = marisa_trie.BinaryTrie(keys)
for key in... | key | assert | variable | tests/test_binary_trie.py | test_get | 68 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
@given(st.sets(text))
def test_get(keys):
trie = marisa_trie.Trie(keys)
for key in ... | None | assert | none_literal | tests/test_trie.py | test_get | 76 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
@given(st.sets(st.tuples(text, st.binary())))
def test_dumps_loads(data):
trie = marisa_trie.BytesTrie(data)
buf = io.... | pickle.load(buf) | assert | func_call | tests/test_bytes_trie.py | test_dumps_loads | 128 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
text = st.binary()
def test_neq_different_type():
assert marisa_trie.BinaryTrie([b"foo", b"bar"]) != | {} | assert | collection | tests/test_binary_trie.py | test_neq_different_type | 154 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
def test_prefixes():
trie = marisa_trie.Trie(["foo", "f", "foobar", "bar"])
assert ... | [] | assert | collection | tests/test_trie.py | test_prefixes | 227 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
text = st.binary()
def test_len():
trie = marisa_trie.BinaryTrie()
assert len(trie) == | 0 | assert | numeric_literal | tests/test_binary_trie.py | test_len | 179 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
def test_neq_different_type():
assert marisa_trie.Trie(["foo", "bar"]) != | {} | assert | collection | tests/test_trie.py | test_neq_different_type | 191 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
@given(st.sets(text), st.lists(st.binary()), text)
def test_getitem(keys, values, missing_key):
assume(missing_key not in k... | KeyError) | pytest.raises | variable | tests/test_bytes_trie.py | test_getitem | 37 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
@given(st.sets(text))
def test_get(keys):
trie = marisa_trie.Trie(keys)
for key in ... | key | assert | variable | tests/test_trie.py | test_get | 68 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
text = st.binary()
def test_len():
trie = marisa_trie.BinaryTrie()
assert len(trie) == 0
trie = marisa... | 3 | assert | numeric_literal | tests/test_binary_trie.py | test_len | 182 | null | |
pytries/marisa-trie | from __future__ import annotations
import pickle
from functools import partial
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, settings, HealthCheck
import marisa_trie
from .utils import text, records, run_threaded
pytestmark = [pytest.mark.thread_unsafe(reason... | trie | assert | variable | tests/test_threading.py | f | 76 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
text = st.binary()
@given(st.sets(text), text)
def test_init(keys, missing_key):
assume(missing_key not in keys... | trie | assert | variable | tests/test_binary_trie.py | test_init | 22 | null | |
pytries/marisa-trie | import io
import pickle
import hypothesis.strategies as st
from hypothesis import given
import marisa_trie
from .utils import text, records
@given(st.sets(st.tuples(text, records)))
def test_dumps_loads(data):
trie = marisa_trie.RecordTrie("<H?", data)
buf = io.BytesIO()
pickle.dump(trie, buf)
buf.... | pickle.load(buf) | assert | func_call | tests/test_record_trie.py | test_dumps_loads | 20 | null | |
pytries/marisa-trie | import io
import re
from importlib.metadata import metadata
import pytest
from readme_renderer.rst import render
_REPORT_RE = re.compile(
r"^<string>:(?P<line>(?:\d+)?): "
r"\((?P<level>DEBUG|INFO|WARNING|ERROR|SEVERE)/(\d+)?\) "
r"(?P<message>.*)",
re.DOTALL | re.MULTILINE,
)
@pytest.mark.thread_un... | None | assert | none_literal | tests/test_packaging.py | test_check_pypi_rendering | 59 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
def test_len():
trie = marisa_trie.Trie()
assert len(trie) == 0
trie = marisa_... | 3 | assert | numeric_literal | tests/test_trie.py | test_len | 219 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
@given(st.sets(text)... | trie2 | assert | variable | tests/test_trie.py | test_saveload | 94 | null | |
pytries/marisa-trie | from __future__ import annotations
import pickle
from functools import partial
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, settings, HealthCheck
import marisa_trie
from .utils import text, records, run_threaded
pytestmark = [pytest.mark.thread_unsafe(reason... | keys | assert | variable | tests/test_threading.py | f | 115 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
@given(st.sets(text), st.lists(st.binary()))
def test_iterkeys(keys, values):
trie = marisa_trie.BytesTrie(zip(keys, values... | list(trie.iterkeys()) | assert | func_call | tests/test_bytes_trie.py | test_iterkeys | 113 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
from .utils import text
@given(st.sets(text), text)
def test_init(keys, missing_key):
assume(missing_key not in... | trie | assert | variable | tests/test_trie.py | test_init | 22 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
def test_items():
data = [
("fo", b"y"),
("foo", b"x"),
("foo", b"a"),
]
trie = marisa_trie... | set(data) | assert | func_call | tests/test_bytes_trie.py | test_items | 74 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
def test_keys():
trie = marisa_trie.BytesTrie(
[
("foo", b"x"),
("fo", b"y"),
(... | ["foo", "foo"] | assert | collection | tests/test_bytes_trie.py | test_keys | 105 | null | |
pytries/marisa-trie | from __future__ import annotations
import pickle
from functools import partial
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, settings, HealthCheck
import marisa_trie
from .utils import text, records, run_threaded
pytestmark = [pytest.mark.thread_unsafe(reason... | key | assert | variable | tests/test_threading.py | f | 80 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
def test_getitem_multiple():
data = [
("foo", b"x"),
("fo", b"y"),
("foo", b"a"),
]
trie = ... | [b"a", b"x"] | assert | collection | tests/test_bytes_trie.py | test_getitem_multiple | 56 | null | |
pytries/marisa-trie | import pickle
from collections.abc import Mapping
from uuid import uuid4
import pytest
import hypothesis.strategies as st
from hypothesis import given, assume, settings, HealthCheck
import marisa_trie
text = st.binary()
@settings(suppress_health_check=[HealthCheck.function_scoped_fixture])
@given(st.sets(text))
def... | trie2 | assert | variable | tests/test_binary_trie.py | test_saveload | 89 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
def test_getitem_multiple():
data = [
("foo", b"x"),
("fo", b"y"),
("foo", b"a"),
]
trie = ... | [b"y"] | assert | collection | tests/test_bytes_trie.py | test_getitem_multiple | 55 | null | |
pytries/marisa-trie | import io
import pickle
from collections.abc import Mapping
import pytest
import hypothesis.strategies as st
from hypothesis import assume, given
import marisa_trie
from .utils import text
def test_keys():
trie = marisa_trie.BytesTrie(
[
("foo", b"x"),
("fo", b"y"),
(... | ["foo", "foo", "fo"] | assert | collection | tests/test_bytes_trie.py | test_keys | 102 | null | |
jpsca/jinjax | import typing as t
from pathlib import Path
import jinjax
def application(environ, start_response) -> list[bytes]:
status = "200 OK"
headers = [("Content-type", "text/plain")]
start_response(status, headers)
return [b"NOPE"]
def make_environ(**kw) -> dict[str, t.Any]:
kw.setdefault("PATH_INFO", "... | b"/* Page.css */" | assert | string_literal | tests/test_middleware.py | test_css_is_returned | 57 | null | |
jpsca/jinjax | import typing as t
from pathlib import Path
import jinjax
def application(environ, start_response) -> list[bytes]:
status = "200 OK"
headers = [("Content-type", "text/plain")]
start_response(status, headers)
return [b"NOPE"]
def make_environ(**kw) -> dict[str, t.Any]:
kw.setdefault("PATH_INFO", "... | b"???" | assert | string_literal | tests/test_middleware.py | test_add_custom_extensions | 87 | null | |
jpsca/jinjax | import jinja2
import pytest
from markupsafe import Markup
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_prefix_namespace_assets(catalog, folder, folder_t, autoescape, undefined):
"""Components import without specifyi... | Markup(""" <link rel="stylesheet" href="/static/components/ui/Title.css"> prefix """.strip()) | assert | func_call | tests/test_prefix.py | test_prefix_namespace_assets | 108 | null | |
jpsca/jinjax | import time
from textwrap import dedent
import jinja2
import pytest
from jinja2.exceptions import TemplateSyntaxError
from markupsafe import Markup
import jinjax
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_render_sou... | html | assert | variable | tests/test_render.py | test_render_source | 42 | null | |
jpsca/jinjax | import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument
def test_load_metadata_in_any_order():
com = Component(
name="Test.jinja",
source="""
{#css a.css #}
{#def lorem, ipsum=4 #}
{#js a.js #}
""",
)
assert com.required == ["lor... | ["a.js"] | assert | collection | tests/test_component.py | test_load_metadata_in_any_order | 150 | null | |
jpsca/jinjax | import typing as t
from pathlib import Path
import jinjax
def application(environ, start_response) -> list[bytes]:
status = "200 OK"
headers = [("Content-type", "text/plain")]
start_response(status, headers)
return [b"NOPE"]
def make_environ(**kw) -> dict[str, t.Any]:
kw.setdefault("PATH_INFO", "... | b"/* Page.js */" | assert | string_literal | tests/test_middleware.py | test_js_is_returned | 68 | null | |
jpsca/jinjax | import time
from textwrap import dedent
import jinja2
import pytest
from jinja2.exceptions import TemplateSyntaxError
from markupsafe import Markup
import jinjax
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_auto_reloa... | html2 | assert | variable | tests/test_render.py | test_auto_reload | 529 | null | |
jpsca/jinjax | import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument
def test_load_metadata_in_any_order():
com = Component(
name="Test.jinja",
source="""
{#css a.css #}
{#def lorem, ipsum=4 #}
{#js a.js #}
""",
)
assert com.required == ["lor... | ["a.css"] | assert | collection | tests/test_component.py | test_load_metadata_in_any_order | 149 | null | |
jpsca/jinjax | import jinja2
import pytest
from markupsafe import Markup
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_render_prefixed(catalog, folder, folder_t, autoescape, undefined):
"""Components mounted with a prefix should be... | Markup("prefix") | assert | func_call | tests/test_prefix.py | test_render_prefixed | 25 | null | |
jpsca/jinjax | from threading import Thread
from markupsafe import Markup
import jinjax
def test_thread_safety_of_template_globals(catalog, folder):
NUM_THREADS = 5
(folder / "Page.jinja").write_text(
"{{ globalvar if globalvar is defined else 'not set' }}"
)
def render(i):
return catalog.render("P... | Markup(str(i)) | assert | func_call | tests/test_thread_safety.py | test_thread_safety_of_template_globals | 191 | null | |
jpsca/jinjax | import pytest
import jinjax
def test_add_folder_with_dirty_prefix():
catalog = jinjax.Catalog()
catalog.add_folder("file_path", prefix="/custom.")
assert "/custom." not in | catalog.prefixes | assert | complex_expr | tests/test_catalog.py | test_add_folder_with_dirty_prefix | 28 | null | |
jpsca/jinjax | from pathlib import Path
import jinja2
import pytest
from markupsafe import Markup
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_auto_load_assets_with_same_name(catalog, folder, autoescape, undefined):
catalog.jinja... | Markup(expected) | assert | func_call | tests/test_render_assets.py | test_auto_load_assets_with_same_name | 228 | null | |
jpsca/jinjax | import pytest
import jinjax
def test_add_folder_with_custom_prefix():
catalog = jinjax.Catalog()
catalog.add_folder("file_path", prefix="custom")
assert "file_path" in | catalog.prefixes["custom"].searchpath | assert | complex_expr | tests/test_catalog.py | test_add_folder_with_custom_prefix | 21 | null | |
jpsca/jinjax | from pathlib import Path
import jinja2
import pytest
from markupsafe import Markup
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_render_assets(catalog, folder, autoescape, undefined):
catalog.jinja_env.autoescape = ... | html | assert | variable | tests/test_render_assets.py | test_render_assets | 61 | null | |
jpsca/jinjax | import time
from textwrap import dedent
import jinja2
import pytest
from jinja2.exceptions import TemplateSyntaxError
from markupsafe import Markup
import jinjax
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_do_not_mes... | "foo" | assert | string_literal | tests/test_render.py | test_do_not_mess_with_external_jinja_env | 456 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_additional_attributes_lazily_evaluated_has_string_methods():
class TestObject:
def __str__(self):
return "test"
attrs = HTMLAttrs({"some_object": TestObject()})
assert attrs["some_object"].__str__
assert attrs["some_o... | "TEST" | assert | string_literal | tests/test_html_attrs.py | test_additional_attributes_lazily_evaluated_has_string_methods | 288 | null | |
jpsca/jinjax | import pytest
import jinjax
def test_add_module_legacy():
class Module:
components_path = "legacy_path"
catalog = jinjax.Catalog()
module = Module()
catalog.add_module(module, prefix="legacy")
assert "legacy_path" in | catalog.prefixes["legacy"].searchpath | assert | complex_expr | tests/test_catalog.py | test_add_module_legacy | 57 | null | |
jpsca/jinjax | import time
from textwrap import dedent
import jinja2
import pytest
from jinja2.exceptions import TemplateSyntaxError
from markupsafe import Markup
import jinjax
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_auto_reloa... | html1 | assert | variable | tests/test_render.py | test_auto_reload | 504 | null | |
jpsca/jinjax | import pytest
import jinjax
def test_add_module_fails_with_other_modules():
class Module:
pass
catalog = jinjax.Catalog()
module = Module()
with pytest.raises( | AttributeError) | pytest.raises | variable | tests/test_catalog.py | test_add_module_fails_with_other_modules | 77 | null | |
jpsca/jinjax | import jinja2
import pytest
from markupsafe import Markup
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_prefix_fallback(catalog, folder, folder_t, autoescape, undefined):
"""If a component is not found in the folder ... | Markup("parent") | assert | func_call | tests/test_prefix.py | test_prefix_fallback | 86 | null | |
jpsca/jinjax | from threading import Thread
from markupsafe import Markup
import jinjax
def test_thread_safety_of_render_assets(catalog, folder):
NUM_THREADS = 5
child_tmpl = """
{#css "c{i}.css" #}
{#js "c{i}.js" #}
<p>Child {i}</p>""".strip()
parent_tmpl = """
{{ catalog.render_assets() }}
{{ content }}""".strip()
... | Markup(expected) | assert | func_call | tests/test_thread_safety.py | test_thread_safety_of_render_assets | 97 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_additional_attributes_are_lazily_evaluated_to_strings():
class TestObject:
def __str__(self):
raise RuntimeError("Should not be called unless rendered.")
attrs = HTMLAttrs(
{
"some_object": TestObject(),
... | RuntimeError) | pytest.raises | variable | tests/test_html_attrs.py | test_additional_attributes_are_lazily_evaluated_to_strings | 211 | null | |
jpsca/jinjax | import pytest
import jinjax
def test_add_same_folder_in_same_prefix_does_nothing():
catalog = jinjax.Catalog()
catalog.add_folder("file_path", prefix="custom")
catalog.add_folder("file_path", prefix="custom")
assert catalog.prefixes["custom"].searchpath.count("file_path") == | 1 | assert | numeric_literal | tests/test_catalog.py | test_add_same_folder_in_same_prefix_does_nothing | 46 | null | |
jpsca/jinjax | import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument
def test_load_metadata_in_any_order():
com = Component(
name="Test.jinja",
source="""
{#css a.css #}
{#def lorem, ipsum=4 #}
{#js a.js #}
""",
)
assert com.required == | ["lorem"] | assert | collection | tests/test_component.py | test_load_metadata_in_any_order | 147 | null | |
jpsca/jinjax | import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument
def test_no_args():
com = Component(
name="Test.jinja",
source="\n",
)
assert com.required == []
assert com.optional == | {} | assert | collection | tests/test_component.py | test_no_args | 70 | null | |
jpsca/jinjax | import typing as t
from pathlib import Path
import jinjax
def application(environ, start_response) -> list[bytes]:
status = "200 OK"
headers = [("Content-type", "text/plain")]
start_response(status, headers)
return [b"NOPE"]
def make_environ(**kw) -> dict[str, t.Any]:
kw.setdefault("PATH_INFO", "... | b"folder1" | assert | string_literal | tests/test_middleware.py | test_multiple_folders | 136 | null | |
jpsca/jinjax | import time
from textwrap import dedent
import jinja2
import pytest
from jinja2.exceptions import TemplateSyntaxError
from markupsafe import Markup
import jinjax
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_do_not_mes... | "bar" | assert | string_literal | tests/test_render.py | test_do_not_mess_with_external_jinja_env | 455 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_render():
attrs = HTMLAttrs(
{
"title": "hi",
"data-position": "top",
"class": "z4 c3 a1 z4 b2",
"open": True,
"disabled": False,
}
)
assert 'class="z4 c3 a1 b2" data... | attrs.render() | assert | func_call | tests/test_html_attrs.py | test_render | 78 | null | |
jpsca/jinjax | from threading import Thread
from markupsafe import Markup
import jinjax
def test_same_thread_assets_independence(catalog, folder):
catalog2 = jinjax.Catalog()
catalog2.add_folder(folder)
print("Catalog1 key:", catalog._key)
print("Catalog2 key:", catalog2._key)
# Check if the context variables... | Markup(expected_2) | assert | func_call | tests/test_thread_safety.py | test_same_thread_assets_independence | 169 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_render_attrs_lik_set():
attrs = HTMLAttrs({"class": "lorem"})
expected = 'class="lorem ipsum" data-position="top" title="hi" open'
result = attrs.render(
title="hi",
data_position="top",
classes="ipsum",
open=Tr... | result | assert | variable | tests/test_html_attrs.py | test_render_attrs_lik_set | 170 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_parse_initial_attrs():
attrs = HTMLAttrs(
{
"title": "hi",
"data-position": "top",
"class": "z4 c3 a1 z4 b2",
"open": True,
"disabled": False,
"value": 0,
"foo... | "0" | assert | string_literal | tests/test_html_attrs.py | test_parse_initial_attrs | 29 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_parse_initial_attrs():
attrs = HTMLAttrs(
{
"title": "hi",
"data-position": "top",
"class": "z4 c3 a1 z4 b2",
"open": True,
"disabled": False,
"value": 0,
"foo... | True | assert | bool_literal | tests/test_html_attrs.py | test_parse_initial_attrs | 27 | null | |
jpsca/jinjax | import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument
def test_load_args():
com = Component(
name="Test.jinja",
source='{#def message, lorem=4, ipsum="bar" -#}\n',
)
assert com.required == | ["message"] | assert | collection | tests/test_component.py | test_load_args | 15 | null | |
jpsca/jinjax | import time
from textwrap import dedent
import jinja2
import pytest
from jinja2.exceptions import TemplateSyntaxError
from markupsafe import Markup
import jinjax
@pytest.mark.parametrize("undefined", [jinja2.Undefined, jinja2.StrictUndefined])
@pytest.mark.parametrize("autoescape", [True, False])
def test_auto_reloa... | html3 | assert | variable | tests/test_render.py | test_auto_reload | 530 | null | |
jpsca/jinjax | import pytest
from jinjax import Component, DuplicateDefDeclaration, InvalidArgument
def test_expression_args():
com = Component(
name="Test.jinja",
source="{#def expr=1 + 2 + 3, a=1 -#}\n",
)
assert com.required == | [] | assert | collection | tests/test_component.py | test_expression_args | 27 | null | |
jpsca/jinjax | import jinja2
import pytest
from jinjax import JinjaX
VALID_DATA = (
# Simple case
(
"""<Foo bar="baz">content</Foo>""",
"""{% call(_slot="") catalog.irender("Foo", __prefix=__prefix, **{"bar":"baz"}) -%}content{%- endcall %}""",
),
# Self-closing tag
(
"""<Alert type="succ... | expected | assert | variable | tests/test_extension.py | test_process_valid_tags | 80 | null | |
jpsca/jinjax | import pytest
from jinjax.html_attrs import HTMLAttrs
def test_parse_initial_attrs():
attrs = HTMLAttrs(
{
"title": "hi",
"data-position": "top",
"class": "z4 c3 a1 z4 b2",
"open": True,
"disabled": False,
"value": 0,
"foo... | 0 | assert | numeric_literal | tests/test_html_attrs.py | test_parse_initial_attrs | 36 | null | |
jpsca/jinjax | import jinja2
import pytest
from jinjax import JinjaX
VALID_DATA = (
# Simple case
(
"""<Foo bar="baz">content</Foo>""",
"""{% call(_slot="") catalog.irender("Foo", __prefix=__prefix, **{"bar":"baz"}) -%}content{%- endcall %}""",
),
# Self-closing tag
(
"""<Alert type="succ... | exception, match=f".*{match}.*") | pytest.raises | complex_expr | tests/test_extension.py | test_process_invalid_tags | 116 | null | |
jpsca/jinjax | from threading import Thread
from markupsafe import Markup
import jinjax
def test_same_thread_assets_independence(catalog, folder):
catalog2 = jinjax.Catalog()
catalog2.add_folder(folder)
print("Catalog1 key:", catalog._key)
print("Catalog2 key:", catalog2._key)
# Check if the context variables... | Markup(expected_1) | assert | func_call | tests/test_thread_safety.py | test_same_thread_assets_independence | 168 | null | |
jpsca/jinjax | import typing as t
from pathlib import Path
import jinjax
def application(environ, start_response) -> list[bytes]:
status = "200 OK"
headers = [("Content-type", "text/plain")]
start_response(status, headers)
return [b"NOPE"]
def make_environ(**kw) -> dict[str, t.Any]:
kw.setdefault("PATH_INFO", "... | b"folder2" | assert | string_literal | tests/test_middleware.py | test_multiple_folders | 138 | null | |
nschloe/tikzplotlib | import matplotlib.pyplot as plt
import numpy as np
def plot():
# plot data
fig = plt.figure()
ax = fig.add_subplot(111)
x = np.arange(3)
y1 = [1, 2, 3]
y1err = [0.1, 0.2, 0.5]
y2 = [3, 2, 4]
y2err = [0.4, 0.2, 0.5]
y3 = [5, 3, 1]
y3err = [0.1, 0.2, 0.1]
w = 0.25
errBar... | "test_barchart_errorbars_reference.tex") | assert_* | string_literal | tests/test_barchart_errorbars.py | test | 36 | null | |
nschloe/tikzplotlib | import numpy as np
import pytest
from matplotlib import pyplot as plt
from tikzplotlib import clean_figure, get_tikz_code
RC_PARAMS = {"figure.figsize": [5, 5], "figure.dpi": 220, "pgf.rcfonts": False}
class Test_plottypes:
def test_scatter(self):
x = np.linspace(1, 100, 20)
y = np.linspace(1, 1... | 6 | assert | numeric_literal | tests/test_cleanfigure.py | test_scatter | Test_plottypes | 68 | null |
nschloe/tikzplotlib | def plot():
import matplotlib.cm as cm
import matplotlib.pyplot as plt
import numpy as np
x, y = np.meshgrid(np.linspace(0, 1), np.linspace(0, 1))
z = x**2 - y**2
fig = plt.figure()
plt.pcolormesh(x, y, z, cmap=cm.viridis, shading="gouraud")
return fig
def test():
from .helpers i... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_context.py | test | 18 | null | |
nschloe/tikzplotlib | import pytest
def plot():
import numpy as np
from matplotlib import pyplot as plt
data = np.zeros((3, 3))
data[:2, :2] = 1.0
fig = plt.figure()
ax1 = plt.subplot(131)
ax2 = plt.subplot(132)
ax3 = plt.subplot(133)
axes = [ax1, ax2, ax3]
for ax in axes:
im = ax.imshow(... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_subplots_with_colorbars.py | test | 30 | null | |
nschloe/tikzplotlib | import matplotlib.pyplot as plt
import numpy as np
def plot():
# Make plot with horizontal colorbar
fig = plt.figure()
ax = fig.add_subplot(111)
np.random.seed(123)
data = np.clip(np.random.randn(250, 250), -1, 1)
cax = ax.imshow(data, interpolation="nearest")
ax.set_title("Gaussian noise... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_noise2.py | test | 26 | null | |
nschloe/tikzplotlib | import datetime as date
import matplotlib.pyplot as plt
from matplotlib import dates
def plot():
fig = plt.figure()
values = [50, 50.02]
time = [date.datetime(2016, 10, 10, 18, 00), date.datetime(2016, 10, 10, 18, 15)]
plt.plot(time, values)
hfmt = dates.DateFormatter("%H:%M")
ax = plt.gca()
... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_datetime.py | test | 22 | null | |
nschloe/tikzplotlib | import numpy as np
import pytest
from matplotlib import pyplot as plt
from tikzplotlib import clean_figure, get_tikz_code
RC_PARAMS = {"figure.figsize": [5, 5], "figure.dpi": 220, "pgf.rcfonts": False}
class Test_plottypes:
def test_plot3d(self):
theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)
z... | 13 | assert | numeric_literal | tests/test_cleanfigure.py | test_plot3d | Test_plottypes | 118 | null |
nschloe/tikzplotlib | def plot():
import numpy as np
from matplotlib import pyplot as plt
def f(t):
s1 = np.cos(2 * np.pi * t)
e1 = np.exp(-t)
return np.multiply(s1, e1)
fig = plt.figure()
t1 = np.arange(0.0, 5.0, 0.4)
t2 = np.arange(0.0, 5.0, 0.1)
t3 = np.arange(0.0, 2.0, 0.1)
plt... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_subplots.py | test | 36 | null | |
nschloe/tikzplotlib | import matplotlib.pyplot as plt
import numpy as np
def plot():
# plot data
fig = plt.figure()
ax = fig.add_subplot(111)
x = np.arange(3)
y1 = [1, 2, 3]
y2 = [3, 2, 4]
y3 = [5, 3, 1]
w = 0.25
ax.bar(x - w, y1, w, color="b", align="center")
ax.bar(x, y2, w, color="g", align="cen... | "test_barchart_reference.tex") | assert_* | string_literal | tests/test_barchart.py | test | 31 | null | |
nschloe/tikzplotlib | import matplotlib.pyplot as plt
import numpy as np
def plot():
fig, ax = plt.subplots()
with plt.style.context("ggplot"):
t = np.linspace(0, 2 * np.pi, 11)
s = np.sin(t)
ax.plot(t, s, "k-")
ax.fill_between(t, s + 0.1, s - 0.1, facecolor="k", alpha=0.2)
ax.set_xlim(t[0], ... | "test_errorband_reference.tex") | assert_* | string_literal | tests/test_errorband.py | test | 23 | null | |
nschloe/tikzplotlib | import matplotlib.pyplot as plt
import numpy as np
def plot():
# Make plot with vertical (default) colorbar
fig = plt.figure()
ax = fig.add_subplot(111)
np.random.seed(123)
data = np.clip(np.random.randn(250, 250), -1, 1)
cax = ax.imshow(data, interpolation="nearest")
ax.set_title("Gaussi... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_noise.py | test | 26 | null | |
nschloe/tikzplotlib | def plot():
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
x = np.arange(5)
y1 = np.array([1, 2, 1, 4, 2])
y2 = np.array([1, 2, 1, 4, 2])
y3 = np.array([1, 2, 1, 4, 2])
y4 = np.array([1, 2, 1, 4, 2])
y5 = np.array([2, 3, 2, 5, 3])
plt.step(x, y1, "r-")
... | __file__[:-3] + "_reference.tex") | assert_* | complex_expr | tests/test_steps.py | test | 26 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.