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
PyMySQL/PyMySQL
from . import capabilities import pymysql from pymysql.tests import base import warnings warnings.filterwarnings("error") class test_MySQLdb(capabilities.DatabaseTest): db_module = pymysql connect_args = () connect_kwargs = base.PyMySQLTestCase.databases[0].copy() leak_test = False def quote_ide...
1)
self.assertEqual
numeric_literal
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py
test_stored_procedures
test_MySQLdb
70
null
PyMySQL/PyMySQL
import pytest import pymysql from pymysql.tests import base from pymysql.constants import CLIENT class TestNextset(base.PyMySQLTestCase): @pytest.mark.xfail def test_multi_cursor(self): con = self.connect(client_flag=CLIENT.MULTI_STATEMENTS) cur1 = con.cursor() cur2 = con.cursor() ...
cur1.nextset())
self.assertIsNone
func_call
pymysql/tests/test_nextset.py
test_multi_cursor
TestNextset
68
null
PyMySQL/PyMySQL
from pymysql.constants import ER from pymysql.tests import base import pymysql.cursors import pytest class CursorTest(base.PyMySQLTestCase): def setUp(self): super().setUp() conn = self.connect() self.safe_create_table( conn, "test", "create table test ...
ER.BAD_TABLE_ERROR)
self.assertEqual
complex_expr
pymysql/tests/test_cursor.py
test_warnings
CursorTest
215
null
PyMySQL/PyMySQL
from pymysql.constants import ER from pymysql.tests import base import pymysql.cursors import pytest class CursorTest(base.PyMySQLTestCase): def setUp(self): super().setUp() conn = self.connect() self.safe_create_table( conn, "test", "create table test ...
1)
self.assertEqual
numeric_literal
pymysql/tests/test_cursor.py
test_warnings
CursorTest
211
null
PyMySQL/PyMySQL
import datetime import ssl import pytest import time from unittest import mock import pymysql from pymysql.tests import base from pymysql.constants import CLIENT def escape_foo(x, d): return x.value class TestEscape(base.PyMySQLTestCase): def test_previous_cursor_not_closed(self): con = self.connect...
3)
self.assertEqual
numeric_literal
pymysql/tests/test_connection.py
test_previous_cursor_not_closed
TestEscape
889
null
PyMySQL/PyMySQL
import pytest from pymysql.tests import base import pymysql.cursors from pymysql.constants import CLIENT, ER class TestSSCursor(base.PyMySQLTestCase): def test_execution_time_limit(self): # this method is similarly implemented in test_cursor conn = self.connect() # table creation and fi...
None)
self.assertEqual
none_literal
pymysql/tests/test_SSCursor.py
test_execution_time_limit
TestSSCursor
178
null
PyMySQL/PyMySQL
__rcs_id__ = "$Id$" __version__ = "$Revision$"[11:-2] __author__ = "Stuart Bishop <zen@shangri-la.dropbear.id.au>" import time import unittest class DatabaseAPI20Test(unittest.TestCase): driver = None connect_args = () # List of arguments to pass to connect connect_kw_args = {} # Keyword arguments for ...
0)
self.assertEqual
numeric_literal
pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py
test_fetchmany
DatabaseAPI20Test
581
null
PyMySQL/PyMySQL
from . import dbapi20 import pymysql from pymysql.tests import base class test_MySQLdb(dbapi20.DatabaseAPI20Test): driver = pymysql connect_args = () connect_kw_args = base.PyMySQLTestCase.databases[0].copy() def test_fetchone(self): con = self._connect() try: cur = con.cur...
"cursor.fetchone retrieved incorrect data")
self.assertEqual
string_literal
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py
test_fetchone
test_MySQLdb
117
null
PyMySQL/PyMySQL
from time import time import unittest class DatabaseTest(unittest.TestCase): db_module = None connect_args = () connect_kwargs = dict(use_unicode=True, charset="utf8mb4", binary_prefix=True) create_table_extra = "ENGINE=INNODB CHARACTER SET UTF8MB4" rows = 10 debug = False def setUp(self):...
len(l) == 1)
self.assertTrue
func_call
pymysql/tests/thirdparty/test_MySQLdb/capabilities.py
test_transactions
DatabaseTest
141
null
PyMySQL/PyMySQL
import datetime import json import time import pytest import pymysql.cursors from pymysql.tests import base __all__ = ["TestConversion", "TestCursor", "TestBulkInserts"] class TestConversion(base.PyMySQLTestCase): def test_datatypes(self): """test every data type""" conn = self.connect() ...
r[-1])
self.assertEqual
complex_expr
pymysql/tests/test_basic.py
test_datatypes
TestConversion
66
null
PyMySQL/PyMySQL
from . import dbapi20 import pymysql from pymysql.tests import base class test_MySQLdb(dbapi20.DatabaseAPI20Test): driver = pymysql connect_args = () connect_kw_args = base.PyMySQLTestCase.databases[0].copy() def help_nextset_setUp(self, cur): """Should create a procedure called deleteme ...
"non-empty result set after other result sets")
self.assertEqual
string_literal
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py
test_nextset
test_MySQLdb
205
null
PyMySQL/PyMySQL
from . import dbapi20 import pymysql from pymysql.tests import base class test_MySQLdb(dbapi20.DatabaseAPI20Test): driver = pymysql connect_args = () connect_kw_args = base.PyMySQLTestCase.databases[0].copy() def test_fetchone(self): con = self._connect() try: cur = con.cur...
cur.rowcount in (-1, 1))
self.assertTrue
func_call
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py
test_fetchone
test_MySQLdb
123
null
PyMySQL/PyMySQL
from pymysql.tests import base import pymysql.cursors import datetime import warnings class TestDictCursor(base.PyMySQLTestCase): bob = {"name": "bob", "age": 21, "DOB": datetime.datetime(1990, 2, 6, 23, 4, 56)} jim = {"name": "jim", "age": 56, "DOB": datetime.datetime(1955, 5, 9, 13, 12, 45)} fred = {"na...
"fetchmany failed via DictCursor")
self.assertEqual
string_literal
pymysql/tests/test_DictCursor.py
test_DictCursor
TestDictCursor
82
null
PyMySQL/PyMySQL
from pymysql import cursors, OperationalError from pymysql.constants import ER from pymysql.tests import base import os __all__ = ["TestLoadLocal"] class TestLoadLocal(base.PyMySQLTestCase): def test_load_warnings(self): """Test load local infile produces the appropriate warnings""" conn = self....
c.warning_count)
self.assertEqual
complex_expr
pymysql/tests/test_load_local.py
test_load_warnings
TestLoadLocal
86
null
PyMySQL/PyMySQL
from pymysql.tests import base import pymysql.cursors import datetime import warnings class TestDictCursor(base.PyMySQLTestCase): bob = {"name": "bob", "age": 21, "DOB": datetime.datetime(1990, 2, 6, 23, 4, 56)} jim = {"name": "jim", "age": 56, "DOB": datetime.datetime(1955, 5, 9, 13, 12, 45)} fred = {"na...
"list failed via MyDictCursor")
self.assertEqual
string_literal
pymysql/tests/test_DictCursor.py
test_custom_dict
TestDictCursor
109
null
PyMySQL/PyMySQL
import unittest import pymysql _mysql = pymysql from pymysql.constants import FIELD_TYPE from pymysql.tests import base class CoreAPI(unittest.TestCase): def setUp(self): kwargs = base.PyMySQLTestCase.databases[0].copy() kwargs["read_default_file"] = "~/.my.cnf" self.conn = _mysql.connec...
isinstance(self.conn.get_server_info(), str))
self.assertTrue
func_call
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py
test_server_info
CoreAPI
93
null
PyMySQL/PyMySQL
from pymysql.constants import ER from pymysql.tests import base import pymysql.cursors import pytest class CursorTest(base.PyMySQLTestCase): def setUp(self): super().setUp() conn = self.connect() self.safe_create_table( conn, "test", "create table test ...
cursor)
self.assertEqual
variable
pymysql/tests/test_cursor.py
test_cursor_is_iterator
CursorTest
32
null
PyMySQL/PyMySQL
import pymysql.charset def test_utf8(): utf8mb3 = pymysql.charset.charset_by_name("utf8mb3") assert utf8mb3.name == "utf8mb3" assert utf8mb3.collation == "utf8mb3_general_ci" assert ( repr(utf8mb3) == "Charset(id=33, name='utf8mb3', collation='utf8mb3_general_ci')" ) # MySQL 8....
"utf8mb4"
assert
string_literal
pymysql/tests/test_charset.py
test_utf8
16
null
PyMySQL/PyMySQL
import pytest from pymysql.tests import base import pymysql.cursors from pymysql.constants import CLIENT, ER class TestSSCursor(base.PyMySQLTestCase): def test_warnings(self): con = self.connect() cur = con.cursor(pymysql.cursors.SSCursor) cur.execute("DROP TABLE IF EXISTS `no_exists_tabl...
w[2])
self.assertIn
complex_expr
pymysql/tests/test_SSCursor.py
test_warnings
TestSSCursor
210
null
PyMySQL/PyMySQL
import datetime import ssl import pytest import time from unittest import mock import pymysql from pymysql.tests import base from pymysql.constants import CLIENT def escape_foo(x, d): return x.value class TestEscape(base.PyMySQLTestCase): def test_escape_list_item(self): con = self.connect() ...
"(bar)")
self.assertEqual
string_literal
pymysql/tests/test_connection.py
test_escape_list_item
TestEscape
878
null
PyMySQL/PyMySQL
import pymysql.charset def test_utf8(): utf8mb3 = pymysql.charset.charset_by_name("utf8mb3") assert utf8mb3.name == "utf8mb3" assert utf8mb3.collation == "utf8mb3_general_ci" assert ( repr(utf8mb3) == "Charset(id=33, name='utf8mb3', collation='utf8mb3_general_ci')" ) # MySQL 8....
lowercase_utf8
assert
variable
pymysql/tests/test_charset.py
test_utf8
30
null
PyMySQL/PyMySQL
import unittest import pymysql _mysql = pymysql from pymysql.constants import FIELD_TYPE from pymysql.tests import base class TestDBAPISet(unittest.TestCase): def test_set_equality(self): self.assertTrue(
pymysql.STRING == pymysql.STRING)
self.assertTrue
complex_expr
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py
test_set_equality
TestDBAPISet
12
null
PyMySQL/PyMySQL
from pymysql.constants import ER from pymysql.tests import base import pymysql.cursors import pytest class CursorTest(base.PyMySQLTestCase): def setUp(self): super().setUp() conn = self.connect() self.safe_create_table( conn, "test", "create table test ...
0)
self.assertEqual
numeric_literal
pymysql/tests/test_cursor.py
test_warnings
CursorTest
222
null
PyMySQL/PyMySQL
from pymysql.tests import base import pymysql.cursors import datetime import warnings class TestDictCursor(base.PyMySQLTestCase): bob = {"name": "bob", "age": 21, "DOB": datetime.datetime(1990, 2, 6, 23, 4, 56)} jim = {"name": "jim", "age": 56, "DOB": datetime.datetime(1955, 5, 9, 13, 12, 45)} fred = {"na...
"DictCursor should be iterable")
self.assertEqual
string_literal
pymysql/tests/test_DictCursor.py
test_DictCursor
TestDictCursor
78
null
PyMySQL/PyMySQL
from pymysql.constants import ER from pymysql.tests import base import pymysql.cursors import pytest class CursorTest(base.PyMySQLTestCase): def setUp(self): super().setUp() conn = self.connect() self.safe_create_table( conn, "test", "create table test ...
ER.STATEMENT_TIMEOUT)
self.assertEqual
complex_expr
pymysql/tests/test_cursor.py
test_execution_time_limit
CursorTest
201
null
PyMySQL/PyMySQL
__rcs_id__ = "$Id$" __version__ = "$Revision$"[11:-2] __author__ = "Stuart Bishop <zen@shangri-la.dropbear.id.au>" import time import unittest class DatabaseAPI20Test(unittest.TestCase): driver = None connect_args = () # List of arguments to pass to connect connect_kw_args = {} # Keyword arguments for ...
2)
self.assertEqual
numeric_literal
pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py
test_fetchmany
DatabaseAPI20Test
579
null
PyMySQL/PyMySQL
from pymysql import cursors, OperationalError from pymysql.constants import ER from pymysql.tests import base import os __all__ = ["TestLoadLocal"] class TestLoadLocal(base.PyMySQLTestCase): def test_load_warnings(self): """Test load local infile produces the appropriate warnings""" conn = self....
w[2].lower())
self.assertIn
func_call
pymysql/tests/test_load_local.py
test_load_warnings
TestLoadLocal
92
null
PyMySQL/PyMySQL
from . import capabilities import pymysql from pymysql.tests import base import warnings warnings.filterwarnings("error") class test_MySQLdb(capabilities.DatabaseTest): db_module = pymysql connect_args = () connect_kwargs = base.PyMySQLTestCase.databases[0].copy() leak_test = False def quote_ide...
3)
self.assertEqual
numeric_literal
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_capabilities.py
test_stored_procedures
test_MySQLdb
71
null
PyMySQL/PyMySQL
import datetime import time import warnings import pytest import pymysql from pymysql.tests import base __all__ = ["TestOldIssues", "TestNewIssues", "TestGitHubIssues"] class TestGitHubIssues(base.PyMySQLTestCase): def test_issue_321(self): """Test iterable as query argument.""" conn = pymysql....
1)
self.assertEqual
numeric_literal
pymysql/tests/test_issues.py
test_issue_321
TestGitHubIssues
413
null
PyMySQL/PyMySQL
import datetime import json import time import pytest import pymysql.cursors from pymysql.tests import base __all__ = ["TestConversion", "TestCursor", "TestBulkInserts"] class TestCursor(base.PyMySQLTestCase): def test_json(self): args = self.databases[0].copy() args["charset"] = "utf8mb4" ...
json.loads(json_str))
self.assertEqual
func_call
pymysql/tests/test_basic.py
test_json
TestCursor
324
null
PyMySQL/PyMySQL
import pytest from pymysql.tests import base import pymysql.cursors from pymysql.constants import CLIENT, ER class TestSSCursor(base.PyMySQLTestCase): def test_SSCursor(self): affected_rows = 18446744073709551615 conn = self.connect(client_flag=CLIENT.MULTI_STATEMENTS) data = [ ...
cursor.nextset())
self.assertTrue
func_call
pymysql/tests/test_SSCursor.py
test_SSCursor
TestSSCursor
106
null
PyMySQL/PyMySQL
import datetime import time import warnings import pytest import pymysql from pymysql.tests import base __all__ = ["TestOldIssues", "TestNewIssues", "TestGitHubIssues"] class TestNewIssues(base.PyMySQLTestCase): def test_issue_34(self): try: pymysql.connect(host="localhost", port=1237, user=...
e.args[0])
self.assertEqual
complex_expr
pymysql/tests/test_issues.py
test_issue_34
TestNewIssues
183
null
PyMySQL/PyMySQL
import datetime import ssl import pytest import time from unittest import mock import pymysql from pymysql.tests import base from pymysql.constants import CLIENT def escape_foo(x, d): return x.value class TestEscape(base.PyMySQLTestCase): def test_socket_closed_on_exception_in_connect(self): con = s...
None
assert
none_literal
pymysql/tests/test_connection.py
test_socket_closed_on_exception_in_connect
TestEscape
930
null
PyMySQL/PyMySQL
import datetime import time import warnings import pytest import pymysql from pymysql.tests import base __all__ = ["TestOldIssues", "TestNewIssues", "TestGitHubIssues"] class TestGitHubIssues(base.PyMySQLTestCase): def test_issue_364(self): """Test mixed unicode/binary arguments in executemany.""" ...
tuple(values))
self.assertEqual
func_call
pymysql/tests/test_issues.py
test_issue_364
TestGitHubIssues
439
null
PyMySQL/PyMySQL
import unittest import pymysql _mysql = pymysql from pymysql.constants import FIELD_TYPE from pymysql.tests import base class CoreModule(unittest.TestCase): def test_version(self): """Version information sanity.""" self.assertTrue(
isinstance(_mysql.__version__, str))
self.assertTrue
func_call
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_nonstandard.py
test_version
CoreModule
33
null
PyMySQL/PyMySQL
import pymysql.charset def test_utf8(): utf8mb3 = pymysql.charset.charset_by_name("utf8mb3") assert utf8mb3.name ==
"utf8mb3"
assert
string_literal
pymysql/tests/test_charset.py
test_utf8
6
null
PyMySQL/PyMySQL
import datetime import time import warnings import pytest import pymysql from pymysql.tests import base __all__ = ["TestOldIssues", "TestNewIssues", "TestGitHubIssues"] class TestNewIssues(base.PyMySQLTestCase): def test_issue_33(self): conn = pymysql.connect(charset="utf8", **self.databases[0]) ...
c.fetchone()[0])
self.assertEqual
func_call
pymysql/tests/test_issues.py
test_issue_33
TestNewIssues
195
null
PyMySQL/PyMySQL
import datetime import json import time import pytest import pymysql.cursors from pymysql.tests import base __all__ = ["TestConversion", "TestCursor", "TestBulkInserts"] class TestConversion(base.PyMySQLTestCase): def test_datatypes(self): """test every data type""" conn = self.connect() ...
r[0])
self.assertEqual
complex_expr
pymysql/tests/test_basic.py
test_datatypes
TestConversion
61
null
PyMySQL/PyMySQL
from time import time import unittest class DatabaseTest(unittest.TestCase): db_module = None connect_args = () connect_kwargs = dict(use_unicode=True, charset="utf8mb4", binary_prefix=True) create_table_extra = "ENGINE=INNODB CHARACTER SET UTF8MB4" rows = 10 debug = False def setUp(self):...
generator(i, j))
self.assertEqual
func_call
pymysql/tests/thirdparty/test_MySQLdb/capabilities.py
check_data_integrity
DatabaseTest
102
null
PyMySQL/PyMySQL
__rcs_id__ = "$Id$" __version__ = "$Revision$"[11:-2] __author__ = "Stuart Bishop <zen@shangri-la.dropbear.id.au>" import time import unittest class DatabaseAPI20Test(unittest.TestCase): driver = None connect_args = () # List of arguments to pass to connect connect_kw_args = {} # Keyword arguments for ...
len(self.samples)
assert
func_call
pymysql/tests/thirdparty/test_MySQLdb/dbapi20.py
test_nextset
DatabaseAPI20Test
748
null
PyMySQL/PyMySQL
from pymysql.tests import base import pymysql.cursors import datetime import warnings class TestDictCursor(base.PyMySQLTestCase): bob = {"name": "bob", "age": 21, "DOB": datetime.datetime(1990, 2, 6, 23, 4, 56)} jim = {"name": "jim", "age": 56, "DOB": datetime.datetime(1955, 5, 9, 13, 12, 45)} fred = {"na...
"fetchone() returns MyDictCursor")
self.assertEqual
string_literal
pymysql/tests/test_DictCursor.py
test_custom_dict
TestDictCursor
100
null
PyMySQL/PyMySQL
import datetime import time import warnings import pytest import pymysql from pymysql.tests import base __all__ = ["TestOldIssues", "TestNewIssues", "TestGitHubIssues"] class TestNewIssues(base.PyMySQLTestCase): def test_issue_36(self): # connection 0 is super user, connection 1 isn't conn = se...
kill_id in ids)
self.assertFalse
complex_expr
pymysql/tests/test_issues.py
test_issue_36
TestNewIssues
240
null
PyMySQL/PyMySQL
import datetime import ssl import pytest import time from unittest import mock import pymysql from pymysql.tests import base from pymysql.constants import CLIENT class TestConnection(base.PyMySQLTestCase): def test_autocommit(self): con = self.connect() self.assertFalse(con.get_autocommit()) ...
0)
self.assertEqual
numeric_literal
pymysql/tests/test_connection.py
test_autocommit
TestConnection
483
null
PyMySQL/PyMySQL
from . import dbapi20 import pymysql from pymysql.tests import base class test_MySQLdb(dbapi20.DatabaseAPI20Test): driver = pymysql connect_args = () connect_kw_args = base.PyMySQLTestCase.databases[0].copy() def test_fetchall(self): con = self._connect() try: cur = con.cur...
cur.rowcount in (-1, 0))
self.assertTrue
func_call
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py
test_fetchall
test_MySQLdb
72
null
PyMySQL/PyMySQL
from pymysql.tests import base import pymysql.cursors import datetime import warnings class TestDictCursor(base.PyMySQLTestCase): bob = {"name": "bob", "age": 21, "DOB": datetime.datetime(1990, 2, 6, 23, 4, 56)} jim = {"name": "jim", "age": 56, "DOB": datetime.datetime(1955, 5, 9, 13, 12, 45)} fred = {"na...
"fetchall failed via DictCursor")
self.assertEqual
string_literal
pymysql/tests/test_DictCursor.py
test_DictCursor
TestDictCursor
74
null
PyMySQL/PyMySQL
import datetime import ssl import pytest import time from unittest import mock import pymysql from pymysql.tests import base from pymysql.constants import CLIENT class TestConnection(base.PyMySQLTestCase): def test_ssl_connect(self): dummy_ssl_context = mock.Mock(options=0, verify_flags=0) with m...
"cert")
assert_*
string_literal
pymysql/tests/test_connection.py
test_ssl_connect
TestConnection
578
null
PyMySQL/PyMySQL
from . import dbapi20 import pymysql from pymysql.tests import base class test_MySQLdb(dbapi20.DatabaseAPI20Test): driver = pymysql connect_args = () connect_kw_args = base.PyMySQLTestCase.databases[0].copy() def test_fetchall(self): con = self._connect() try: cur = con.cur...
"cursor.fetchall retrieved incorrect rows")
self.assertEqual
string_literal
pymysql/tests/thirdparty/test_MySQLdb/test_MySQLdb_dbapi20.py
test_fetchall
test_MySQLdb
57
null
PyMySQL/PyMySQL
import pytest import pymysql from pymysql.tests import base from pymysql.constants import CLIENT class TestNextset(base.PyMySQLTestCase): def test_nextset(self): con = self.connect( init_command='SELECT "bar"; SELECT "baz"', client_flag=CLIENT.MULTI_STATEMENTS, ) cu...
cur.nextset())
self.assertIsNone
func_call
pymysql/tests/test_nextset.py
test_nextset
TestNextset
22
null
PyMySQL/PyMySQL
from pymysql import cursors, OperationalError from pymysql.constants import ER from pymysql.tests import base import os __all__ = ["TestLoadLocal"] class TestLoadLocal(base.PyMySQLTestCase): def test_load_file(self): """Test load local infile with a valid file""" conn = self.connect() c ...
c.fetchone()[0])
self.assertEqual
func_call
pymysql/tests/test_load_local.py
test_load_file
TestLoadLocal
43
null
PyMySQL/PyMySQL
import pytest from pymysql.tests import base import pymysql.cursors from pymysql.constants import CLIENT, ER class TestSSCursor(base.PyMySQLTestCase): def test_SSCursor(self): affected_rows = 18446744073709551615 conn = self.connect(client_flag=CLIENT.MULTI_STATEMENTS) data = [ ...
[(3,)])
self.assertListEqual
collection
pymysql/tests/test_SSCursor.py
test_SSCursor
TestSSCursor
109
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_one_byte_message(): """Messages that are one byte long should not wait for data bytes.""" messages = parse_all([0xf6]) # Tune request. assert len(messages) == 1 ...
'tune_request'
assert
string_literal
tests/test_parser.py
test_one_byte_message
93
null
mido/mido
from mido.tokenizer import Tokenizer def tokenize(midi_bytes): return list(Tokenizer(midi_bytes)) def test_channel_message(): assert tokenize([0x90, 1, 2]) ==
[[0x90, 1, 2]]
assert
collection
tests/test_tokenizer.py
test_channel_message
13
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_encode_and_parse_all(): """Encode and then parse all message types. This checks mostly for errors in the parser. """ parser = Parser() for type_ in sorted(s...
msg
assert
variable
tests/test_parser.py
test_encode_and_parse_all
127
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_one_byte_message(): """Messages that are one byte long should not wait for data bytes.""" messages = parse_all([0xf6]) # Tune request. assert len(messages) ==
1
assert
numeric_literal
tests/test_parser.py
test_one_byte_message
92
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_encode_pitchwheel(): assert 'E0 00 00' == Message('pitchwheel', pitch=MIN_PITCHWHEEL).hex() assert 'E0 00 40' ==
Message('pitchwheel', pitch=0).hex()
assert
func_call
tests/messages/test_messages.py
test_encode_pitchwheel
25
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
2
assert
numeric_literal
tests/midifiles/test_midifiles.py
test_two_tracks
66
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_decode_pitchwheel(): assert Message.from_hex('E0 00 00').pitch ==
MIN_PITCHWHEEL
assert
variable
tests/messages/test_messages.py
test_decode_pitchwheel
30
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
[ MetaMessage('sequence_number', number=0), MetaMessage('midi_port', port=0), MetaMessage('sequence_number', number=1), MetaMessage('midi_port', port=1), MetaMessage('end_of_track'), ]
assert
collection
tests/midifiles/test_midifiles.py
test_meta_messages_with_length_0
163
null
mido/mido
import itertools import time import mido from mido.messages import Message from mido.midifiles.meta import MetaMessage, UnknownMetaMessage from mido.midifiles.tracks import MidiTrack zip = getattr(itertools, 'izip', zip) def test_merge_large_midifile(): mid = mido.MidiFile() for k in range(5): t = mi...
5.0
assert
numeric_literal
tests/midifiles/test_tracks.py
test_merge_large_midifile
74
null
mido/mido
from pytest import raises from mido.messages import Message from mido.syx import read_syx_file, write_syx_file def test_read(tmpdir): path = tmpdir.join("test.syx").strpath msg = Message('sysex', data=(1, 2, 3)) with open(path, 'wb') as outfile: outfile.write(msg.bin()) assert read_syx_file...
[msg]
assert
collection
tests/test_syx.py
test_read
18
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
127
assert
numeric_literal
tests/midifiles/test_midifiles.py
test_invalid_data_byte_with_clipping_high
100
null
mido/mido
from mido.midifiles.units import bpm2tempo, second2tick, tempo2bpm, tick2second def test_second2tick(): # default tempo (500000 ms per quarter note) assert second2tick(0.001, ticks_per_beat=100, tempo=500000) ==
0
assert
numeric_literal
tests/midifiles/test_units.py
test_second2tick
66
null
mido/mido
import pytest from mido.midifiles.meta import ( KeySignatureError, MetaMessage, MetaSpec_key_signature, UnknownMetaMessage, ) def test_meta_from_bytes_text(): test_bytes = [ 0xFF, # Meta event 0x01, # Event Type: Text 0x04, # Length ord('T'), ord('E'), ord('S'), ...
'text'
assert
string_literal
tests/midifiles/test_meta.py
test_meta_from_bytes_text
96
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_encode_and_parse(): """Encode a message and then parse it. Should return the same message. """ note_on = Message('note_on') assert note_on ==
parse(note_on.bytes())
assert
func_call
tests/test_parser.py
test_encode_and_parse
36
null
mido/mido
from pytest import raises from mido.messages import Message from mido.syx import read_syx_file, write_syx_file def test_handle_any_whitespace(tmpdir): path = tmpdir.join("test.syx").strpath with open(path, 'w') as outfile: outfile.write('F0 01 02 \t F7\n F0 03 04 F7\n') assert read_syx_file(pa...
[Message('sysex', data=[1, 2]), Message('sysex', data=[3, 4])]
assert
collection
tests/test_syx.py
test_handle_any_whitespace
36
null
mido/mido
import pytest from mido.midifiles.meta import ( KeySignatureError, MetaMessage, MetaSpec_key_signature, UnknownMetaMessage, ) def test_meta_message_repr(): msg = MetaMessage('end_of_track', time=10) msg_eval = eval(repr(msg)) # noqa: S307 assert msg ==
msg_eval
assert
variable
tests/midifiles/test_meta.py
test_meta_message_repr
48
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
[]
assert
collection
tests/midifiles/test_midifiles.py
test_no_tracks
34
null
mido/mido
from mido.messages.decode import decode_message from mido.messages.encode import encode_message from mido.messages.specs import SPEC_BY_STATUS def test_encode_decode_all(): """Encode and then decode all messages on all channels. Each data byte is different so that the test will fail if the bytes are swapp...
msg_bytes
assert
variable
tests/messages/test_encode.py
test_encode_decode_all
25
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_decode_songpos(): assert Message.from_hex('F2 00 00').pos ==
MIN_SONGPOS
assert
variable
tests/messages/test_messages.py
test_decode_songpos
41
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_repr(): msg = Message('note_on', channel=1, note=2, time=3) msg_eval = eval(repr(msg)) # noqa: S307 assert msg ==
msg_eval
assert
variable
tests/messages/test_messages.py
test_repr
121
null
mido/mido
import pytest from mido.sockets import parse_address class TestParseAddress: def test_too_many_colons_raises_value_error(self): with pytest.raises(
ValueError)
pytest.raises
variable
tests/test_sockets.py
test_too_many_colons_raises_value_error
TestParseAddress
19
null
mido/mido
from pytest import raises from mido.messages import Message from mido.syx import read_syx_file, write_syx_file def test_write(tmpdir): # p = tmpdir.mkdir("sub").join("hello.txt") path = tmpdir.join("test.syx").strpath msg = Message('sysex', data=(1, 2, 3)) write_syx_file(path, [msg]) with open(pa...
msg.hex()
assert
func_call
tests/test_syx.py
test_write
51
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_encode_songpos(): assert 'F2 00 00' ==
Message('songpos', pos=MIN_SONGPOS).hex()
assert
func_call
tests/messages/test_messages.py
test_encode_songpos
36
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_realtime_inside_sysex(): """Realtime message inside sysex should be delivered first.""" messages = parse_all([0xf0, 0, 0xfb, 0, 0xf7]) assert len(messages) == 2 a...
'sysex'
assert
string_literal
tests/test_parser.py
test_realtime_inside_sysex
107
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_encode_songpos(): assert 'F2 00 00' == Message('songpos', pos=MIN_SONGPOS).hex() assert 'F2 7F 7F' ==
Message('songpos', pos=MAX_SONGPOS).hex()
assert
func_call
tests/messages/test_messages.py
test_encode_songpos
37
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_decode_pitchwheel(): assert Message.from_hex('E0 00 00').pitch == MIN_PITCHWHEEL assert Message.from_hex('E0 00 40').pitch == 0 ...
MAX_PITCHWHEEL
assert
variable
tests/messages/test_messages.py
test_decode_pitchwheel
32
null
mido/mido
from pytest import raises from mido.messages import Message def test_decode_sysex(): assert Message.from_str('sysex data=(1,2,3)').data ==
(1, 2, 3)
assert
collection
tests/messages/test_strings.py
test_decode_sysex
11
null
mido/mido
from mido.midifiles.units import bpm2tempo, second2tick, tempo2bpm, tick2second def test_second2tick(): # default tempo (500000 ms per quarter note) assert second2tick(0.001, ticks_per_beat=100, tempo=500000) == 0 assert second2tick(0.004, ticks_per_beat=100, tempo=500000) == 1 assert second2tick(0.005...
2
assert
numeric_literal
tests/midifiles/test_units.py
test_second2tick
69
null
mido/mido
from mido.tokenizer import Tokenizer def tokenize(midi_bytes): return list(Tokenizer(midi_bytes)) def test_realtime_inside_sysex(): """Realtime messages are allowed inside sysex. The sysex messages should be delivered first. This is the only case where a message is allowed inside another message. ...
[[0xf8], [0xf0, 1, 2, 0xf7]]
assert
collection
tests/test_tokenizer.py
test_realtime_inside_sysex
44
null
mido/mido
from mido.midifiles.units import bpm2tempo, second2tick, tempo2bpm, tick2second def test_tempo2bpm(): # default tempo (500000 ms per quarter note) assert tempo2bpm(500000) ==
120
assert
numeric_literal
tests/midifiles/test_units.py
test_tempo2bpm
10
null
mido/mido
import pytest from mido.midifiles.meta import ( KeySignatureError, MetaMessage, MetaSpec_key_signature, UnknownMetaMessage, ) class TestKeySignature: @pytest.mark.parametrize('input_bytes,expect_sig', [([0, 0], 'C'), ([0, 1], 'Am'), ...
expect_sig
assert
variable
tests/midifiles/test_meta.py
test_key_signature
TestKeySignature
42
null
mido/mido
import pytest from mido.midifiles.meta import ( KeySignatureError, MetaMessage, MetaSpec_key_signature, UnknownMetaMessage, ) def test_meta_from_bytes_text(): test_bytes = [ 0xFF, # Meta event 0x01, # Event Type: Text 0x04, # Length ord('T'), ord('E'), ord('S'), ...
'TEST'
assert
string_literal
tests/midifiles/test_meta.py
test_meta_from_bytes_text
97
null
mido/mido
from mido.tokenizer import Tokenizer def tokenize(midi_bytes): return list(Tokenizer(midi_bytes)) def test_empty_sysex(): assert tokenize([0xf0, 0xf7]) ==
[[0xf0, 0xf7]]
assert
collection
tests/test_tokenizer.py
test_empty_sysex
21
null
mido/mido
from pytest import raises from mido.messages import Message def test_encode_sysex(): assert str(Message('sysex', data=())) == 'sysex data=() time=0' # This should not have an extra comma. assert str(Message('sysex', data=(1,))) ==
'sysex data=(1) time=0'
assert
string_literal
tests/messages/test_strings.py
test_encode_sysex
22
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_parse_stray_data(): """The parser should ignore stray data bytes.""" assert parse_all(b'\x20\x30') ==
[]
assert
collection
tests/test_parser.py
test_parse_stray_data
22
null
mido/mido
from pytest import raises from mido.messages import Message from mido.syx import read_syx_file, write_syx_file def test_write(tmpdir): # p = tmpdir.mkdir("sub").join("hello.txt") path = tmpdir.join("test.syx").strpath msg = Message('sysex', data=(1, 2, 3)) write_syx_file(path, [msg]) with open(pa...
msg.bin()
assert
func_call
tests/test_syx.py
test_write
47
null
mido/mido
from mido.midifiles.units import bpm2tempo, second2tick, tempo2bpm, tick2second def test_tick2second(): # default tempo (500000 ms per quarter note) assert tick2second(1, ticks_per_beat=100, tempo=500000) == 0.005 assert tick2second(2, ticks_per_beat=100, tempo=100000) ==
0.002
assert
numeric_literal
tests/midifiles/test_units.py
test_tick2second
61
null
mido/mido
from mido.tokenizer import Tokenizer def tokenize(midi_bytes): return list(Tokenizer(midi_bytes)) def test_stray_data_bytes(): """Data bytes outside messages should be ignored.""" assert
[[0x90, 2, 3], [0xf8]]
assert
collection
tests/test_tokenizer.py
test_stray_data_bytes
60
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
m2
assert
variable
tests/midifiles/test_midifiles.py
test_midifile_repr
187
null
mido/mido
from mido.frozen import ( FrozenMessage, FrozenMetaMessage, FrozenUnknownMetaMessage, freeze_message, is_frozen, thaw_message, ) from mido.messages import Message from mido.midifiles.meta import UnknownMetaMessage def test_frozen_repr(): msg = FrozenMessage('note_on', channel=1, note=2, tim...
msg_eval
assert
variable
tests/test_frozen.py
test_frozen_repr
46
null
mido/mido
from mido.tokenizer import Tokenizer def tokenize(midi_bytes): return list(Tokenizer(midi_bytes)) def test_realtime_inside_sysex(): """Realtime messages are allowed inside sysex. The sysex messages should be delivered first. This is the only case where a message is allowed inside another message. ...
[[0xf8], [0xf0, 0xf7]]
assert
collection
tests/test_tokenizer.py
test_realtime_inside_sysex
45
null
mido/mido
from mido.midifiles.units import bpm2tempo, second2tick, tempo2bpm, tick2second def test_second2tick(): # default tempo (500000 ms per quarter note) assert second2tick(0.001, ticks_per_beat=100, tempo=500000) == 0 assert second2tick(0.004, ticks_per_beat=100, tempo=500000) ==
1
assert
numeric_literal
tests/midifiles/test_units.py
test_second2tick
67
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_from_dict_default_values(): msg = Message('note_on', channel=0, note=0, time=0) data = {'type': 'note_on'} assert Message.from_...
msg
assert
variable
tests/messages/test_messages.py
test_from_dict_default_values
103
null
mido/mido
from mido.backends.rtmidi_utils import expand_alsa_port_name def test_expand_alsa_port_name(): port_names = sorted(['A:port 128:0', 'B:port 129:0', 'B:port 129:0', 'Z:port 130:0']) def expand(name): return expand_alsa_port_name...
'B:port 129:0'
assert
string_literal
tests/backends/test_rtmidi.py
test_expand_alsa_port_name
21
null
mido/mido
from pytest import raises from mido.messages.messages import Message, SysexData from mido.messages.specs import MAX_PITCHWHEEL, MAX_SONGPOS, MIN_PITCHWHEEL, MIN_SONGPOS def test_compare_with_nonmessage(): with raises(TypeError): assert Message('clock') ==
'not a message'
assert
string_literal
tests/messages/test_messages.py
test_compare_with_nonmessage
97
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
MetaMessage('end_of_track')
assert
func_call
tests/midifiles/test_midifiles.py
test_meta_messages
115
null
mido/mido
import random from pytest import raises from mido.messages import Message, specs from mido.parser import Parser, parse, parse_all def test_parse(): """Parse a note_on msg and compare it to one created with Message().""" parsed = parse(b'\x90\x4c\x20') other = Message('note_on', channel=0, note=0x4c, velo...
other
assert
variable
tests/test_parser.py
test_parse
17
null
mido/mido
import io from pytest import raises from mido.messages import Message from mido.midifiles.meta import KeySignatureError, MetaMessage from mido.midifiles.midifiles import MidiFile, MidiTrack HEADER_ONE_TRACK = """ 4d 54 68 64 # MThd 00 00 00 06 # Chunk size 00 01 # Type 1 00 01 # 1 track 00 78 ...
[Message('note_on', note=64, velocity=64, time=32)]
assert
collection
tests/midifiles/test_midifiles.py
test_single_message
44
null
mido/mido
import pytest from mido.sockets import parse_address class TestParseAddress: @pytest.mark.parametrize('input_str, expected', [(':8080', ('', 8080)), ('localhost:8080', ('localhost', 8080)) ]) def test_parse_address_normal...
expected
assert
variable
tests/test_sockets.py
test_parse_address_normal
TestParseAddress
16
null
mido/mido
from pytest import raises from mido.messages import Message def test_encode_sysex(): assert str(Message('sysex', data=())) ==
'sysex data=() time=0'
assert
string_literal
tests/messages/test_strings.py
test_encode_sysex
20
null