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 |
|---|---|---|---|---|---|---|---|---|---|
karlicoss/HPI | from pathlib import Path
import pytest
from more_itertools import one
from my.core.cfg import tmp_config
from my.location.google import locations
def test_google_locations() -> None:
locs = list(locations())
assert len(locs) == | 3810 | assert | numeric_literal | src/my/tests/location/google.py | test_google_locations | 18 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | None | assert | none_literal | src/my/core/stats.py | test_guess_stats | 190 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | RuntimeError) | pytest.raises | variable | src/my/tests/tz.py | test_policies | 105 | null | |
karlicoss/HPI | import json
import warnings
from collections.abc import Iterator
from datetime import datetime
from pathlib import Path
from typing import NamedTuple
from ..denylist import DenyList
def data() -> Iterator[IP]:
# random IP addresses
yield IP(addr="67.98.113.0", dt=datetime(2020, 1, 1))
yield IP(addr="59.40... | 0 | assert | numeric_literal | src/my/core/tests/denylist.py | test_denylist | 44 | null | |
karlicoss/HPI | from __future__ import annotations
import shutil
import sqlite3
from collections.abc import Callable, Iterator
from contextlib import contextmanager
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, Literal, assert_never, overload
from . import warnings
from .common import PathI... | row_factory) | assert_* | variable | src/my/core/sqlite.py | sqlite_connection | 69 | null | |
karlicoss/HPI | from collections.abc import Iterator
import pytest
from more_itertools import one
from my.bluemaestro import Measurement, measurements
from my.core.cfg import tmp_config
from .common import testdata
def ok_measurements() -> Iterator[Measurement]:
for m in measurements():
assert not isinstance(m, Excepti... | 6000 | assert | numeric_literal | src/my/tests/bluemaestro.py | test | 32 | null | |
karlicoss/HPI | from pathlib import Path
import pytest
from ..structure import match_structure
structure_data: Path = Path(__file__).parent / "structure_data"
gdpr_expected = ("comments", "messages/index.csv", "profile")
@pytest.mark.parametrize("archive", ["gdpr_export.zip", "gdpr_export.tar.gz"])
def test_gdpr_unpack(archive: s... | 1 | assert | numeric_literal | src/my/core/tests/structure.py | test_gdpr_unpack | 20 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | [_B(y=datetime(year=2015, month=5, day=10, hour=4, minute=10, second=1))] | assert | collection | src/my/core/query_range.py | test_filter_in_timeframe | 425 | null | |
karlicoss/HPI | from __future__ import annotations
import importlib.util
import os
import pkgutil
import sys
from collections.abc import Iterable
from itertools import chain
from pathlib import Path
from types import ModuleType
from .discovery_pure import HPIModule, _is_not_module_src, has_stats, ignored
def modules() -> Iterable[H... | "has no 'stats()' function" | assert | string_literal | src/my/core/util.py | test_module_detection | 178 | null | |
karlicoss/HPI | from __future__ import annotations
import inspect
import os
import pkgutil
import re
from collections.abc import Iterator, MutableSequence, Sequence
from typing import Any
from . import warnings
def handle_legacy_import(
parent_module_name: str,
legacy_submodule_name: str,
parent_module_path: MutableSequ... | None | assert | none_literal | src/my/core/hpi_compat.py | __next__ | always_supports_sequence | 133 | null |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import inspect
import itertools
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime
from typing import Any, NamedTuple
import more_itertools
from . import error as err
from .error import Res, unwrap
from .types ... | 7 | assert | numeric_literal | src/my/core/query.py | test_drop_exceptions | 678 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import tempfile
from collections.abc import Sequence
from dataclasses import dataclass
from pathlib import Path
from . import warnings
_HPI_CACHE_DIR_DEFAULT = ''
def _reset_config() -> Iterator[Config]:
# todo maybe have this decorator for the whole of my.config?
... | None | assert | none_literal | src/my/core/core_config.py | test_active_modules | 150 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | 'Europe/Moscow' | assert | string_literal | src/my/tests/tz.py | test_future | 60 | null | |
karlicoss/HPI | from __future__ import annotations
import warnings
from collections.abc import Callable, Hashable, Iterable, Iterator, Sized
from typing import TYPE_CHECKING, cast
import more_itertools
from decorator import decorator
from .. import warnings as core_warnings
def _identity[T, V](v: T) -> V: # type: ignore[type-var]... | r6 | assert | variable | src/my/core/utils/itertools.py | test_check_if_hashable | 287 | null | |
karlicoss/HPI | from __future__ import annotations
import code
import contextlib
import functools
import importlib
import importlib.util
import inspect
import os
import shlex
import shutil
import sys
import tempfile
import traceback
import warnings
from collections.abc import Callable, Iterable, Sequence
from contextlib import ExitSt... | 0 | assert | numeric_literal | src/my/core/__main__.py | _ui_getchar_pick | 459 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import traceback
from collections.abc import Callable, Iterable, Iterator
from datetime import date, datetime
from itertools import tee
from typing import Any, Literal, cast
from .types import Json
from .warnings import medium
ErrorPolicy = Literal["yield", "raise", "drop... | [ 1, 'bad', 2, 3, Exc('first'), Exc('second'), 5, Exc('last'), ] | assert | collection | src/my/core/error.py | test_sort_res_by | 135 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import inspect
import itertools
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime
from typing import Any, NamedTuple
import more_itertools
from . import error as err
from .error import Res, unwrap
from .types ... | Counter({"_A": 4, "Unsortable": 2}) | assert | func_call | src/my/core/query.py | test_wrap_unsortable | 654 | null | |
karlicoss/HPI | from collections.abc import Iterator
from datetime import UTC, datetime, timedelta
import pytest
from more_itertools import ilen
import my.ip.all as ip_module
from my.ip.common import IP
from my.location.fallback import via_ip
from ..shared_tz_config import config # noqa: F401 # autoused fixture
def test_ip_fallb... | 5 | assert | numeric_literal | src/my/tests/location/fallback.py | test_ip_fallback | 24 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import tempfile
from collections.abc import Sequence
from dataclasses import dataclass
from pathlib import Path
from . import warnings
_HPI_CACHE_DIR_DEFAULT = ''
def _reset_config() -> Iterator[Config]:
# todo maybe have this decorator for the whole of my.config?
... | True | assert | bool_literal | src/my/core/core_config.py | test_active_modules | 157 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | False | assert | bool_literal | src/my/core/query_range.py | test_range_predicate | 483 | null | |
karlicoss/HPI | from __future__ import annotations
from collections import OrderedDict
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Any, cast
def ignore(w, *keys):
for k in keys:
w[k].ignore()
def zoom(w, *keys):
return [w[k].zoom() for k in keys]
class Wdict(Zoomabl... | 1 | assert | numeric_literal | src/my/core/konsume.py | _remove | Wdict | 63 | null |
karlicoss/HPI | import os
from pathlib import Path
import pytest
from more_itertools import bucket
from my.coding.commits import commits
from my.core.cfg import tmp_config
from .common import hpi_repo_root
pytestmark = pytest.mark.skipif(
os.name == 'nt',
reason='TODO figure out how to install fd-find on Windows',
)
def t... | 100 | assert | numeric_literal | src/my/tests/commits.py | test | 20 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | 0 | assert | numeric_literal | src/my/core/stats.py | test_sig_required_params | 303 | null | |
karlicoss/HPI | import inspect
from pathlib import Path
import pytest
from more_itertools import ilen
from my.core.cfg import tmp_config
from my.pdfs import annotated_pdfs, annotations, get_annots
from .common import testdata
def test_module(with_config) -> None:
# todo check types etc as well
assert ilen(annotations()) >... | 3 | assert | numeric_literal | src/my/tests/pdfs.py | test_module | 15 | null | |
karlicoss/HPI | import os
import zipfile
from pathlib import Path
import pytest
from kompress import CPath, ZipPath
from ..common import get_files
def test_implicit_glob(tmp_path_cwd: Path) -> None:
'''
Asterisk in the path results in globbing too.
'''
# todo hopefully that makes sense? dunno why would anyone actual... | ( Path('123/file.gz'), Path('456/file.gz'), ) | assert | collection | src/my/core/tests/test_get_files.py | test_implicit_glob | 136 | null | |
karlicoss/HPI | import json
from datetime import UTC, datetime
from my.twitter.archive import Tweet
def test_tweet() -> None:
raw = r"""
{
"edit_info" : {
"initial" : {
"editTweetIds" : [
"1269253350735982592"
],
"editableUntil" : "2020-06-06T14:02:35.059Z",
"editsRemaining" : ... | '1269253350735982592' | assert | string_literal | src/my/tests/twitter/archive.py | test_tweet | 61 | null | |
karlicoss/HPI | from __future__ import annotations
from .common import skip_if_uses_optional_deps as pytestmark # noqa: F401
def test_cachew_dir_none() -> None:
from cachew import settings
settings.ENABLE = True # by default it's off in tests (see conftest.py)
from my.core.cachew import cache_dir, mcachew
from my... | [2, 2, 2] | assert | collection | src/my/core/tests/test_cachew.py | test_cachew_dir_none | 52 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | {} | assert | collection | src/my/core/stats.py | test_stat | 129 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | None | assert | none_literal | src/my/tests/tz.py | test_get_tz | 78 | null | |
karlicoss/HPI | import json
import warnings
from collections.abc import Iterator
from datetime import datetime
from pathlib import Path
from typing import NamedTuple
from ..denylist import DenyList
def data() -> Iterator[IP]:
# random IP addresses
yield IP(addr="67.98.113.0", dt=datetime(2020, 1, 1))
yield IP(addr="59.40... | 9 | assert | numeric_literal | src/my/core/tests/denylist.py | test_denylist | 59 | null | |
karlicoss/HPI | from __future__ import annotations
import importlib.util
import os
import pkgutil
import sys
from collections.abc import Iterable
from itertools import chain
from pathlib import Path
from types import ModuleType
from .discovery_pure import HPIModule, _is_not_module_src, has_stats, ignored
def modules() -> Iterable[H... | "suppressed in the user config" | assert | string_literal | src/my/core/util.py | test_module_detection | 186 | null | |
karlicoss/HPI | from __future__ import annotations
import shutil
import sqlite3
from collections.abc import Callable, Iterator
from contextlib import contextmanager
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, Literal, assert_never, overload
from . import warnings
from .common import PathI... | {'table', 'index', 'view', 'trigger'} | assert | collection | src/my/core/sqlite.py | _get_sqlite_master | SqliteTool | 171 | null |
karlicoss/HPI | import os
import sys
from pathlib import Path
import pytest
import pytz
import my.config
from my.core import notnone
from my.demo import items, make_config
from .common import tmp_environ_set
def test_mixin_attribute_handling(tmp_path: Path) -> None:
"""
Tests that arbitrary mixin attributes work with our c... | 'UUU' | assert | string_literal | src/my/core/tests/test_config.py | test_mixin_attribute_handling | 70 | null | |
karlicoss/HPI | from collections.abc import Iterator
import pytest
from more_itertools import one
from my.bluemaestro import Measurement, measurements
from my.core.cfg import tmp_config
from .common import testdata
def ok_measurements() -> Iterator[Measurement]:
for m in measurements():
assert not isinstance(m, Excepti... | 18.5 | assert | numeric_literal | src/my/tests/bluemaestro.py | test_old_db | 42 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import re
import sys
from collections.abc import Callable, Iterator
from contextlib import ExitStack, contextmanager
from typing import Any, cast
def make_config[C](cls: type[C], migration: Callable[[Attrs], Attrs] = lambda x: x) -> C:
user_co... | None | assert | none_literal | src/my/core/cfg.py | tmp_config | 87 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | RangeTuple(after=start_date.timestamp(), before=end_date.timestamp(), within=None) | assert | func_call | src/my/core/query_range.py | test_parse_range | 513 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | [ 'Europe/Rome', 'Europe/Rome', 'Europe/Vienna', 'Europe/Vienna', 'Europe/Vienna', ] | assert | collection | src/my/tests/tz.py | test_iter_tzs | 28 | null | |
karlicoss/HPI | from __future__ import annotations
import inspect
import os
import pkgutil
import re
from collections.abc import Iterator, MutableSequence, Sequence
from typing import Any
from . import warnings
def handle_legacy_import(
parent_module_name: str,
legacy_submodule_name: str,
parent_module_path: MutableSequ... | 'c' | assert | string_literal | src/my/core/hpi_compat.py | test_always_supports_sequence_indexing | 198 | null | |
karlicoss/HPI | from __future__ import annotations
import inspect
import os
import pkgutil
import re
from collections.abc import Iterator, MutableSequence, Sequence
from typing import Any
from . import warnings
def handle_legacy_import(
parent_module_name: str,
legacy_submodule_name: str,
parent_module_path: MutableSequ... | ['a', 'b', 'c'] | assert | collection | src/my/core/hpi_compat.py | test_always_supports_sequence_list_constructor | 177 | null | |
karlicoss/HPI | import inspect
from pathlib import Path
import pytest
from more_itertools import ilen
from my.core.cfg import tmp_config
from my.pdfs import annotated_pdfs, annotations, get_annots
from .common import testdata
def test_module(with_config) -> None:
# todo check types etc as well
assert ilen(annotations()) >=... | 1 | assert | numeric_literal | src/my/tests/pdfs.py | test_module | 16 | null | |
karlicoss/HPI | import json
from datetime import UTC, datetime
from my.twitter.archive import Tweet
def test_tweet() -> None:
raw = r"""
{
"edit_info" : {
"initial" : {
"editTweetIds" : [
"1269253350735982592"
],
"editableUntil" : "2020-06-06T14:02:35.059Z",
"editsRemaining" : ... | None | assert | none_literal | src/my/tests/twitter/archive.py | test_tweet | 62 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | int(parse_datetime_float(dt_int_s)) | assert | func_call | src/my/core/query_range.py | test_parse_datetime_float | 549 | null | |
karlicoss/HPI | from __future__ import annotations
import shutil
import sqlite3
from collections.abc import Callable, Iterator
from contextlib import contextmanager
from pathlib import Path
from tempfile import TemporaryDirectory
from typing import Any, Literal, assert_never, overload
from . import warnings
from .common import PathI... | None | assert | none_literal | src/my/core/sqlite.py | sqlite_connection | 78 | null | |
karlicoss/HPI | from pathlib import Path
import pytest
from more_itertools import one
from my.core.cfg import tmp_config
from my.location.google import locations
def test_google_locations() -> None:
locs = list(locations())
assert len(locs) == 3810, len(locs)
last = locs[-1]
assert last.dt.strftime('%Y%m%d %H:%M:%S... | 16.4742742 | assert | numeric_literal | src/my/tests/location/google.py | test_google_locations | 24 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | 'Europe/Sofia' | assert | string_literal | src/my/tests/tz.py | test_get_tz | 69 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import inspect
import itertools
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime
from typing import Any, NamedTuple
import more_itertools
from . import error as err
from .error import Res, unwrap
from .types ... | 1 | assert | numeric_literal | src/my/core/query.py | test_couldnt_determine_order | 591 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | RangeTuple(after=0, before=5, within=None) | assert | func_call | src/my/core/query_range.py | test_parse_range | 502 | null | |
karlicoss/HPI | from pathlib import Path
import pytest
from more_itertools import one
from my.core.cfg import tmp_config
from my.location.google import locations
def test_google_locations() -> None:
locs = list(locations())
assert len(locs) == 3810, len(locs)
last = locs[-1]
assert last.dt.strftime('%Y%m%d %H:%M:%S... | 46.5515350 | assert | numeric_literal | src/my/tests/location/google.py | test_google_locations | 23 | null | |
karlicoss/HPI | import shutil
import sqlite3
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
from tempfile import TemporaryDirectory
from ..sqlite import sqlite_connect_immutable, sqlite_copy_and_open
def _test_do_copy(db: Path) -> None:
# from a copy without journal can only read previously committed... | 10 | assert | numeric_literal | src/my/core/tests/sqlite.py | _test_do_copy_and_open | 59 | null | |
karlicoss/HPI | from __future__ import annotations
import warnings
from collections.abc import Callable, Hashable, Iterable, Iterator, Sized
from typing import TYPE_CHECKING, cast
import more_itertools
from decorator import decorator
from .. import warnings as core_warnings
def _identity[T, V](v: T) -> V: # type: ignore[type-var]... | ll | assert | variable | src/my/core/utils/itertools.py | test_warn_if_empty_list | 192 | null | |
karlicoss/HPI | Seems that the stub config is used ({cfg_path}). This is likely not going to work.
See https://github.com/karlicoss/HPI/blob/master/doc/SETUP.org#setting-up-modules for more information
'''.strip()
)
errors.append(RuntimeError('bad config path'))
except Exception as e:
errors.append(... | result.output | assert | complex_expr | src/my/core/__main__.py | test_requires | 917 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | ["0", "1", "2", "3", "4"] | assert | collection | src/my/core/query_range.py | test_range_predicate | 486 | null | |
karlicoss/HPI | from __future__ import annotations
REQUIRES = 'REQUIRES'
NOT_HPI_MODULE_VAR = '__NOT_HPI_MODULE__'
import ast
import logging
import os
import re
from collections.abc import Iterable, Sequence
from pathlib import Path
from typing import Any, NamedTuple, cast
def ignored(m: str) -> bool:
excluded = [
# leg... | Path('my', 'demo.py') | assert | func_call | src/my/core/discovery_pure.py | test_demo | 217 | null | |
karlicoss/HPI | from pathlib import Path
import pytest
from ..structure import match_structure
structure_data: Path = Path(__file__).parent / "structure_data"
gdpr_expected = ("comments", "messages/index.csv", "profile")
@pytest.mark.parametrize("archive", ["gdpr_export.zip", "gdpr_export.tar.gz"])
def test_gdpr_unpack(archive: s... | "test message" | assert | string_literal | src/my/core/tests/structure.py | test_gdpr_unpack | 23 | null | |
karlicoss/HPI | from __future__ import annotations
REQUIRES = 'REQUIRES'
NOT_HPI_MODULE_VAR = '__NOT_HPI_MODULE__'
import ast
import logging
import os
import re
from collections.abc import Iterable, Sequence
from pathlib import Path
from typing import Any, NamedTuple, cast
def ignored(m: str) -> bool:
excluded = [
# leg... | None | assert | none_literal | src/my/core/discovery_pure.py | test_demo | 216 | null | |
karlicoss/HPI | from __future__ import annotations
REQUIRES = 'REQUIRES'
NOT_HPI_MODULE_VAR = '__NOT_HPI_MODULE__'
import ast
import logging
import os
import re
from collections.abc import Iterable, Sequence
from pathlib import Path
from typing import Any, NamedTuple, cast
def ignored(m: str) -> bool:
excluded = [
# leg... | src | assert | variable | src/my/core/discovery_pure.py | test_pure | 249 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | True | assert | bool_literal | src/my/core/query_range.py | test_range_predicate | 482 | null | |
karlicoss/HPI | import shutil
import sqlite3
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
from tempfile import TemporaryDirectory
from ..sqlite import sqlite_connect_immutable, sqlite_copy_and_open
def _test_do_copy(db: Path) -> None:
# from a copy without journal can only read previously committed... | 5 | assert | numeric_literal | src/my/core/tests/sqlite.py | _test_do_immutable | 53 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import inspect
import itertools
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime
from typing import Any, NamedTuple
import more_itertools
from . import error as err
from .error import Res, unwrap
from .types ... | [_Int(1), _Int(3)] | assert | collection | src/my/core/query.py | test_basic_orders | 561 | null | |
karlicoss/HPI | import json
from datetime import UTC, datetime
from my.twitter.archive import Tweet
def test_tweet() -> None:
raw = r"""
{
"edit_info" : {
"initial" : {
"editTweetIds" : [
"1269253350735982592"
],
"editableUntil" : "2020-06-06T14:02:35.059Z",
"editsRemaining" : ... | datetime(2020, 6, 6, 13, 2, 35, tzinfo=UTC) | assert | func_call | src/my/tests/twitter/archive.py | test_tweet | 56 | null | |
karlicoss/HPI | from __future__ import annotations
import inspect
import os
import pkgutil
import re
from collections.abc import Iterator, MutableSequence, Sequence
from typing import Any
from . import warnings
def handle_legacy_import(
parent_module_name: str,
legacy_submodule_name: str,
parent_module_path: MutableSequ... | 0 | assert | numeric_literal | src/my/core/hpi_compat.py | test_always_supports_sequence_next | 223 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | 1 + 2 + 1 + 3 + 1 | assert | complex_expr | src/my/core/stats.py | test_stat_iterable | 426 | null | |
karlicoss/HPI | from __future__ import annotations
from collections import OrderedDict
from collections.abc import Iterator
from contextlib import contextmanager
from typing import Any, cast
def ignore(w, *keys):
for k in keys:
w[k].ignore()
def zoom(w, *keys):
return [w[k].zoom() for k in keys]
class Zoomable:
... | None | assert | none_literal | src/my/core/konsume.py | consume | Zoomable | 46 | null |
karlicoss/HPI | from collections.abc import Iterator
import pytest
from more_itertools import one
from my.bluemaestro import Measurement, measurements
from my.core.cfg import tmp_config
from .common import testdata
def ok_measurements() -> Iterator[Measurement]:
for m in measurements():
assert not isinstance(m, Excepti... | 1009.8 | assert | numeric_literal | src/my/tests/bluemaestro.py | test_old_db | 44 | null | |
karlicoss/HPI | from __future__ import annotations
import datetime
import warnings
from collections.abc import Callable
from dataclasses import asdict, is_dataclass
from decimal import Decimal
from functools import cache
from pathlib import Path
from typing import Any, NamedTuple
from .error import error_to_json
from .pytest import ... | [5, 5.0] | assert | collection | src/my/core/serialize.py | test_dumps | 213 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | OSError) | pytest.raises | variable | src/my/tests/tz.py | test_get_tz | 87 | null | |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | [ 'Europe/Rome', 'Europe/Rome', 'Europe/Ljubljana', 'Europe/Ljubljana', 'Europe/Ljubljana', ] | assert | collection | src/my/tests/tz.py | test_iter_tzs | 36 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import time
from collections.abc import Callable, Iterator
from datetime import date, datetime, timedelta
from functools import cache
from typing import Any, NamedTuple
import more_itertools
from .query import (
ET,
OrderFunc,
QueryException,
Where,
_h... | 60 | assert | numeric_literal | src/my/core/query_range.py | test_parse_datetime_float | 541 | null | |
karlicoss/HPI | from __future__ import annotations
import importlib.util
import os
import pkgutil
import sys
from collections.abc import Iterable
from itertools import chain
from pathlib import Path
from types import ModuleType
from .discovery_pure import HPIModule, _is_not_module_src, has_stats, ignored
def modules() -> Iterable[H... | nostats | assert | variable | src/my/core/util.py | test_good_modules | 215 | null | |
karlicoss/HPI | from pathlib import Path
import pytest
from ..structure import match_structure
structure_data: Path = Path(__file__).parent / "structure_data"
gdpr_expected = ("comments", "messages/index.csv", "profile")
def test_not_directory() -> None:
with pytest.raises( | NotADirectoryError, match=r"Expected either a zip/tar.gz archive or a directory") | pytest.raises | complex_expr | src/my/core/tests/structure.py | test_not_directory | 36 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import traceback
from collections.abc import Callable, Iterable, Iterator
from datetime import date, datetime
from itertools import tee
from typing import Any, Literal, cast
from .types import Json
from .warnings import medium
ErrorPolicy = Literal["yield", "raise", "drop... | ['a', 'aba', 'caba', 'daba'] | assert | collection | src/my/core/error.py | test_sort_res_by | 149 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime, timezone
from pprint import pformat
from typing import (
TYPE_CHECKING,
Any,
Literal,
)
from decorator import decorator
from . import warnings
from .error import R... | 1 | assert | numeric_literal | src/my/core/pandas.py | test_check_dateish | 84 | null | |
karlicoss/HPI | import json
from datetime import UTC, datetime
from my.twitter.archive import Tweet
def test_tweet() -> None:
raw = r"""
{
"edit_info" : {
"initial" : {
"editTweetIds" : [
"1269253350735982592"
],
"editableUntil" : "2020-06-06T14:02:35.059Z",
"editsRemaining" : ... | 'https://twitter.com/whatever/status/1269253350735982592' | assert | string_literal | src/my/tests/twitter/archive.py | test_tweet | 55 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime, timezone
from pprint import pformat
from typing import (
TYPE_CHECKING,
Any,
Literal,
)
from decorator import decorator
from . import warnings
from .error import R... | pd.DataFrame(data={ 'value': ['test', np.nan ], 'error': [np.nan, 'RuntimeError: i failed\n'], 'dt' : [np.nan, np.nan ], }).astype(dtype={'dt': 'float'})) | assert_* | func_call | src/my/core/pandas.py | test_as_dataframe | 245 | null | |
karlicoss/HPI | from __future__ import annotations
from my.core import __NOT_HPI_MODULE__ # noqa: F401 # isort: skip
import re
from collections.abc import Callable, Iterable
from datetime import datetime
from enum import Enum
from html.parser import HTMLParser
from pathlib import Path
from typing import Any
from urllib.parse impor... | None | assert | none_literal | src/my/google/takeout/html.py | handle_starttag | TakeoutHTMLParser | 101 | null |
karlicoss/HPI | import sys
from datetime import datetime, timedelta
import pytest
import pytz
import my.time.tz.main as tz_main
import my.time.tz.via_location as tz_via_location
from my.core import notnone
from .shared_tz_config import config # noqa: F401 # autoused fixture
def getzone(dt: datetime) -> str:
tz = notnone(dt.t... | 'America/New_York' | assert | string_literal | src/my/tests/tz.py | test_past | 51 | null | |
karlicoss/HPI | import os
import sys
from pathlib import Path
import pytest
import pytz
import my.config
from my.core import notnone
from my.demo import items, make_config
from .common import tmp_environ_set
def test_mixin_attribute_handling(tmp_path: Path) -> None:
"""
Tests that arbitrary mixin attributes work with our c... | 'hello' | assert | string_literal | src/my/core/tests/test_config.py | test_mixin_attribute_handling | 73 | null | |
karlicoss/HPI | from __future__ import annotations
import re
import traceback
from collections.abc import Callable, Iterable, Iterator
from datetime import date, datetime
from itertools import tee
from typing import Any, Literal, cast
from .types import Json
from .warnings import medium
ErrorPolicy = Literal["yield", "raise", "drop... | date | assert | variable | src/my/core/error.py | test_datetime_errors | 280 | null | |
karlicoss/HPI | from __future__ import annotations
import warnings
from collections.abc import Callable, Hashable, Iterable, Iterator, Sized
from typing import TYPE_CHECKING, cast
import more_itertools
from decorator import decorator
from .. import warnings as core_warnings
def _identity[T, V](v: T) -> V: # type: ignore[type-var]... | Exception) | pytest.raises | variable | src/my/core/utils/itertools.py | test_check_if_hashable | 268 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | {'fun': {'count': 3}} | assert | collection | src/my/core/stats.py | test_stat | 117 | null | |
karlicoss/HPI | import os
import sys
from pathlib import Path
import pytest
import pytz
import my.config
from my.core import notnone
from my.demo import items, make_config
from .common import tmp_environ_set
@pytest.mark.parametrize('run_id', ['1', '2'])
def test_dynamic_module_import(tmp_path: Path, run_id: str) -> None:
"""
... | {f'total_{run_id}': 2 + 456} | assert | collection | src/my/core/tests/test_config.py | test_dynamic_module_import | 119 | null | |
karlicoss/HPI | from __future__ import annotations
import inspect
import os
import pkgutil
import re
from collections.abc import Iterator, MutableSequence, Sequence
from typing import Any
from . import warnings
def handle_legacy_import(
parent_module_name: str,
legacy_submodule_name: str,
parent_module_path: MutableSequ... | 1 | assert | numeric_literal | src/my/core/hpi_compat.py | test_always_supports_sequence_list_constructor | 178 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime, timezone
from pprint import pformat
from typing import (
TYPE_CHECKING,
Any,
Literal,
)
from decorator import decorator
from . import warnings
from .error import R... | pd.DataFrame({ 'i' : [0 , 1 , 2 , 3 , 4 ], 's' : ['str0', 'str1', 'str2', 'str3', 'str4'], # NOTE: error column is always added 'error': [None , None , None , None , None ], })) | assert_* | func_call | src/my/core/pandas.py | test_as_dataframe | 218 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import inspect
import itertools
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime
from typing import Any, NamedTuple
import more_itertools
from . import error as err
from .error import Res, unwrap
from .types ... | Counter({"_A": 4}) | assert | func_call | src/my/core/query.py | test_drop_unsorted | 673 | null | |
karlicoss/HPI | from __future__ import annotations
import datetime
import warnings
from collections.abc import Callable
from dataclasses import asdict, is_dataclass
from decimal import Decimal
from functools import cache
from pathlib import Path
from typing import Any, NamedTuple
from .error import error_to_json
from .pytest import ... | TypeError) | pytest.raises | variable | src/my/core/serialize.py | test_dumps | 221 | null | |
karlicoss/HPI | from __future__ import annotations
import warnings
from collections.abc import Callable, Hashable, Iterable, Iterator, Sized
from typing import TYPE_CHECKING, cast
import more_itertools
from decorator import decorator
from .. import warnings as core_warnings
def _identity[T, V](v: T) -> V: # type: ignore[type-var]... | list[int]) | assert_* | complex_expr | src/my/core/utils/itertools.py | test_listify | 114 | null | |
karlicoss/HPI | import os
import zipfile
from pathlib import Path
import pytest
from kompress import CPath, ZipPath
from ..common import get_files
def test_single_file(tmp_path_cwd: Path) -> None:
'''
Regular file path is just returned as is.
'''
# Exception if it doesn't exist"
with pytest.raises(Exception):
... | (Path('~').expanduser() / '.bashrc',) | assert | collection | src/my/core/tests/test_get_files.py | test_single_file | 30 | null | |
karlicoss/HPI | from __future__ import annotations
import json
from . import warnings
from .pytest import parametrize
def json_loads(data: bytes | str):
"""
Tries loading with orjson if it's available, otherwise falls back to stdlib json.
"""
try:
import orjson
except ModuleNotFoundError as e:
if... | {"key": "value"} | assert | collection | src/my/core/json.py | test_json_loads_stdlib | 34 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | dd + day * 50 | assert | complex_expr | src/my/core/stats.py | test_stat_iterable | 428 | null | |
karlicoss/HPI | from collections.abc import Iterator
import pytest
from more_itertools import one
from my.bluemaestro import Measurement, measurements
from my.core.cfg import tmp_config
from .common import testdata
def ok_measurements() -> Iterator[Measurement]:
for m in measurements():
assert not isinstance(m, Excepti... | 1024.5 | assert | numeric_literal | src/my/tests/bluemaestro.py | test_old_db | 43 | null | |
karlicoss/HPI | from __future__ import annotations
import collections.abc
import importlib
import inspect
import typing
from collections.abc import Callable, Iterable, Iterator, Sequence
from contextlib import contextmanager
from datetime import datetime
from pathlib import Path
from types import ModuleType
from typing import (
A... | { 'inputs': { 'count': 3, 'first': 'file1.json', 'last': 'file3.json', }, 'iter_data': { 'count': 9, 'first': datetime(2020, 1, 1, 1, 1, 1), 'last': datetime(2020, 1, 3, 1, 1, 1), }, } | assert | collection | src/my/core/stats.py | test_guess_stats | 193 | null | |
karlicoss/HPI | import shutil
import sqlite3
from concurrent.futures import ProcessPoolExecutor
from pathlib import Path
from tempfile import TemporaryDirectory
from ..sqlite import sqlite_connect_immutable, sqlite_copy_and_open
def test_sqlite_read_with_wal(tmp_path: Path) -> None:
db = tmp_path / 'db.sqlite'
# write a bit
... | 1 | assert | numeric_literal | src/my/core/tests/sqlite.py | test_sqlite_read_with_wal | 27 | null | |
karlicoss/HPI | from __future__ import annotations
REQUIRES = 'REQUIRES'
NOT_HPI_MODULE_VAR = '__NOT_HPI_MODULE__'
import ast
import logging
import os
import re
from collections.abc import Iterable, Sequence
from pathlib import Path
from typing import Any, NamedTuple, cast
def ignored(m: str) -> bool:
excluded = [
# leg... | 2 | assert | numeric_literal | src/my/core/discovery_pure.py | test_requires | 230 | null | |
karlicoss/HPI | from __future__ import annotations
from .common import skip_if_uses_optional_deps as pytestmark # noqa: F401
def test_cachew() -> None:
from cachew import settings
settings.ENABLE = True # by default it's off in tests (see conftest.py)
from my.core.cachew import mcachew
called = 0
# TODO ugh... | [1, 2, 3] | assert | collection | src/my/core/tests/test_cachew.py | test_cachew | 29 | null | |
karlicoss/HPI | import os
import zipfile
from pathlib import Path
import pytest
from kompress import CPath, ZipPath
from ..common import get_files
def test_explicit_glob(tmp_path_cwd: Path) -> None:
'''
You can pass a glob to restrict the extensions
'''
create_tree('''
file_3.gz
file_2.gz
ignoreme
file.gz
''')
... | expected | assert | variable | src/my/core/tests/test_get_files.py | test_explicit_glob | 114 | null | |
karlicoss/HPI | import os
import zipfile
from pathlib import Path
import pytest
from kompress import CPath, ZipPath
from ..common import get_files
def test_multiple_files(tmp_path_cwd: Path) -> None:
'''
If you pass a directory/multiple directories, it flattens the contents
'''
create_tree('''
dir1/
dir1/zzz
dir1/yy... | ( Path('dir3/ttt'), Path('dir1/yyy'), Path('dir1/zzz'), ) | assert | collection | src/my/core/tests/test_get_files.py | test_multiple_files | 50 | null | |
karlicoss/HPI | from pathlib import Path
import pytest
from more_itertools import one
from my.core.cfg import tmp_config
from my.location.google import locations
def test_google_locations() -> None:
locs = list(locations())
assert len(locs) == 3810, len(locs)
last = locs[-1]
assert last.dt.strftime('%Y%m%d %H:%M:%... | '20170802 13:01:56' | assert | string_literal | src/my/tests/location/google.py | test_google_locations | 21 | null | |
karlicoss/HPI | from __future__ import annotations
import dataclasses
import importlib
import inspect
import itertools
from collections.abc import Callable, Iterable, Iterator
from datetime import datetime
from typing import Any, NamedTuple
import more_itertools
from . import error as err
from .error import Res, unwrap
from .types ... | 0 | assert | numeric_literal | src/my/core/query.py | test_basic_orders | 565 | null | |
karlicoss/HPI | from __future__ import annotations
REQUIRES = 'REQUIRES'
NOT_HPI_MODULE_VAR = '__NOT_HPI_MODULE__'
import ast
import logging
import os
import re
from collections.abc import Iterable, Sequence
from pathlib import Path
from typing import Any, NamedTuple, cast
def ignored(m: str) -> bool:
excluded = [
# leg... | [] | assert | collection | src/my/core/discovery_pure.py | test_pure | 248 | null | |
karlicoss/HPI | import json
from datetime import UTC, datetime
from my.twitter.archive import Tweet
def test_tweet() -> None:
raw = r"""
{
"edit_info" : {
"initial" : {
"editTweetIds" : [
"1269253350735982592"
],
"editableUntil" : "2020-06-06T14:02:35.059Z",
"editsRemaining" : ... | 'Finally published the post about Promnesia: https://beepb00p.xyz/promnesia.html\n\nA story of how our browser history is broken and my attempt to fix it!' | assert | string_literal | src/my/tests/twitter/archive.py | test_tweet | 57 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.