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 |
|---|---|---|---|---|---|---|---|---|---|
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from organize.config import Config
def test_write_clear_then_append(fs):
make_files({"test1.txt": "", "test2.txt": ""}, "loc1")
make_files({"test1.txt": "", "test2.txt": ""}, "loc2")
make_files(
{
"test... | { "test1": { "test1.log": f"FOUND {Path('loc1/test1.txt')}\nFOUND {Path('loc2/test1.txt')}\n" }, "test2": { "test2.log": f"FOUND {Path('loc1/test2.txt')}\nFOUND {Path('loc2/test2.txt')}\n" }, } | assert | collection | tests/actions/test_write.py | test_write_clear_then_append | 111 | null | |
tfeldmann/organize | import sys
import pytest
from organize import Config
from organize.filters.macos_tags import list_tags, matches_tags
@pytest.mark.skipif(sys.platform != "darwin", reason="runs only on macOS")
def test_macos_filter(tmp_path, testoutput):
import macos_tags
testdir = tmp_path / "test"
testdir.mkdir()
... | ["Pictures (blue)"] | assert | collection | tests/filters/test_macos_tags.py | test_macos_filter | 48 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files
from organize import Config
def test_standalone(testoutput):
Config.from_string(
"""
rules:
- actions:
- echo: "Do this"
- echo: "And this"
- actions:
- echo: "And that"
"""
).... | ["Do this", "And this", "And that"] | assert | collection | tests/core/test_location.py | test_standalone | 19 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files
from organize import Config
def test_python(fs, testoutput):
make_files({"file.txt": "File content"}, "test")
Config.from_string(
"""
rules:
- locations: /test
actions:
- python: |
... | [ f"Handling: {Path('/test/file.txt')}", "File content", ] | assert | collection | tests/actions/test_python.py | test_python | 25 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_mimetype_filter(fs):
make_files({"test.pdf": "", "other.jpg": "", "other2.png": ""}, "test")
Config.from_string(
"""
rules:
- locations: /test
filters:
- mimetype:
... | { "test.pdf": "", "image": { "jpeg": { "other.jpg": "", }, "png": { "other2.png": "", }, }, } | assert | collection | tests/filters/test_mimetype.py | test_mimetype_filter | 45 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize.config import Config
def test_move_folder_conflict(fs):
make_files(
{
"src": {"dir": {"src.txt": ""}},
"dst": {"dir": {"dst.txt": ""}},
},
"test",
)
# src is moved onto dst.
Config.f... | { "src": {}, "dst": { "dir": {"dst.txt": ""}, "dir 2": {"src.txt": ""}, }, } | assert | collection | tests/actions/test_move.py | test_move_folder_conflict | 118 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize import Config
FILES = {
"test.txt": "",
"file.txt": "Hello world\nAnother line",
"another.txt": "",
"folder": {
"x.txt": "",
},
}
def test_copy_into_dir_subfolders(fs):
make_files(FILES, "test")
config = """
... | { "test.txt": "", "file.txt": "Hello world\nAnother line", "another.txt": "", "folder": { "x.txt": "", }, "a brand": { "new": { "folder": { "test.txt": "", "file.txt": "Hello world\nAnother line", "another.txt": "", "x.txt": "", } } }, } | assert | collection | tests/actions/test_copy.py | test_copy_into_dir_subfolders | 89 | null | |
tfeldmann/organize | import sys
from organize.utils import (
ChangeDetector,
deep_merge,
deep_merge_inplace,
has_executable,
)
def test_merges_dicts():
a = {"a": 1, "b": {"b1": 2, "b2": 3}}
b = {"a": 1, "b": {"b1": 4}}
print(deep_merge(a, b))
assert deep_merge(a, b)["a"] == 1
assert deep_merge(a, b)["... | 4 | assert | numeric_literal | tests/test_utils.py | test_merges_dicts | 37 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files
from organize import Config
def test_single_file(fs, testoutput):
make_files(["foo.txt", "bar.txt"], "/test")
Config.from_string(
"""
rules:
- locations:
- /test/foo.txt
- /test/bar.txt
... | ["foo.txt", "bar.txt"] | assert | collection | tests/core/test_location.py | test_single_file | 36 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
CONTENT_SMALL = "COPY CONTENT"
CONTENT_LARGE = "XYZ" * 300000
CONFIG_DEEP_DUP_DELETE = """
rules:
- locations: "."
subfolders: true
filters:
- duplicate:
detect_original_by: name
actions:
- delete
"""
def tes... | { "unique.txt": "I'm unique.", "unique_too.txt": "I'm unique: too.", "a.txt": CONTENT_SMALL, "other": { "large.txt": CONTENT_LARGE, }, } | assert | collection | tests/filters/test_duplicate.py | test_duplicate_smallfiles | 37 | null | |
tfeldmann/organize | import pytest
from organize.config import should_execute
@pytest.mark.parametrize(
"result, rule_tags, tags, skip_tags",
(
# no tags given
(True, None, None, None),
(True, ["tag"], None, None),
(True, ["tag", "tag2"], None, None),
# run tagged
(False, None, ["ta... | result | assert | variable | tests/core/test_tags.py | test_tags | 40 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files
from organize import Config
from organize.filters.hash import hash, hash_first_chunk
def test_full_hash(fs):
r"""
Reference hashsums:
```sh
python3 -c 'from pathlib import Path; Path("hello.txt").write_text("Hello world")'
md5 hello.txt &&... | "3e25960a79dbc69b674cd4ec67a72c62" | assert | string_literal | tests/filters/test_hash.py | test_full_hash | 22 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
structure = {
"file1.txt": "",
"file2.txt": "",
"folder1": {
"folder2": {
"file1.2.1.txt": "",
"file1.2.2.txt": "",
},
"file1.1.txt": "",
"file1.2.txt": "",
},
}
def test_fr... | {"test": {"sub1": {"sub2": structure}}} | assert | collection | tests/combined/test_keep_folder_structure.py | test_from_root | 80 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from pyfakefs.fake_filesystem import FakeFilesystem
from organize import Config
from organize.filters import Regex
from organize.output import Default
from organize.resource import Resource
def test_multiple_regex_placeholders(fs: Fak... | out | assert | variable | tests/filters/test_regex.py | test_multiple_regex_placeholders | 61 | null | |
tfeldmann/organize | import sys
from organize.utils import (
ChangeDetector,
deep_merge,
deep_merge_inplace,
has_executable,
)
def test_returns_copy():
a = {"regex": {"first": "A", "second": "B"}}
b = {"regex": {"third": "C"}}
x = deep_merge(a, b)
a["regex"]["first"] = "X"
assert x["regex"]["first"] =... | "B" | assert | string_literal | tests/test_utils.py | test_returns_copy | 47 | null | |
tfeldmann/organize | from organize import Config
from organize.find_config import EXAMPLE_CONFIG
from organize.output import JSONL, Default
def test_example_config(testoutput):
config = Config.from_string(EXAMPLE_CONFIG)
config.execute(simulate=False, output=testoutput)
assert testoutput.messages == | ["Hello, World!"] | assert | collection | tests/combined/test_example_config.py | test_example_config | 9 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files, read_files
from organize.actions.common.target_path import prepare_target_path, user_wants_a_folder
def test_prepare_folder_target_already_exists(fs):
make_files({"some": {"Application.app": {}}})
assert (
prepare_target_path(
src_... | {"Application.app": {}} | assert | collection | tests/actions/test_common.py | test_prepare_folder_target_already_exists | 75 | null | |
tfeldmann/organize | import sys
from organize.utils import (
ChangeDetector,
deep_merge,
deep_merge_inplace,
has_executable,
)
def test_merges_dicts():
a = {"a": 1, "b": {"b1": 2, "b2": 3}}
b = {"a": 1, "b": {"b1": 4}}
print(deep_merge(a, b))
assert deep_merge(a, b)["a"] == | 1 | assert | numeric_literal | tests/test_utils.py | test_merges_dicts | 35 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
structure = {
"file1.txt": "",
"file2.txt": "",
}
def test_simple_replace(fs):
make_files(structure, "/test")
Config.from_string(
"""
rules:
- locations: "/test"
subfolders: true
... | { "Datei1.txt": "", "Datei2.txt": "", } | assert | collection | tests/combined/test_simple_replace.py | test_simple_replace | 22 | null | |
tfeldmann/organize | from conftest import make_files
from organize import Config, Rule
from organize.actions import Echo
from organize.filters import Name
def test_api(fs, testoutput):
make_files(["foo.txt", "bar.txt", "baz.txt"], "test")
echo = Echo("{name.upper()}{% if name.upper() == 'FOO' %}FOO{% endif %}")
config = Con... | ["BAR", "BAZ", "FOOFOO"] | assert | collection | tests/test_api.py | test_api | 24 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_python(fs, testoutput):
make_files(
["student-01.jpg", "student-01.txt", "student-02.txt", "student-03.txt"],
"test",
)
config = """
rules:
- locations: /test
filters:
- n... | [ "100", "200", "300", ] | assert | collection | tests/filters/test_python.py | test_python | 23 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_rename_issue51(fs):
# test for issue https://github.com/tfeldmann/organize/issues/51
files = {
"19asd_WF_test2.PDF": "",
"other.pdf": "",
"18asd_WFX_test2.pdf": "",
}
make_files(files, "test")
... | { "copy": { "19asd_WF_test2_unread.pdf": "", }, "19asd_WF_test2_unread.pdf": "", "other.pdf": "", "18asd_WFX_test2.pdf": "", } | assert | collection | tests/actions/test_rename.py | test_rename_issue51 | 31 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_python_dict(fs, testoutput):
make_files(
["foo-01.jpg", "foo-01.txt", "bar-02.txt", "baz-03.txt"],
"test",
)
config = """
rules:
- locations: /test
filters:
- extensio... | [ "200 bar", "300 baz", "100 foo", ] | assert | collection | tests/filters/test_python.py | test_python_dict | 72 | null | |
tfeldmann/organize | import sys
from organize.utils import (
ChangeDetector,
deep_merge,
deep_merge_inplace,
has_executable,
)
def test_returns_copy():
a = {"regex": {"first": "A", "second": "B"}}
b = {"regex": {"third": "C"}}
x = deep_merge(a, b)
a["regex"]["first"] = "X"
assert x["regex"]["first"] ... | "A" | assert | string_literal | tests/test_utils.py | test_returns_copy | 46 | null | |
tfeldmann/organize | from collections import Counter
from datetime import datetime
from conftest import make_files
from organize import Config
def test_echo_args(testoutput):
Config.from_string(
"""
rules:
- actions:
- echo: "Date formatting: {now().strftime('%Y')}"
"""
).execute(s... | [f"Date formatting: {datetime.now().year}"] | assert | collection | tests/actions/test_echo.py | test_echo_args | 28 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize import Config
FILES = {
"test.txt": "",
"file.txt": "Hello world\nAnother line",
"another.txt": "",
"folder": {
"x.txt": "",
},
}
@pytest.mark.parametrize(
"mode,result",
[
("skip", {"src.txt": "src", ... | result | assert | variable | tests/actions/test_copy.py | test_copy_conflict | 137 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
from organize.filters import Name
def test_name_match_case_insensitive(fs):
filename = "UPPER_MiXed_lower.txt"
make_files([filename], "test")
Config.from_string(
"""
rules:
- locations: /test
filt... | {"MiXed": {"lower": {filename: ""}}} | assert | collection | tests/filters/test_name.py | test_name_match_case_insensitive | 122 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize.config import Config
def test_move_deduplicate_conflict(fs):
files = {
"src.txt": "src",
"duplicate": {
"src.txt": "src",
},
"nonduplicate": {
"src.txt": "src2",
},
}
co... | { "duplicate": { "src.txt": "src", }, "nonduplicate": {}, "dst.txt": "src", "dst 2.txt": "src2", } | assert | collection | tests/actions/test_move.py | test_move_deduplicate_conflict | 86 | null | |
tfeldmann/organize | import re
import pytest
from conftest import ORGANIZE_DIR
from organize import Config
from organize.registry import ACTIONS, FILTERS
DOCS_DIR = ORGANIZE_DIR / "docs"
RE_CONFIG = re.compile(r"```yaml\n(?P<config>rules:(?:.*?\n)+?)```", re.MULTILINE)
def _list_examples():
for f in DOCS_DIR.rglob("*.md"):
... | filter_docs | assert | variable | tests/test_docs.py | test_all_filters_documented | 48 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from organize.config import Config
@pytest.mark.parametrize(
("mode", "newline", "result"),
[
("append", "true", "a\nb\nc\n"),
("append", "false", "abc"),
("prepend", "true", "c\nb\na\n"),
("pre... | f.read() | assert | func_call | tests/actions/test_write.py | test_write | 58 | null | |
tfeldmann/organize | from collections import Counter
from pathlib import Path
import pytest
from conftest import equal_items, make_files
from pyfakefs.fake_filesystem import FakeFilesystem
from organize.walker import Walker
def counter(items):
return Counter(str(x) for x in items)
def test_exclude_dirs(fs):
make_files(
... | 4 | assert | numeric_literal | tests/core/test_walker.py | test_exclude_dirs | 149 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files
from organize import Config
def test_standalone(testoutput):
Config.from_string(
"""
rules:
- actions:
- echo: "Do this"
- echo: "And this"
- actions:
- echo: "And that"
"""
).... | 2 | assert | numeric_literal | tests/core/test_location.py | test_standalone | 20 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files
from organize import Config
from organize.filters.extension import Extension
@pytest.mark.parametrize(
"path,match,suffix",
(
("/somefile.pdf", True, "pdf"),
("/home/test/somefile.pdf.jpeg", False, "jpeg"),
("/home... | suffix | assert | variable | tests/filters/test_extension.py | test_extension | 24 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_dependent_rules(fs):
files = {
"asd.txt": "",
"newname 2.pdf": "",
"newname.pdf": "",
"test.pdf": "",
}
make_files(files, "test")
Config.from_string(
"""
rules:
- locations:... | { "newname.pdf": "", "newname 2.pdf": "", "test.pdf": "", "asd.txt": "", "newfolder": {"test-found.pdf": ""}, } | assert | collection | tests/combined/test_dependent_rules.py | test_dependent_rules | 29 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from pyfakefs.fake_filesystem import FakeFilesystem
from organize import Config
from organize.filters import Regex
from organize.output import Default
from organize.resource import Resource
@pytest.mark.parametrize(
"path,valid,te... | {"regex": {"the_number": test_result}} | assert | collection | tests/filters/test_regex.py | test_regex_return | 35 | null | |
tfeldmann/organize | from pydantic.type_adapter import TypeAdapter
from organize.validators import FlatList
def test_flatlist():
ta = TypeAdapter(FlatList[int])
v = ta.validate_python([1, 2, [10, 11, [12, 23]], 3, [4, 5, 6]])
assert v == | [1, 2, 10, 11, 12, 23, 3, 4, 5, 6] | assert | collection | tests/test_validators.py | test_flatlist | 9 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_rename_files_date(fs):
# inspired by https://github.com/tfeldmann/organize/issues/43
files = {
"File_abc_dat20190812_xyz.pdf": "",
"File_xyz_bar19990101_a.pdf": "",
"File_123456_foo20000101_xyz20190101.pdf... | { "File_12082019.pdf": "", "File_01011999.pdf": "", "File_01012000.pdf": "", } | assert | collection | tests/combined/test_rename_regex.py | test_rename_files_date | 24 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
FILES = {
"test.txt": "",
"file.txt": "Hello world\nAnother line",
"another.txt": "",
"folder": {
"x.txt": "",
"empty_sub": {},
},
"empty_folder": {},
}
def test_delete_deep(fs):
files = {
"fil... | {} | assert | collection | tests/actions/test_delete.py | test_delete_deep | 97 | null | |
tfeldmann/organize | import pytest
from organize.config import Config, ConfigError
def test_error_filter_dict():
STR = """
rules:
- locations: '/'
filters:
extension: 'jpg'
name: test
actions:
- trash
"""
with pytest.raises( | ConfigError) | pytest.raises | variable | tests/core/test_config.py | test_error_filter_dict | 74 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_codepost_usecase(fs):
files = {
"Devonte-Betts.txt": "",
"Alaina-Cornish.txt": "",
"Dimitri-Bean.txt": "",
"Lowri-Frey.txt": "",
"Someunknown-User.txt": "",
}
make_files(files, "test")
... | { "dbetts@mail.de.txt": "", "acornish@google.com.txt": "", "dbean@aol.com.txt": "", "l-frey@frey.org.txt": "", } | assert | collection | tests/combined/test_codepost_usecase.py | test_codepost_usecase | 36 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from organize.actions.common.conflict import next_free_name, resolve_conflict
from organize.output import JSONL
from organize.resource import Resource
from organize.template import Template
@pytest.mark.parametrize(
"mode,result,f... | (result[0], Path(result[1])) | assert | collection | tests/actions/test_conflict_resolution.py | test_resolve_overwrite_conflict | 88 | null | |
tfeldmann/organize | import sys
import pytest
from conftest import make_files, read_files
from organize import Config
@pytest.mark.skipif(sys.platform == "win32", reason="Wrong path names in windows")
def test_ignore_seen_files(fs):
make_files(
{
"sub": {},
"foo.txt": "",
"bar.txt": "",
... | { "sub": { "foo.txt": "", "bar.txt": "", } } | assert | collection | tests/core/test_ignore_seen_files.py | test_ignore_seen_files | 28 | null | |
tfeldmann/organize | from pathlib import Path
from conftest import make_files, read_files
from organize.actions.common.target_path import prepare_target_path, user_wants_a_folder
def test_prepare_folder_target_advanced(fs):
assert (
prepare_target_path(
src_name="dst",
dst="/some/test/folder",
... | {"test": {"folder": {}}} | assert | collection | tests/actions/test_common.py | test_prepare_folder_target_advanced | 61 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import ORGANIZE_DIR
from pyfakefs.fake_filesystem import FakeFilesystem
from organize import Config
from organize.filters.exif import matches_tags
def images_folder(fs: FakeFilesystem):
RESOURCE_DIR = str(ORGANIZE_DIR / "tests" / "resources" / "images-with-exi... | set(["3.jpg", "4.jpg"]) | assert | func_call | tests/filters/test_exif.py | test_exif_filter_by_multiple_keys | 126 | null | |
tfeldmann/organize | import sys
from organize.utils import (
ChangeDetector,
deep_merge,
deep_merge_inplace,
has_executable,
)
def test_merges_dicts():
a = {"a": 1, "b": {"b1": 2, "b2": 3}}
b = {"a": 1, "b": {"b1": 4}}
print(deep_merge(a, b))
assert deep_merge(a, b)["a"] == 1
assert deep_merge(a, b)[... | 3 | assert | numeric_literal | tests/test_utils.py | test_merges_dicts | 36 | null | |
tfeldmann/organize | import pytest
from conftest import make_files
from organize import Config
@pytest.mark.parametrize(
"filter_mode, expected_msgs",
(
("any", ["foo", "x"]),
("all", ["foo"]),
("none", ["baz"]),
),
)
def test_filter_mode(fs, testoutput, filter_mode, expected_msgs):
make_files(["fo... | expected_msgs | assert | variable | tests/core/test_filter_mode.py | test_filter_mode | 28 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize import Config
FILES = {
"test.txt": "",
"file.txt": "Hello world\nAnother line",
"another.txt": "",
"folder": {
"x.txt": "",
},
}
def test_copy_into_dir(fs):
make_files(FILES, "test")
config = """
rules:
... | { "test.txt": "", "file.txt": "Hello world\nAnother line", "another.txt": "", "folder": { "x.txt": "", }, "a brand": { "new": { "folder": { "test.txt": "", "file.txt": "Hello world\nAnother line", "another.txt": "", } } }, } | assert | collection | tests/actions/test_copy.py | test_copy_into_dir | 59 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_filecontent(fs):
# inspired by https://github.com/tfeldmann/organize/issues/43
files = {
"Test1.txt": "Lorem MegaCorp Ltd. ipsum\nInvoice 12345\nMore text\nID: 98765",
"Test2.txt": "Tests",
"Test3.txt": "M... | { "Homework.txt": "My Homework ...", "MegaCorp_Invoice_12345.txt": "Lorem MegaCorp Ltd. ipsum\nInvoice 12345\nMore text\nID: 98765", "Test2.txt": "Tests", } | assert | collection | tests/filters/test_filecontent.py | test_filecontent | 29 | null | |
tfeldmann/organize | from conftest import make_files, read_files
def test_make_files(fs):
files = {
"folder": {
"subfolder": {
"test.txt": "",
"other.pdf": "text",
},
},
"file.txt": "Hello world\nAnother line",
}
make_files(files, "test")
ass... | files | assert | variable | tests/test_make_files.py | test_make_files | 16 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from pyfakefs.fake_filesystem import FakeFilesystem
from organize import Config
from organize.filters import Regex
from organize.output import Default
from organize.resource import Resource
def test_podcast_sorting(fs: FakeFilesystem)... | { "My Podcast": {"Ep 1.mp3": "", "Ep 2.mp3": "", "Ep 3.mp3": ""}, "Your Podcast": {"Ep 1.mp3": "", "Ep 2.mp3": "", "Ep 3.mp3": ""}, } | assert | collection | tests/filters/test_regex.py | test_podcast_sorting | 87 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize import Config
from organize.filters import Size
def test_basic(fs):
files = {
"empty": "",
"full": "0" * 2000,
"halffull": "0" * 1010,
"two_thirds.txt": "0" * 666,
}
make_files(files, "test")
config... | { "halffull": "0" * 1010, "two_thirds.txt": "0" * 666, } | assert | collection | tests/filters/test_size.py | test_basic | 74 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import make_files, read_files
from organize import Config
from organize.utils import normalize_unicode
@pytest.mark.parametrize("a, b", CONFUSABLES)
def test_normalize(a, b):
assert a != | b | assert | variable | tests/core/test_unicode.py | test_normalize | 77 | null | |
tfeldmann/organize | from conftest import make_files, read_files
from organize import Config
def test_folder_instructions(fs):
"""
I would like to include path/folder-instructions into the filename because I have a
lot of different files (and there are always new categories added) I don't want
create rules for. For exampl... | { "other.pdf": "", "2019": { "Jobs": { "CategoryA": { "TagB": { "V01": { "draft": { "eng": { "2019_Jobs_CategoryA_TagB_A-Media_content-name_V01_draft_eng.docx": "", } } } } } }, "Work": { "CategoryC": { "V14": { "final": { "2019_Work_CategoryC_V-Test_A-Audio_V14_final.pdf": "", } } } }, }, } | assert | collection | tests/filters/test_python.py | test_folder_instructions | 167 | null | |
tfeldmann/organize | import sys
from organize.utils import (
ChangeDetector,
deep_merge,
deep_merge_inplace,
has_executable,
)
def test_does_not_insert_new_keys():
"""Will it avoid inserting new keys when required?"""
a = {"a": 1, "b": {"b1": 2, "b2": 3}}
b = {"a": 1, "b": {"b1": 4, "b3": 5}, "c": 6}
ass... | { "a": 1, "b": {"b1": 4, "b2": 3, "b3": 5}, "c": 6, } | assert | collection | tests/test_utils.py | test_does_not_insert_new_keys | 68 | null | |
tfeldmann/organize | import pytest
from conftest import make_files, read_files
from organize import Config
from organize.filters import Size
@pytest.mark.skip(reason="TODO - template vars in filters not supported")
def test_python_args(testfs):
make_files(
testfs,
{
"empty": "",
"full": "0" * 2... | { "empty": "", "halffull": "0" * 1010, "two_thirds.txt": "0" * 666, } | assert | collection | tests/filters/test_size.py | test_python_args | 102 | null | |
tfeldmann/organize | from pathlib import Path
import pytest
from conftest import ORGANIZE_DIR
from pyfakefs.fake_filesystem import FakeFilesystem
from organize import Config
from organize.filters.exif import matches_tags
def images_folder(fs: FakeFilesystem):
RESOURCE_DIR = str(ORGANIZE_DIR / "tests" / "resources" / "images-with-exi... | set( [ "3: 12.08.2017", "4: 22.02.2018", "5: 08.07.2015", ] ) | assert | func_call | tests/filters/test_exif.py | test_exif_filter_tag_exists_and_date_format | 103 | null | |
tfeldmann/organize | import sys
import pytest
from conftest import make_files, read_files
from organize import Config
def test_issue_200(fs):
# https://github.com/tfeldmann/organize/issues/200
config = """
# try to extract the first date from the file and rename it accordingly
rules:
- name: date_rename
loc... | { "2022-23-03_20220401_173738.txt": "Datum: 23.03.2022", } | assert | collection | tests/core/test_ignore_seen_files.py | test_issue_200 | 53 | null | |
py2many/py2many | import os
import unittest
from pathlib import Path
from shutil import rmtree
from unittest.mock import Mock
from py2many.cli import _get_all_settings, _process_dir
from py2many.exceptions import (
AstNotImplementedError,
AstTypeNotSupported,
AstUnrecognisedBinOp,
)
SHOW_ERRORS = os.environ.get("SHOW_ERROR... | *_process_dir( settings, transpiler_module, OUT_DIR, False, _suppress_exceptions=False )) | assert_* | func_call | tests/test_transpile_self.py | test_rust_recursive | SelfTranspileTests | 71 | null |
py2many/py2many | import textwrap
def parse(*args):
return "\n".join(args)
def test_print_multiple_vars():
source = parse('print(("hi", "there" ))')
cpp = transpile(source)
assert cpp == | parse( 'std::cout << std::string{"hi"} << std::string{"there"};', "std::cout << std::endl;", ) | assert | func_call | tests/test_transpiler_cpp.py | test_print_multiple_vars | 32 | null | |
py2many/py2many | from typing import List
def inline_pass():
pass
def inline_ellipsis(): ...
def indexing():
sum = 0
a: List[int] = []
for i in range(10):
a.append(i)
sum += a[i]
return sum
def infer_bool(code: int):
return code in [1, 2, 4]
def show():
# assign
a1 = 10
# multi-as... | 15 | assert | numeric_literal | tests/cases/coverage.py | show | 29 | null | |
py2many/py2many | import os
import unittest
from pathlib import Path
from shutil import rmtree
from unittest.mock import Mock
from py2many.cli import _get_all_settings, _process_dir
from py2many.exceptions import (
AstNotImplementedError,
AstTypeNotSupported,
AstUnrecognisedBinOp,
)
SHOW_ERRORS = os.environ.get("SHOW_ERROR... | *_process_dir( settings, PY2MANY_MODULE, OUT_DIR, False, _suppress_exceptions=suppress_exceptions, )) | assert_* | func_call | tests/test_transpile_self.py | test_dlang_recursive | SelfTranspileTests | 120 | null |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
from typing import List
def main_func():
ands: List[bool] = []
ors: List[bool] = ... | [False, True, True, True] | assert | collection | tests/expected/bitops.py | main_func | 18 | null | |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
def foo():
a: int = 10
b: int = a
assert b == | 10 | assert | numeric_literal | tests/expected/infer.py | foo | 10 | null | |
py2many/py2many | import textwrap
def parse(*args):
return "\n".join(args)
def test_declare():
source = parse("x = 3")
cpp = transpile(source)
assert cpp == | "auto x = 3;" | assert | string_literal | tests/test_transpiler_cpp.py | test_declare | 16 | null | |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
def complex_test():
c1: complex = 2 + 3j
c2: complex = 4 + 5j
c3: complex = c... | 3.7 + 8j | assert | complex_expr | tests/expected/complex.py | complex_test | 17 | null | |
py2many/py2many | import argparse
import logging
import os.path
import platform
import sys
from functools import lru_cache
from itertools import product
from pathlib import Path
from subprocess import run
from unittest.mock import Mock
import pytest
from py2many.cli import (
_create_cmd,
_get_all_settings,
_get_output_path... | proc.returncode | assert | complex_expr | tests/test_cli.py | test_generated | TestCodeGenerator | 313 | null |
py2many/py2many | def show():
try:
raise Exception("foo")
except Exception as e:
print("caught")
finally:
print("Finally")
try:
raise Exception("foo")
except:
print("Got it")
try:
raise Exception("foo")
except Exception as e:
assert "foo" in | str(e) | assert | func_call | tests/cases/exceptions.py | show | 20 | null | |
py2many/py2many | import os
import unittest
from pathlib import Path
from shutil import rmtree
from unittest.mock import Mock
from py2many.cli import _get_all_settings, _process_dir
from py2many.exceptions import (
AstNotImplementedError,
AstTypeNotSupported,
AstUnrecognisedBinOp,
)
SHOW_ERRORS = os.environ.get("SHOW_ERROR... | format_error_count | assert | variable | tests/test_transpile_self.py | assert_counts | 55 | null | |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
def complex_test():
c1: complex = 2 + 3j
c2: complex = 4 + 5j
c3: complex = c... | 5 + 3j | assert | complex_expr | tests/expected/complex.py | complex_test | 13 | null | |
py2many/py2many | import os
import unittest
from pathlib import Path
from shutil import rmtree
from unittest.mock import Mock
from py2many.cli import _get_all_settings, _process_dir
from py2many.exceptions import (
AstNotImplementedError,
AstTypeNotSupported,
AstUnrecognisedBinOp,
)
SHOW_ERRORS = os.environ.get("SHOW_ERROR... | *_process_dir( settings, PY2MANY_MODULE, OUT_DIR, False, _suppress_exceptions=False )) | assert_* | func_call | tests/test_transpile_self.py | test_rust_recursive | SelfTranspileTests | 80 | null |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
from typing import List
def main_func():
ands: List[bool] = []
ors: List[bool] = ... | [False, False, False, True] | assert | collection | tests/expected/bitops.py | main_func | 17 | null | |
py2many/py2many | import textwrap
def parse(*args):
return "\n".join(args)
def test_vector_find_out_type():
source = parse("values = []", "values.append(1)")
cpp = transpile(source)
assert cpp == | parse("std::vector<decltype(1)> values = {};", "values.push_back(1);") | assert | func_call | tests/test_transpiler_cpp.py | test_vector_find_out_type | 149 | null | |
py2many/py2many | import ast
import sys
import unittest
from py2many.inference import infer_types, infer_types_typpete
def parse(*args):
return ast.parse("\n".join(args))
class TestInference:
def test_infer_types(self):
tree = parse("a = [10, 20]")
assert not hasattr(tree.body[0].targets[0], "annotation")
... | "List" | assert | string_literal | tests/test_inference.py | test_infer_types | TestInference | 18 | null |
py2many/py2many | import unittest
from pathlib import Path
from unittest.mock import Mock
from py2many.cli import _get_all_settings
class TestSettings(unittest.TestCase):
def test_conan_include_dirs(self):
include_dirs = _conan_include_dirs()
assert len(include_dirs) == | len(REQUIRED_INCLUDE_FILES) | assert | func_call | tests/test_settings.py | test_conan_include_dirs | TestSettings | 21 | null |
py2many/py2many | from py2many.smt import check_sat, default_value, get_value
from py2many.smt import pre as smt_pre
x: int = default_value(int)
y: int = default_value(int)
z: float = default_value(float)
def equation(x: int, y: int) -> bool:
if smt_pre:
assert x > 2
assert y < 10
assert x + 2 * y == | 7 | assert | numeric_literal | tests/cases/equations.py | equation | 13 | null | |
py2many/py2many | def compare_with_integer_variable():
i: int = 0
s: int = 1
if i:
s = 2
else:
s = 3
assert s == | 3 | assert | numeric_literal | tests/cases/comparison.py | compare_with_integer_variable | 9 | null | |
py2many/py2many | from py2many.smt import check_sat, default_value, get_value
from py2many.smt import pre as smt_pre
x: int = default_value(int)
y: int = default_value(int)
z: float = default_value(float)
def equation(x: int, y: int) -> bool:
if smt_pre:
assert x > | 2 | assert | numeric_literal | tests/cases/equations.py | equation | 11 | null | |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
def compare_assert(a: int, b: int):
assert a == | b | assert | variable | tests/expected/assert.py | compare_assert | 8 | null | |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
def complex_test():
c1: complex = 2 + 3j
c2: complex = 4 + 5j
c3: complex = c... | 2 + 7j | assert | complex_expr | tests/expected/complex.py | complex_test | 15 | null | |
py2many/py2many | import io
from ctypes import c_uint8 as u8
from ctypes import c_uint32 as u32
from dataclasses import dataclass
import pytest
from py2many.result import Error, Ok, Result
@pytest.mark.parametrize(
"input, expected",
[
(b"0", u32(0)),
(b"12", u32(12)),
(b"56789", u32(56789)),
#... | expected.value | assert | complex_expr | tests/cases/hello-wuffs.py | test_parser | 53 | null | |
py2many/py2many | import ast
from py2many.context import add_list_calls, add_variable_context
from py2many.scope import add_scope_context
from py2many.tracer import is_list, is_recursive, value_expr, value_type
def parse(*args):
source = ast.parse("\n".join(args))
add_variable_context(source, (source,))
add_scope_context(s... | "3 * 1 - 5 + 2" | assert | string_literal | tests/test_tracer.py | test_catch_long_expression_chain | TestValueExpr | 73 | null |
py2many/py2many | from adt import adt as sealed
from py2many.smt import check_sat, default_value, get_model
from py2many.smt import pre as smt_pre
def classify_triangle_correct(a: int, b: int, c: int) -> TriangleType:
"""Classify triangle based on side lengths"""
# Classify the triangle
if a == b and b == c:
retur... | b + c | assert | complex_expr | tests/cases/triangle_buggy.py | classify_triangle | 70 | null | |
py2many/py2many | from typing import List
def main():
ands: List[bool] = []
ors: List[bool] = []
xors: List[bool] = []
for a in [False, True]:
for b in [False, True]:
ands.append(a & b)
ors.append(a | b)
xors.append(a ^ b)
assert ands == | [False, False, False, True] | assert | collection | tests/cases/bitops.py | main | 15 | null | |
py2many/py2many | import textwrap
def parse(*args):
return "\n".join(args)
def test_assert():
source = parse("assert 1 == foo(3)")
cpp = transpile(source, testing=True)
assert cpp == | "#include <catch2/catch_test_macros.hpp>\nREQUIRE(1 == foo(3));" | assert | string_literal | tests/test_transpiler_cpp.py | test_assert | 41 | null | |
py2many/py2many | from typing import List
def main():
ands: List[bool] = []
ors: List[bool] = []
xors: List[bool] = []
for a in [False, True]:
for b in [False, True]:
ands.append(a & b)
ors.append(a | b)
xors.append(a ^ b)
assert ands == [False, False, False, True]
as... | [False, True, True, True] | assert | collection | tests/cases/bitops.py | main | 16 | null | |
py2many/py2many | import ast
from py2many.context import add_list_calls, add_variable_context
from py2many.scope import add_scope_context
from py2many.tracer import is_list, is_recursive, value_expr, value_type
def parse(*args):
source = ast.parse("\n".join(args))
add_variable_context(source, (source,))
add_scope_context(s... | "3" | assert | string_literal | tests/test_tracer.py | test_direct_assignment | TestValueType | 20 | null |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
import asyncio
async def nested() -> int:
return 42
async def async_main():
ass... | 42 | assert | numeric_literal | tests/expected/asyncio_test.py | async_main | 13 | null | |
py2many/py2many | from typing import List
def inline_pass():
pass
def inline_ellipsis(): ...
def indexing():
sum = 0
a: List[int] = []
for i in range(10):
a.append(i)
sum += a[i]
return sum
def infer_bool(code: int):
return code in [1, 2, 4]
def show():
# assign
a1 = 10
# multi-as... | 10 | assert | numeric_literal | tests/cases/coverage.py | show | 51 | null | |
py2many/py2many | import asyncio
async def nested() -> int:
return 42
async def async_main():
assert await nested() == | 42 | assert | numeric_literal | tests/cases/asyncio_test.py | async_main | 11 | null | |
py2many/py2many | import os
import unittest
from pathlib import Path
from shutil import rmtree
from unittest.mock import Mock
from py2many.cli import _get_all_settings, _process_dir
from py2many.exceptions import (
AstNotImplementedError,
AstTypeNotSupported,
AstUnrecognisedBinOp,
)
SHOW_ERRORS = os.environ.get("SHOW_ERROR... | failures) | assert_* | variable | tests/test_transpile_self.py | assert_reformat_fails | 28 | null | |
py2many/py2many | import unittest
from pathlib import Path
from unittest.mock import Mock
from py2many.cli import _get_all_settings
class TestSettings(unittest.TestCase):
def test_env_clang_format_style(self):
lang = "cpp"
env = {"CLANG_FORMAT_STYLE": "Google"}
settings = _get_all_settings(Mock(indent=4), ... | settings.formatter) | self.assertIn | complex_expr | tests/test_settings.py | test_env_clang_format_style | TestSettings | 32 | null |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
from typing import List
def inline_pass():
pass
def inline_ellipsis(): ...
def inde... | 11 | assert | numeric_literal | tests/expected/coverage.py | show | 71 | null | |
py2many/py2many | import argparse
import logging
import os.path
import platform
import sys
from functools import lru_cache
from itertools import product
from pathlib import Path
from subprocess import run
from unittest.mock import Mock
import pytest
from py2many.cli import (
_create_cmd,
_get_all_settings,
_get_output_path... | generated_cleaned | assert | variable | tests/test_cli.py | test_generated | TestCodeGenerator | 259 | null |
py2many/py2many | import textwrap
def parse(*args):
return "\n".join(args)
def test_create_catch_test_case():
source = parse("def test_fun():", " assert True")
cpp = transpile(source, testing=True)
assert cpp == | parse( "#include <catch2/catch_test_macros.hpp>", 'TEST_CASE("test_fun") {', "REQUIRE(true);", "}", ) | assert | func_call | tests/test_transpiler_cpp.py | test_create_catch_test_case | 132 | null | |
py2many/py2many | import ast
from py2many.context import add_variable_context
from py2many.scope import add_scope_context
def parse(*args):
source = ast.parse("\n".join(args))
add_scope_context(source)
return source
class TestScopeList:
def test_find_returns_most_upper_definition(self):
source = parse("x = 1",... | 1 | assert | numeric_literal | tests/test_scope.py | test_find_returns_most_upper_definition | TestScopeList | 26 | null |
py2many/py2many | import ast
from py2many.clike import c_symbol
def test_c_symbol():
source = ast.parse("x == y")
equals_symbol = source.body[0].value.ops[0]
assert c_symbol(equals_symbol) == | "==" | assert | string_literal | tests/test_clike.py | test_c_symbol | 9 | null | |
py2many/py2many | from typing import Callable, Dict, List, Set, Optional
from ctypes import c_int8 as i8, c_int16 as i16, c_int32 as i32, c_int64 as i64
from ctypes import c_uint8 as u8, c_uint16 as u16, c_uint32 as u32, c_uint64 as u64
import sys
def default_builtins():
a: str = str()
b: bool = bool()
c: int = int()
d:... | 0.0 | assert | numeric_literal | tests/expected/built_ins.py | default_builtins | 15 | null | |
py2many/py2many | def complex_test():
c1 = 2 + 3j
c2 = 4 + 5j
c3 = c1 + c2
assert c3 == 6 + 8j
c4 = c1 + 3
assert c4 == 5 + 3j
c5 = c1 + 4j
assert c5 == | 2 + 7j | assert | complex_expr | tests/cases/complex.py | complex_test | 12 | null | |
py2many/py2many | import argparse
import logging
import os.path
import platform
import sys
from functools import lru_cache
from itertools import product
from pathlib import Path
from subprocess import run
from unittest.mock import Mock
import pytest
from py2many.cli import (
_create_cmd,
_get_all_settings,
_get_output_path... | stdout | assert | variable | tests/test_cli.py | test_generated | TestCodeGenerator | 332 | null |
py2many/py2many | import ast
import os.path
import sys
from functools import lru_cache, partial
from itertools import product
from subprocess import run
from textwrap import dedent
from unittest.mock import Mock
import pytest
from test_cli import BUILD_DIR, COMPILERS, ENV, GENERATED_DIR, INVOKER, KEEP_GENERATED
from test_cli import LA... | expected_error | assert | variable | tests/test_unsupported.py | test_error_cases | TestCodeGenerator | 420 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.