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 |
|---|---|---|---|---|---|---|---|---|---|
marcwebbie/passpie | import passpie.config
import yaml
def test_config_read_logs_debug_when_config_file_not_found_and_returns_empty(mocker):
mocker.patch('passpie.config.open', side_effect=IOError, create=True)
mock_logging = mocker.patch('passpie.config.logging')
result = passpie.config.read('path')
assert result == {}
... | 'config file "path" not found') | assert_* | string_literal | tests/test_config.py | test_config_read_logs_debug_when_config_file_not_found_and_returns_empty | 21 | null | |
marcwebbie/passpie | import os
from tinydb import where, Query
from tinydb.storages import MemoryStorage
from passpie.database import Database, PasspieStorage
from .helpers import MockerTestCase
def test_database_update_uses_table_update_credential_to_database(mocker):
config = {
'path': 'path',
'extension': '.pass',... | query) | assert_* | variable | tests/test_database.py | test_database_update_uses_table_update_credential_to_database | 187 | null | |
marcwebbie/passpie | import pytest
from passpie import clipboard
def test_copy_calls_copy_osx_when_on_darwin_system(mocker):
mocker.patch('passpie.clipboard.process.call')
mocker.patch('passpie.clipboard.platform.system', return_value='Darwin')
mock_copy_osx = mocker.patch('passpie.clipboard._copy_osx')
mock_copy_linux = ... | False | assert | bool_literal | tests/test_clipboard.py | test_copy_calls_copy_osx_when_on_darwin_system | 36 | null | |
marcwebbie/passpie | import pytest
from passpie import clipboard
def test_logs_error_msg_when_platform_not_supported(mocker):
mocker.patch('passpie.clipboard.platform.system', return_value='unknown')
mock_logger = mocker.patch('passpie.clipboard.logging')
clipboard.copy('text')
assert mock_logger.error.called
msg = "... | msg) | assert_* | variable | tests/test_clipboard.py | test_logs_error_msg_when_platform_not_supported | 89 | null | |
marcwebbie/passpie | import passpie.config
import yaml
def test_config_read_logs_error_when_config_file_malformed_found_and_returns_empty(mocker):
mocker.patch('passpie.config.open', side_effect=yaml.scanner.ScannerError('message'),
create=True)
mock_logging = mocker.patch('passpie.config.logging')
result = p... | 'Malformed user configuration file: message') | assert_* | string_literal | tests/test_config.py | test_config_read_logs_error_when_config_file_malformed_found_and_returns_empty | 32 | null | |
marcwebbie/passpie | import csv
import click
from click.testing import CliRunner
import pytest
from passpie import cli
from passpie.database import Database
def test_call_to_cli_exit_with_error_when_missing_dependencies(mocker):
mocker.patch('passpie.cli.Database')
mocker.patch('passpie.cli.ensure_dependencies', side_effect=Runt... | 0 | assert | numeric_literal | tests/test_cli.py | test_call_to_cli_exit_with_error_when_missing_dependencies | 53 | null | |
marcwebbie/passpie | import pytest
from passpie.importers.keepass_importer import KeepassImporter
def test_keepass_importer_returns_false_when_csv_files_hasnt_expected_headers(mocker, mock_open):
headers = reversed(['Group', 'Title', 'Username', 'Password', 'URL', 'Notes'])
mocker.patch('passpie.importers.keepass_importer.unicode... | False | assert | bool_literal | tests/test_importers/test_keepass_importer.py | test_keepass_importer_returns_false_when_csv_files_hasnt_expected_headers | 13 | null | |
marcwebbie/passpie | from collections import namedtuple
import os
import shutil
import sys
import tempfile
import yaml
from passpie.importers import find_importer, BaseImporter, get_instances
from passpie.importers.default_importer import DefaultImporter
from passpie.importers.pysswords_importer import PysswordsImporter
def mock_open():... | [] | assert | collection | tests/test_importers/test_pysswords_importer.py | test_pysswords_handle_returns_empty_when_bad_passphrase | 83 | null | |
marcwebbie/passpie | from collections import namedtuple
import os
import shutil
import sys
import tempfile
import yaml
from passpie.importers import find_importer, BaseImporter, get_instances
from passpie.importers.default_importer import DefaultImporter
from passpie.importers.pysswords_importer import PysswordsImporter
def mock_open():... | 'Pysswords is not installed') | assert_* | string_literal | tests/test_importers/test_pysswords_importer.py | test_pysswords_returns_false_with_logging_when_not_installed | 31 | null | |
marcwebbie/passpie | import pytest
from passpie.credential import split_fullname, make_fullname
def test_split_fullname_returns_expected_login_and_name(mocker):
assert split_fullname("foo@example") == ("foo", "example")
assert split_fullname("foo@example.com") == ("foo", "example.com")
assert split_fullname("@example.com") =... | ("", "example.com") | assert | collection | tests/test_credential.py | test_split_fullname_returns_expected_login_and_name | 15 | null | |
marcwebbie/passpie | import re
import pytest
from passpie.utils import genpass, mkdir_open, ensure_dependencies, touch
def mock_open():
try:
from mock import mock_open as mopen
except:
from unittest.mock import mock_open as mopen
return mopen()
def test_ensure_dependencies_raises_runtime_when_gpg_not_installe... | RuntimeError) | pytest.raises | variable | tests/test_utils.py | test_ensure_dependencies_raises_runtime_when_gpg_not_installed | 53 | null | |
marcwebbie/passpie | import re
import pytest
from passpie.utils import genpass, mkdir_open, ensure_dependencies, touch
def mock_open():
try:
from mock import mock_open as mopen
except:
from unittest.mock import mock_open as mopen
return mopen()
def test_genpass_generates_a_password_with_length_32(mocker):
... | 32 | assert | numeric_literal | tests/test_utils.py | test_genpass_generates_a_password_with_length_32 | 17 | null | |
marcwebbie/passpie | import pytest
from passpie.credential import split_fullname, make_fullname
def test_make_fullname_returns_expected_fullname(mocker):
assert make_fullname("foo", "bar") == "foo@bar"
assert make_fullname("_", "bar") == "_@bar"
assert make_fullname(None, "bar") == | "@bar" | assert | string_literal | tests/test_credential.py | test_make_fullname_returns_expected_fullname | 23 | null | |
marcwebbie/passpie | import os
from tinydb import where, Query
from tinydb.storages import MemoryStorage
from passpie.database import Database, PasspieStorage
from .helpers import MockerTestCase
def test_database_credential_with_fullname_does_a_db_where_with_split_fullname(mocker):
config = {
'path': 'path',
'extensi... | [{}] | assert | collection | tests/test_database.py | test_database_credential_with_fullname_does_a_db_where_with_split_fullname | 97 | null | |
marcwebbie/passpie | from collections import namedtuple
import os
import shutil
import sys
import tempfile
import yaml
from passpie.importers import find_importer, BaseImporter, get_instances
from passpie.importers.default_importer import DefaultImporter
from passpie.importers.pysswords_importer import PysswordsImporter
def mock_open():... | '.keys not found in path') | assert_* | string_literal | tests/test_importers/test_pysswords_importer.py | test_pysswords_returns_false_with_logging_when_path_not_dir | 45 | null | |
marcwebbie/passpie | from collections import namedtuple
import os
import shutil
import sys
import tempfile
import yaml
from passpie.importers import find_importer, BaseImporter, get_instances
from passpie.importers.default_importer import DefaultImporter
from passpie.importers.pysswords_importer import PysswordsImporter
def mock_open():... | mock_importer2 | assert | variable | tests/test_importers/test_default_importer.py | test_find_importer_returns_first_match_default_importer | 33 | null | |
marcwebbie/passpie | from collections import namedtuple
import os
import shutil
import sys
import tempfile
import yaml
from passpie.importers import find_importer, BaseImporter, get_instances
from passpie.importers.default_importer import DefaultImporter
from passpie.importers.pysswords_importer import PysswordsImporter
def mock_open():... | 'passpie_importers') | assert_* | string_literal | tests/test_importers/test_base_importer.py | test_find_importers_through_entry_points | 51 | null | |
marcwebbie/passpie | from passpie import checkers
from datetime import datetime, timedelta
def test_repeated_deepcopy_credentials(mocker):
mock_deepcopy = mocker.patch('passpie.checkers.deepcopy')
credentials = [{'fullname': 'foo@example.com', 'password': 's3cr3t'}]
checkers.repeated(credentials, limit=1)
assert mock_deep... | credentials) | assert_* | variable | tests/test_checkers.py | test_repeated_deepcopy_credentials | 11 | null | |
marcwebbie/passpie | import re
import pytest
from passpie.utils import genpass, mkdir_open, ensure_dependencies, touch
def mock_open():
try:
from mock import mock_open as mopen
except:
from unittest.mock import mock_open as mopen
return mopen()
def test_mkdir_open_makedirs_on_path_dirname(mocker):
mock_os... | dirname) | assert_* | variable | tests/test_utils.py | test_mkdir_open_makedirs_on_path_dirname | 32 | null | |
marcwebbie/passpie | import pytest
from passpie.credential import split_fullname, make_fullname
def test_split_fullname_returns_expected_login_and_name(mocker):
assert split_fullname("foo@example") == ("foo", "example")
assert split_fullname("foo@example.com") == ("foo", "example.com")
assert split_fullname("@example.com") ==... | ("foo@example.com", "archive.com") | assert | collection | tests/test_credential.py | test_split_fullname_returns_expected_login_and_name | 17 | null | |
marcwebbie/passpie | import re
import pytest
import passpie.crypt
from passpie.crypt import (
KEY_INPUT,
DEVNULL,
make_key_input,
export_keys,
export_secret_keys,
import_keys,
create_keys,
)
def mock_call(mocker):
return mocker.patch('passpie.crypt.process.call')
def mock_open():
try:
from mo... | 'PUBLIC') | assert_* | string_literal | tests/test_crypt.py | test_create_keys_if_path_is_passed_create_file_homedir | 132 | null | |
marcwebbie/passpie | import pytest
from passpie.process import Proc, call, DEVNULL, PIPE
def mock_popen(mocker):
return mocker.patch('passpie.process.Popen')
def test_call_output_and_error_are_utf8_decoded(mocker, mock_popen):
MockProc = mocker.patch('passpie.process.Proc')
output = mocker.MagicMock()
error = mocker.Magic... | error.decode('utf-8') | assert | func_call | tests/test_process.py | test_call_output_and_error_are_utf8_decoded | 53 | null | |
marcwebbie/passpie | import os
from tinydb import where, Query
from tinydb.storages import MemoryStorage
from passpie.database import Database, PasspieStorage
from .helpers import MockerTestCase
def test_database_add_insert_credential_to_database(mocker):
config = {
'path': 'path',
'extension': '.pass',
}
db ... | credential) | assert_* | variable | tests/test_database.py | test_database_add_insert_credential_to_database | 150 | null | |
marcwebbie/passpie | from passpie.table import Table
def test_render_colorize_expected_columns(mocker):
colors = {'name': 'red', 'login': 'blue'}
table = Table(headers=['name', 'login'], colors=colors)
mock_tabulate = mocker.patch('passpie.table.tabulate')
mocker.patch.object(table, 'colorize', return_value='colorized')
... | 'foo') | assert_* | string_literal | tests/test_table.py | test_render_colorize_expected_columns | 43 | null | |
marcwebbie/passpie | import pytest
from passpie.importers.keepass_importer import KeepassImporter
def test_keepass_importer_returns_true_when_csv_files_has_expected_headers(mocker, mock_open):
headers = ['Group', 'Title', 'Username', 'Password', 'URL', 'Notes']
mocker.patch('passpie.importers.keepass_importer.unicode_csv_reader',... | True | assert | bool_literal | tests/test_importers/test_keepass_importer.py | test_keepass_importer_returns_true_when_csv_files_has_expected_headers | 36 | null | |
marcwebbie/passpie | import pytest
from passpie.importers.csv_importer import CSVImporter
def test_csv_importer_match_always_returns_false():
importer = CSVImporter()
assert importer.match('filepath') is | False | assert | bool_literal | tests/test_importers/test_csv_importer.py | test_csv_importer_match_always_returns_false | 8 | null | |
marcwebbie/passpie | import pytest
from passpie import clipboard
def test_copy_calls_copy_osx_when_on_darwin_system(mocker):
mocker.patch('passpie.clipboard.process.call')
mocker.patch('passpie.clipboard.platform.system', return_value='Darwin')
mock_copy_osx = mocker.patch('passpie.clipboard._copy_osx')
mock_copy_linux = ... | 0) | assert_* | numeric_literal | tests/test_clipboard.py | test_copy_calls_copy_osx_when_on_darwin_system | 38 | null | |
marcwebbie/passpie | import pytest
from passpie.process import Proc, call, DEVNULL, PIPE
def mock_popen(mocker):
return mocker.patch('passpie.process.Popen')
def test_call_sets_stderr_as_pipe_when_logger_level_is_set_to_debug(mocker, mock_popen):
MockProc = mocker.patch('passpie.process.Proc')
MockProc().__enter__.return_valu... | PIPE | assert | variable | tests/test_process.py | test_call_sets_stderr_as_pipe_when_logger_level_is_set_to_debug | 39 | null | |
marcwebbie/passpie | import pytest
from passpie.importers.csv_importer import CSVImporter
def test_csv_importer_returns_list_of_credentials(mocker, mock_open):
headers = ['Name', 'Login', 'Password', 'Comment']
rows = [
headers,
['example.com', 'foo', 'password', ''],
['example.com', 'bar', 'password', '']... | expected_credentials | assert | variable | tests/test_importers/test_csv_importer.py | test_csv_importer_returns_list_of_credentials | 39 | null | |
marcwebbie/passpie | import re
import pytest
import passpie.crypt
from passpie.crypt import (
KEY_INPUT,
DEVNULL,
make_key_input,
export_keys,
export_secret_keys,
import_keys,
create_keys,
)
def mock_call(mocker):
return mocker.patch('passpie.crypt.process.call')
def mock_open():
try:
from mo... | 'PRIVATE') | assert_* | string_literal | tests/test_crypt.py | test_create_keys_if_path_is_passed_create_file_homedir | 133 | null | |
marcwebbie/passpie | import pytest
from passpie.process import Proc, call, DEVNULL, PIPE
def mock_popen(mocker):
return mocker.patch('passpie.process.Popen')
def test_call_output_and_error_are_utf8_decoded(mocker, mock_popen):
MockProc = mocker.patch('passpie.process.Proc')
output = mocker.MagicMock()
error = mocker.Magic... | output.decode('utf-8') | assert | func_call | tests/test_process.py | test_call_output_and_error_are_utf8_decoded | 52 | null | |
marcwebbie/passpie | import re
import pytest
import passpie.crypt
from passpie.crypt import (
KEY_INPUT,
DEVNULL,
make_key_input,
export_keys,
export_secret_keys,
import_keys,
create_keys,
)
def mock_call(mocker):
return mocker.patch('passpie.crypt.process.call')
def mock_open():
try:
from mo... | 2 | assert | numeric_literal | tests/test_crypt.py | test_crypt_export_secret_keys_calls_fallback_gpg_command_on_export_keys_when_error | 65 | null | |
marcwebbie/passpie | import passpie.config
import yaml
def test_config_create_adds_an_empty_dot_config_file_to_path_when_default_false(mocker, mock_open):
config_file = mocker.patch('passpie.config.open', mock_open(), create=True)
mock_yaml_dump = mocker.patch('passpie.config.yaml.dump')
overrides = {}
passpie.config.creat... | mock_yaml_dump(overrides, default_flow_style=False)) | assert_* | func_call | tests/test_config.py | test_config_create_adds_an_empty_dot_config_file_to_path_when_default_false | 41 | null | |
marcwebbie/passpie | import re
import pytest
from passpie.utils import genpass, mkdir_open, ensure_dependencies, touch
def mock_open():
try:
from mock import mock_open as mopen
except:
from unittest.mock import mock_open as mopen
return mopen()
def test_mkdir_open_handle_oserror_for_file_exist(mocker):
mo... | OSError) | pytest.raises | variable | tests/test_utils.py | test_mkdir_open_handle_oserror_for_file_exist | 45 | null | |
marcwebbie/passpie | import csv
import click
from click.testing import CliRunner
import pytest
from passpie import cli
from passpie.database import Database
def test_validate_cols_returns_none_when_missing_cols(mocker):
value_missing_name = ',login,,password,,,comment'
value_missing_login = ',name,,password,,,comment'
value_... | None | assert | none_literal | tests/test_cli.py | test_validate_cols_returns_none_when_missing_cols | 133 | null | |
marcwebbie/passpie | import re
import pytest
import passpie.crypt
from passpie.crypt import (
KEY_INPUT,
DEVNULL,
make_key_input,
export_keys,
export_secret_keys,
import_keys,
create_keys,
)
def mock_call(mocker):
return mocker.patch('passpie.crypt.process.call')
def mock_open():
try:
from mo... | command) | assert_* | variable | tests/test_crypt.py | test_crypt_export_secret_keys_calls_fallback_gpg_command_on_export_keys_when_error | 67 | null | |
marcwebbie/passpie | import pytest
from passpie.importers.keepass_importer import KeepassImporter
def test_keepass_importer_returns_expected_credentials_for_row(mocker, mock_open):
rows = [
['Group', 'Title', 'Username', 'Password', 'URL', 'Notes'],
['Root', 'Email', 'foo', 'password', 'example.org', ''],
['Ro... | credentials | assert | variable | tests/test_importers/test_keepass_importer.py | test_keepass_importer_returns_expected_credentials_for_row | 64 | null | |
marcwebbie/passpie | import csv
import click
from click.testing import CliRunner
import pytest
from passpie import cli
from passpie.database import Database
class CliTests(object):
def test_cli_show_error_no_such_command(self, mocker, mock_config, irunner):
with mock_config():
result = irunner.invoke(cli.cli, ['... | 2 | assert | numeric_literal | tests/test_cli.py | test_cli_show_error_no_such_command | CliTests | 152 | null |
marcwebbie/passpie | from collections import namedtuple
import os
import shutil
import sys
import tempfile
import yaml
from passpie.importers import find_importer, BaseImporter, get_instances
from passpie.importers.default_importer import DefaultImporter
from passpie.importers.pysswords_importer import PysswordsImporter
def mock_open():... | False | assert | bool_literal | tests/test_importers/test_pysswords_importer.py | test_pysswords_returns_false_with_logging_when_not_installed | 29 | null | |
marcwebbie/passpie | import pytest
from passpie.importers.csv_importer import CSVImporter
def test_csv_importer_with_empty_reader_raises_value_error(mocker, mock_open):
mocker.patch('passpie.importers.csv_importer.open', mock_open(), create=True)
mocker.patch('passpie.importers.csv_importer.csv.reader', return_value=iter([]))
... | ValueError) | pytest.raises | variable | tests/test_importers/test_csv_importer.py | test_csv_importer_with_empty_reader_raises_value_error | 18 | null | |
marcwebbie/passpie | import tempfile
from passpie import completion
def test_script_returns_zsh_script_when_zsh_shell_name(mocker):
shell_name = 'zsh'
config_path = tempfile.gettempdir()
commands = ['add', 'remove', 'update', 'remove', 'search']
text = completion.script(shell_name=shell_name,
... | text | assert | variable | tests/test_completion.py | test_script_returns_zsh_script_when_zsh_shell_name | 15 | null | |
marcwebbie/passpie | import pytest
from passpie import clipboard
def test_clear_calls_command_to_clear_with_whitespace_char(mocker):
mocker.patch('passpie.clipboard.sys.stdout')
mocker.patch('passpie.clipboard.print', create=True)
mocker.patch('passpie.clipboard.time')
mock_process = mocker.patch('passpie.clipboard.proces... | 'some command') | assert_* | string_literal | tests/test_clipboard.py | test_clear_calls_command_to_clear_with_whitespace_char | 127 | null | |
marcwebbie/passpie | import re
import pytest
from passpie.utils import genpass, mkdir_open, ensure_dependencies, touch
def mock_open():
try:
from mock import mock_open as mopen
except:
from unittest.mock import mock_open as mopen
return mopen()
def test_genpass_raises_value_error_when_regex_pattern_error(mock... | ValueError) | pytest.raises | variable | tests/test_utils.py | test_genpass_raises_value_error_when_regex_pattern_error | 22 | null | |
sql-hkr/tiny8 | import time
from tiny8 import CPU, assemble
from tiny8.cli import KeyContext, ViewState, format_byte, run_command
class TestRunCommandNumeric:
def test_absolute_step_valid(self):
"""Test jumping to absolute step number."""
state = ViewState()
traces = [{"step": i} for i in range(10)]
... | 5 | assert | numeric_literal | tests/test_cli.py | test_absolute_step_valid | TestRunCommandNumeric | 52 | null |
sql-hkr/tiny8 | import pytest
class TestLDST:
def test_st_multiple_addresses(self, cpu_with_program, helper):
"""Test storing to multiple memory locations."""
cpu = cpu_with_program("""
ldi r20, 100
ldi r21, 11
st r20, r21
ldi r20, 101
ldi r... | 33) | assert_* | numeric_literal | tests/test_data_transfer.py | test_st_multiple_addresses | TestLDST | 108 | null |
sql-hkr/tiny8 | import time
from tiny8 import CPU, assemble
from tiny8.cli import KeyContext, ViewState, format_byte, run_command
class TestRunCommandRelative:
def test_relative_forward(self):
"""Test jumping forward relative steps."""
state = ViewState(step_idx=5)
traces = [{"step": i} for i in range(20... | 8 | assert | numeric_literal | tests/test_cli.py | test_relative_forward | TestRunCommandRelative | 100 | null |
sql-hkr/tiny8 | import io
from unittest.mock import Mock, patch
import pytest
from tiny8 import CPU, assemble
class TestCLIHelperFunctions:
def test_format_binary_value(self):
"""Test binary value formatting logic."""
test_values = [0b00000000, 0b11111111, 0b10101010]
for val in test_values:
... | 8 | assert | numeric_literal | tests/test_ui_components.py | test_format_binary_value | TestCLIHelperFunctions | 316 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestSUB:
def test_sub_basic(self, cpu_with_program, helper):
"""Test basic subtraction."""
cpu = cpu_with_program("""
ldi r0, 30
ldi r1, 10
sub r... | 20) | assert_* | numeric_literal | tests/test_arithmetic.py | test_sub_basic | TestSUB | 135 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestShiftRotateInstructions:
def test_rol_instruction(self):
"""Test rotate left through carry."""
cpu = CPU()
asm = assemble("""
ldi r16, 0x01
rol r16
""")
cpu.load_program(asm)
cpu.run()
assert... | 0x02 | assert | complex_expr | tests/test_cpu_core.py | test_rol_instruction | TestShiftRotateInstructions | 44 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestADC:
def test_adc_with_carry_set(self, cpu, helper):
"""Test ADC when carry is 1."""
asm = assemble("""
ldi r0, 10
ldi r1, 5
adc r0, r1
... | 16) | assert_* | numeric_literal | tests/test_arithmetic.py | test_adc_with_carry_set | TestADC | 107 | null |
sql-hkr/tiny8 | import time
from tiny8.utils import ProgressBar
class TestProgressBarFormatting:
def test_progress_bar_format_time_long(self):
"""Test time formatting for long durations."""
pbar = ProgressBar(total=100, disable=True)
assert pbar._format_time(3661) == | "01:01:01" | assert | string_literal | tests/test_utils.py | test_progress_bar_format_time_long | TestProgressBarFormatting | 112 | null |
sql-hkr/tiny8 | import time
from tiny8.utils import ProgressBar
class TestProgressBarEdgeCases:
def test_progress_bar_terminal_width_exception(self):
"""Test terminal width with exception handling."""
import shutil
original_func = shutil.get_terminal_size
def mock_exception(*args, **kwargs):
... | 80 | assert | numeric_literal | tests/test_utils.py | test_progress_bar_terminal_width_exception | TestProgressBarEdgeCases | 176 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUFlagOperations:
def test_mul_result_storage(self):
"""Test MUL stores result in rd:rd+1."""
cpu = CPU()
asm = assemble("""
ldi r16, 10
ldi r17, 20
mul r16, r17
""")
cpu.load_prog... | 200 | assert | numeric_literal | tests/test_cpu_edge_cases.py | test_mul_result_storage | TestCPUFlagOperations | 193 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestImmediateArithmetic:
def test_subi_instruction(self):
"""Test subtract immediate."""
cpu = CPU()
asm = assemble("""
ldi r16, 20
subi r16, 7
""")
cpu.load_program(asm)
cpu.run()
assert cpu.rea... | 13 | assert | numeric_literal | tests/test_cpu_core.py | test_subi_instruction | TestImmediateArithmetic | 150 | null |
sql-hkr/tiny8 | import time
from tiny8.utils import ProgressBar
class TestProgressBarFormatting:
def test_progress_bar_format_time_short(self):
"""Test time formatting for short durations."""
pbar = ProgressBar(total=100, disable=True)
assert pbar._format_time(65) == | "01:05" | assert | string_literal | tests/test_utils.py | test_progress_bar_format_time_short | TestProgressBarFormatting | 106 | null |
sql-hkr/tiny8 | import pytest
class TestMOV:
def test_mov_basic(self, cpu_with_program, helper):
"""Test copying value between registers."""
cpu = cpu_with_program("""
ldi r0, 123
mov r1, r0
""")
helper.assert_register(cpu, 1, | 123) | assert_* | numeric_literal | tests/test_data_transfer.py | test_mov_basic | TestMOV | 52 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUExceptions:
def test_jmp_with_invalid_label(self):
"""Test JMP with invalid label raises KeyError."""
cpu = CPU()
program = [("JMP", ("nonexistent_label",))]
cpu.load_program(program)
with pytest.raises( | KeyError, match="Label nonexistent_label not found") | pytest.raises | complex_expr | tests/test_cpu_edge_cases.py | test_jmp_with_invalid_label | TestCPUExceptions | 55 | null |
sql-hkr/tiny8 | import pytest
from tiny8.memory import Memory
class TestMemoryBasicOperations:
def test_load_rom_oversized(self):
"""Test loading oversized ROM."""
mem = Memory(rom_size=10)
program = list(range(20)) # Larger than rom_size
with pytest.raises( | ValueError, match="ROM image too large") | pytest.raises | complex_expr | tests/test_memory.py | test_load_rom_oversized | TestMemoryBasicOperations | 18 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUProgramLoading:
def test_load_program_with_asm_result(self):
"""Test loading program from AsmResult."""
cpu = CPU()
asm = assemble("""
ldi r16, 42
""")
cpu.load_program(asm)
cpu.run()
a... | 42 | assert | numeric_literal | tests/test_cpu_edge_cases.py | test_load_program_with_asm_result | TestCPUProgramLoading | 70 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestSBC:
def test_sbci_immediate(self, cpu, helper):
"""Test SBCI with immediate value."""
asm = assemble("""
ldi r16, 100
sbci r16, 10
""")
... | 89) | assert_* | numeric_literal | tests/test_arithmetic.py | test_sbci_immediate | TestSBC | 200 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble, assemble_file
class TestAssemblerBasics:
def test_assemble_file_missing(self):
"""Test assembling non-existent file."""
with pytest.raises( | FileNotFoundError) | pytest.raises | variable | tests/test_assembler.py | test_assemble_file_missing | TestAssemblerBasics | 16 | null |
sql-hkr/tiny8 | import pytest
class TestINOUT:
def test_out_multiple_ports(self, cpu_with_program, helper):
"""Test writing to multiple I/O ports."""
cpu = cpu_with_program("""
ldi r20, 10
out 0x10, r20
ldi r21, 20
out 0x20, r21
ldi r22, 30
o... | 10) | assert_* | numeric_literal | tests/test_data_transfer.py | test_out_multiple_ports | TestINOUT | 165 | null |
sql-hkr/tiny8 | import io
from unittest.mock import Mock, patch
import pytest
from tiny8 import CPU, assemble
class TestCLILogic:
def test_view_state_custom_values(self):
"""Test ViewState with custom values."""
from tiny8.cli import ViewState
state = ViewState(
step_idx=5,
scro... | 5 | assert | numeric_literal | tests/test_ui_components.py | test_view_state_custom_values | TestCLILogic | 48 | null |
sql-hkr/tiny8 | import pytest
from tiny8.memory import Memory
class TestMemorySnapshots:
def test_snapshot_ram(self):
"""Test RAM snapshot."""
mem = Memory(ram_size=10)
mem.write_ram(5, 42)
snapshot = mem.snapshot_ram()
assert snapshot[5] == 42
assert len(snapshot) == | 10 | assert | numeric_literal | tests/test_memory.py | test_snapshot_ram | TestMemorySnapshots | 86 | null |
sql-hkr/tiny8 | import pytest
class TestDataTransferIntegration:
def test_copy_memory_block(self, cpu_with_program, helper):
"""Test copying a block of memory."""
cpu = cpu_with_program("""
; Initialize source memory [100-102]
ldi r0, 100
ldi r1, 11
st r0, r1
... | dst_val | assert | variable | tests/test_data_transfer.py | test_copy_memory_block | TestDataTransferIntegration | 269 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble, assemble_file
class TestNumberParsing:
def test_parse_number_hex_dollar(self):
"""Test parsing hex immediate with $ prefix."""
from tiny8.assembler import _parse_number
assert _parse_number("$FF") == | 255 | assert | numeric_literal | tests/test_assembler.py | test_parse_number_hex_dollar | TestNumberParsing | 40 | null |
sql-hkr/tiny8 | import pytest
from tiny8.memory import Memory
class TestMemoryChangeTracking:
def test_load_rom_changes_tracking(self):
"""Test that ROM changes are tracked."""
mem = Memory(rom_size=10)
mem.load_rom([1, 2, 3])
assert len(mem.rom_changes) >= | 3 | assert | numeric_literal | tests/test_memory.py | test_load_rom_changes_tracking | TestMemoryChangeTracking | 74 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestDIV:
def test_div_basic(self, cpu_with_program, helper):
"""Test basic division."""
cpu = cpu_with_program("""
ldi r0, 42
ldi r1, 7
div r0, r... | 6) | assert_* | numeric_literal | tests/test_arithmetic.py | test_div_basic | TestDIV | 340 | null |
sql-hkr/tiny8 | import io
from unittest.mock import Mock, patch
import pytest
from tiny8 import CPU, assemble
class TestCLIStateManagement:
def test_state_mark_management(self):
"""Test mark storage and retrieval."""
from tiny8.cli import ViewState
state = ViewState()
state.marks["a"] = 10
... | 3 | assert | numeric_literal | tests/test_ui_components.py | test_state_mark_management | TestCLIStateManagement | 428 | null |
sql-hkr/tiny8 | import time
from tiny8.utils import ProgressBar
class TestProgressBarEdgeCases:
def test_progress_bar_prints_when_enabled(self):
"""Test that progress bar actually prints terminal width logic."""
pbar = ProgressBar(total=100, disable=False, mininterval=0)
pbar.update(10)
time.slee... | 20 | assert | numeric_literal | tests/test_utils.py | test_progress_bar_prints_when_enabled | TestProgressBarEdgeCases | 187 | null |
sql-hkr/tiny8 | import io
from unittest.mock import Mock, patch
import pytest
from tiny8 import CPU, assemble
class TestCLILogic:
def test_view_state_initialization(self):
"""Test ViewState dataclass initialization."""
from tiny8.cli import ViewState
state = ViewState()
assert state.step_idx =... | 0 | assert | numeric_literal | tests/test_ui_components.py | test_view_state_initialization | TestCLILogic | 26 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUFlagOperations:
def test_div_quotient_remainder(self):
"""Test DIV stores quotient and remainder correctly."""
cpu = CPU()
asm = assemble("""
ldi r16, 17
ldi r17, 5
div r16, r17
""")
... | 3 | assert | numeric_literal | tests/test_cpu_edge_cases.py | test_div_quotient_remainder | TestCPUFlagOperations | 207 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUInterrupts:
def test_trigger_interrupt(self):
"""Test interrupt triggering."""
cpu = CPU()
cpu.interrupts[0x10] = True
cpu.trigger_interrupt(0x10)
assert cpu.pc == | 0x0F | assert | complex_expr | tests/test_cpu_edge_cases.py | test_trigger_interrupt | TestCPUInterrupts | 145 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestShiftRotateInstructions:
def test_swap_instruction(self):
"""Test swap nibbles."""
cpu = CPU()
asm = assemble("""
ldi r16, 0xAB
swap r16
""")
cpu.load_program(asm)
cpu.run()
assert cpu.read_r... | 0xBA | assert | complex_expr | tests/test_cpu_core.py | test_swap_instruction | TestShiftRotateInstructions | 66 | null |
sql-hkr/tiny8 | import pytest
class TestINOUT:
def test_out_multiple_ports(self, cpu_with_program, helper):
"""Test writing to multiple I/O ports."""
cpu = cpu_with_program("""
ldi r20, 10
out 0x10, r20
ldi r21, 20
out 0x20, r21
ldi r22, 30
o... | 30) | assert_* | numeric_literal | tests/test_data_transfer.py | test_out_multiple_ports | TestINOUT | 167 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestRelativeJumpCall:
def test_rcall_instruction(self):
"""Test relative call."""
cpu = CPU()
asm = assemble("""
rcall func
ldi r16, 1
jmp done
func:
ldi r17, 2
ret
done:
... | 2 | assert | numeric_literal | tests/test_cpu_core.py | test_rcall_instruction | TestRelativeJumpCall | 341 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestADD:
def test_add_basic(self, cpu_with_program, helper):
"""Test basic addition without overflow."""
cpu = cpu_with_program("""
ldi r0, 10
ldi r1, 20
... | 30) | assert_* | numeric_literal | tests/test_arithmetic.py | test_add_basic | TestADD | 22 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble, assemble_file
def cpu():
"""Provide a fresh CPU instance for each test.
Returns:
CPU: A new, uninitialized CPU instance.
"""
return CPU()
def cpu_with_program(cpu):
"""Provide a helper function to load and optionally run a program.
Retu... | expected) | assert_* | variable | tests/conftest.py | assert_registers | CPUTestHelper | 105 | null |
sql-hkr/tiny8 | import pytest
from tiny8.cpu import SREG_C, SREG_Z
class TestLoops:
def test_nested_loops(self, cpu_with_program, helper):
"""Test nested loop structure."""
cpu = cpu_with_program("""
ldi r0, 0
ldi r1, 3
outer:
ldi r2, 2
inner:
inc r... | 6) | assert_* | numeric_literal | tests/test_control_flow.py | test_nested_loops | TestLoops | 375 | null |
sql-hkr/tiny8 | import pytest
class TestLDST:
def test_ld_uninitialized_memory(self, cpu_with_program, helper):
"""Test loading from uninitialized memory returns 0."""
cpu = cpu_with_program("""
ldi r16, 200
ld r17, r16
""")
helper.assert_register(cpu, 17, | 0) | assert_* | numeric_literal | tests/test_data_transfer.py | test_ld_uninitialized_memory | TestLDST | 116 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUProgramLoading:
def test_cpu_step_out_of_range(self):
"""Test CPU step when PC is out of range."""
cpu = CPU()
asm = assemble("ldi r16, 1")
cpu.load_program(asm)
cpu.run()
assert cpu.step() is | False | assert | bool_literal | tests/test_cpu_edge_cases.py | test_cpu_step_out_of_range | TestCPUProgramLoading | 86 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestSBC:
def test_sbc_with_borrow_set(self, cpu, helper):
"""Test SBC when carry/borrow is 1."""
asm = assemble("""
ldi r0, 20
ldi r1, 5
sbc r0, ... | 14) | assert_* | numeric_literal | tests/test_arithmetic.py | test_sbc_with_borrow_set | TestSBC | 189 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble
from tiny8.cpu import SREG_C, SREG_H, SREG_N, SREG_S, SREG_V, SREG_Z
class TestSUB:
def test_subi_immediate(self, cpu_with_program, helper):
"""Test SUBI with immediate value."""
cpu = cpu_with_program("""
ldi r16, 100
subi r16, 42
... | 58) | assert_* | numeric_literal | tests/test_arithmetic.py | test_subi_immediate | TestSUB | 154 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble, assemble_file
class TestNumberParsing:
def test_parse_number_binary(self):
"""Test parsing binary immediate."""
from tiny8.assembler import _parse_number
assert _parse_number("0b1111") == 15
assert _parse_number("0b10101010") == | 170 | assert | numeric_literal | tests/test_assembler.py | test_parse_number_binary | TestNumberParsing | 55 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble, assemble_file
def cpu():
"""Provide a fresh CPU instance for each test.
Returns:
CPU: A new, uninitialized CPU instance.
"""
return CPU()
def cpu_with_program(cpu):
"""Provide a helper function to load and optionally run a program.
Retu... | flag_names.get(flag)) | assert_* | func_call | tests/conftest.py | assert_flags | CPUTestHelper | 172 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestShiftRotateInstructions:
def test_ror_instruction(self):
"""Test rotate right through carry."""
cpu = CPU()
asm = assemble("""
ldi r16, 0x80
ror r16
""")
cpu.load_program(asm)
cpu.run()
asser... | 0x40 | assert | complex_expr | tests/test_cpu_core.py | test_ror_instruction | TestShiftRotateInstructions | 55 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble
class TestCPUProgramLoading:
def test_rcall_with_integer_offset(self):
"""Test RCALL with integer offset."""
cpu = CPU()
asm = assemble("""
ldi r16, 0
ldi r17, 0
rcall func
ldi r16, 1
... | 2 | assert | numeric_literal | tests/test_cpu_edge_cases.py | test_rcall_with_integer_offset | TestCPUProgramLoading | 134 | null |
sql-hkr/tiny8 | import time
from tiny8.utils import ProgressBar
class TestProgressBarFormatting:
def test_progress_bar_format_time_long(self):
"""Test time formatting for long durations."""
pbar = ProgressBar(total=100, disable=True)
assert pbar._format_time(3661) == "01:01:01"
assert pbar._form... | "02:00:00" | assert | string_literal | tests/test_utils.py | test_progress_bar_format_time_long | TestProgressBarFormatting | 113 | null |
sql-hkr/tiny8 | import time
from tiny8 import CPU, assemble
from tiny8.cli import KeyContext, ViewState, format_byte, run_command
class TestRunCommandRelative:
def test_relative_backward_out_of_bounds(self):
"""Test relative backward beyond start."""
state = ViewState(step_idx=3)
traces = [{"step": i} fo... | 3 | assert | numeric_literal | tests/test_cli.py | test_relative_backward_out_of_bounds | TestRunCommandRelative | 133 | null |
sql-hkr/tiny8 | import pytest
from tiny8.memory import Memory
class TestMemoryBasicOperations:
def test_write_ram_preserves_mask(self):
"""Test that write_ram preserves 8-bit mask."""
mem = Memory(ram_size=10)
mem.write_ram(5, 256) # Overflow
assert mem.read_ram(5) == | 0 | assert | numeric_literal | tests/test_memory.py | test_write_ram_preserves_mask | TestMemoryBasicOperations | 43 | null |
sql-hkr/tiny8 | import pytest
class TestINOUT:
def test_out_multiple_ports(self, cpu_with_program, helper):
"""Test writing to multiple I/O ports."""
cpu = cpu_with_program("""
ldi r20, 10
out 0x10, r20
ldi r21, 20
out 0x20, r21
ldi r22, 30
o... | 20) | assert_* | numeric_literal | tests/test_data_transfer.py | test_out_multiple_ports | TestINOUT | 166 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import assemble, assemble_file
class TestNumberParsing:
def test_parse_number_invalid(self):
"""Test parsing invalid immediate raises ValueError."""
from tiny8.assembler import _parse_number
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_assembler.py | test_parse_number_invalid | TestNumberParsing | 75 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestShiftRotateInstructions:
def test_lsl_instruction_with_carry(self):
"""Test logical shift left that sets carry."""
cpu = CPU()
asm = assemble("""
ldi r16, 0xFF
lsl r16
""")
cpu.load_program(asm)
cpu.r... | 0xFE | assert | complex_expr | tests/test_cpu_core.py | test_lsl_instruction_with_carry | TestShiftRotateInstructions | 33 | null |
sql-hkr/tiny8 | from tiny8 import CPU, assemble
class TestSkipInstructions:
def test_cpse_skip(self):
"""Test compare and skip if equal."""
cpu = CPU()
asm = assemble("""
ldi r16, 5
ldi r17, 5
ldi r18, 0
cpse r16, r17
ldi r18, 99
ldi ... | 0 | assert | numeric_literal | tests/test_cpu_core.py | test_cpse_skip | TestSkipInstructions | 190 | null |
sql-hkr/tiny8 | import time
from tiny8.utils import ProgressBar
class TestProgressBarFormatting:
def test_progress_bar_format_time_invalid(self):
"""Test time formatting with invalid values."""
pbar = ProgressBar(total=100, disable=True)
result = pbar._format_time(-1)
assert result == | "??:??" | assert | string_literal | tests/test_utils.py | test_progress_bar_format_time_invalid | TestProgressBarFormatting | 119 | null |
sql-hkr/tiny8 | import pytest
class TestLDST:
def test_st_multiple_addresses(self, cpu_with_program, helper):
"""Test storing to multiple memory locations."""
cpu = cpu_with_program("""
ldi r20, 100
ldi r21, 11
st r20, r21
ldi r20, 101
ldi r... | 22) | assert_* | numeric_literal | tests/test_data_transfer.py | test_st_multiple_addresses | TestLDST | 107 | null |
sql-hkr/tiny8 | import pytest
from tiny8.memory import Memory
class TestMemorySnapshots:
def test_snapshot_ram(self):
"""Test RAM snapshot."""
mem = Memory(ram_size=10)
mem.write_ram(5, 42)
snapshot = mem.snapshot_ram()
assert snapshot[5] == | 42 | assert | numeric_literal | tests/test_memory.py | test_snapshot_ram | TestMemorySnapshots | 85 | null |
sql-hkr/tiny8 | import pytest
from tiny8 import CPU, assemble, assemble_file
def cpu():
"""Provide a fresh CPU instance for each test.
Returns:
CPU: A new, uninitialized CPU instance.
"""
return CPU()
def cpu_with_program(cpu):
"""Provide a helper function to load and optionally run a program.
Retu... | expected | assert | variable | tests/conftest.py | assert_flag | CPUTestHelper | 139 | null |
sql-hkr/tiny8 | import pytest
from tiny8.memory import Memory
class TestMemoryBasicOperations:
def test_load_rom_preserves_mask(self):
"""Test that load_rom preserves 8-bit mask."""
mem = Memory(rom_size=10)
mem.load_rom([256, 257, 258])
assert mem.read_rom(0) == 0 # 256 & 0xFF
assert me... | 2 | assert | numeric_literal | tests/test_memory.py | test_load_rom_preserves_mask | TestMemoryBasicOperations | 51 | null |
sql-hkr/tiny8 | import pytest
from tiny8.cpu import SREG_C, SREG_Z
class TestJMP:
def test_jmp_backward_loop(self, cpu_with_program, helper):
"""Test backward jump creating a loop."""
cpu = cpu_with_program("""
ldi r0, 0
ldi r1, 5
loop:
inc r0
dec r1
... | 5) | assert_* | numeric_literal | tests/test_control_flow.py | test_jmp_backward_loop | TestJMP | 35 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.