Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI: update python versions #4775

Merged
merged 6 commits into from
May 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11-dev']
python-version: ['3.7', '3.8', '3.9', '3.x', '3.12-dev']

env:
PY_COLORS: 1
Expand Down Expand Up @@ -45,17 +45,17 @@ jobs:
sudo apt install ffmpeg # For replaygain
- name: Test older Python versions with tox
if: matrix.python-version != '3.10' && matrix.python-version != '3.11-dev'
if: matrix.python-version != '3.x' && matrix.python-version != '3.12-dev'
run: |
tox -e py-test
- name: Test latest Python version with tox and get coverage
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.x'
run: |
tox -vv -e py-cov
- name: Test latest Python version with tox and mypy
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.x'
# continue-on-error is not ideal since it doesn't give a visible
# warning, but there doesn't seem to be anything better:
# https://github.com/actions/toolkit/issues/399
Expand All @@ -64,7 +64,7 @@ jobs:
tox -vv -e py-mypy
- name: Test nightly Python version with tox
if: matrix.python-version == '3.11-dev'
if: matrix.python-version == '3.12-dev'
# continue-on-error is not ideal since it doesn't give a visible
# warning, but there doesn't seem to be anything better:
# https://github.com/actions/toolkit/issues/399
Expand All @@ -73,7 +73,7 @@ jobs:
tox -e py-test
- name: Upload code coverage
if: matrix.python-version == '3.10'
if: matrix.python-version == '3.x'
run: |
pip install codecov || true
codecov || true
Expand All @@ -87,10 +87,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.10
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: '3.10'
python-version: '3.x'

- name: Install base dependencies
run: |
Expand All @@ -109,10 +109,10 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.10
- name: Set up Python 3.x
uses: actions/setup-python@v2
with:
python-version: '3.10'
python-version: '3.x'

- name: Install base dependencies
run: |
Expand Down
15 changes: 13 additions & 2 deletions beets/dbcore/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,11 @@ class Database:
"""

def __init__(self, path, timeout=5.0):
if sqlite3.threadsafety == 0:
raise RuntimeError(
"sqlite3 must be compiled with multi-threading support"
)

self.path = path
self.timeout = timeout

Expand Down Expand Up @@ -975,7 +980,11 @@ def _create_connection(self):
# bytestring paths here on Python 3, so we need to
# provide a `str` using `py3_path`.
conn = sqlite3.connect(
py3_path(self.path), timeout=self.timeout
py3_path(self.path),
timeout=self.timeout,
# We have our own same-thread checks in _connection(), but need to
# call conn.close() in _close()
check_same_thread=False,
)
self.add_functions(conn)

Expand Down Expand Up @@ -1005,7 +1014,9 @@ def _close(self):
unusable; new connections can still be opened on demand.
"""
with self._shared_map_lock:
self._connections.clear()
while self._connections:
_thread_id, conn = self._connections.popitem()
conn.close()

@contextlib.contextmanager
def _tx_stack(self):
Expand Down
9 changes: 8 additions & 1 deletion test/test_dbcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def setUpClass(cls):
'insert into test (field_one, field_two) values (4, 2)'
)
old_lib._connection().commit()
old_lib._connection().close()
del old_lib

@classmethod
Expand All @@ -190,33 +191,39 @@ def test_open_with_same_fields_leaves_untouched(self):
c = new_lib._connection().cursor()
c.execute("select * from test")
row = c.fetchone()
c.connection.close()
self.assertEqual(len(row.keys()), len(ModelFixture2._fields))

def test_open_with_new_field_adds_column(self):
new_lib = DatabaseFixture3(self.libfile)
c = new_lib._connection().cursor()
c.execute("select * from test")
row = c.fetchone()
c.connection.close()
self.assertEqual(len(row.keys()), len(ModelFixture3._fields))

def test_open_with_fewer_fields_leaves_untouched(self):
new_lib = DatabaseFixture1(self.libfile)
c = new_lib._connection().cursor()
c.execute("select * from test")
row = c.fetchone()
c.connection.close()
self.assertEqual(len(row.keys()), len(ModelFixture2._fields))

def test_open_with_multiple_new_fields(self):
new_lib = DatabaseFixture4(self.libfile)
c = new_lib._connection().cursor()
c.execute("select * from test")
row = c.fetchone()
c.connection.close()
self.assertEqual(len(row.keys()), len(ModelFixture4._fields))

def test_extra_model_adds_table(self):
new_lib = DatabaseFixtureTwoModels(self.libfile)
try:
new_lib._connection().execute("select * from another")
c = new_lib._connection()
c.execute("select * from another")
c.close()
except sqlite3.OperationalError:
self.fail("select failed")

Expand Down
8 changes: 4 additions & 4 deletions test/test_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ def test_small_single_artist_album(self):
self.assertFalse(self.items[0].comp)


def test_album_info(*args, **kwargs):
def match_album_mock(*args, **kwargs):
"""Create an AlbumInfo object for testing.
"""
track_info = TrackInfo(
Expand All @@ -1240,7 +1240,7 @@ def test_album_info(*args, **kwargs):
return iter([album_info])


@patch('beets.autotag.mb.match_album', Mock(side_effect=test_album_info))
@patch('beets.autotag.mb.match_album', Mock(side_effect=match_album_mock))
class ImportDuplicateAlbumTest(unittest.TestCase, TestHelper,
_common.Assertions):

Expand Down Expand Up @@ -1349,13 +1349,13 @@ def add_album_fixture(self, **kwargs):
return album


def test_track_info(*args, **kwargs):
def match_track_mock(*args, **kwargs):
return iter([TrackInfo(
artist='artist', title='title',
track_id='new trackid', index=0,)])


@patch('beets.autotag.mb.match_track', Mock(side_effect=test_track_info))
@patch('beets.autotag.mb.match_track', Mock(side_effect=match_track_mock))
class ImportDuplicateSingletonTest(unittest.TestCase, TestHelper,
_common.Assertions):

Expand Down
4 changes: 2 additions & 2 deletions test/test_m3ufile.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ def test_playlist_write_and_read_unicode_windows(self):
self.assertTrue(path.exists(the_playlist_file))
m3ufile_read = M3UFile(the_playlist_file)
m3ufile_read.load()
self.assertEquals(
self.assertEqual(
m3ufile.media_list[0],
bytestring_path(
path.join('x:\\', 'This', 'is', 'å', 'path', 'to_a_file.mp3'))
)
self.assertEquals(
self.assertEqual(
m3ufile.media_list[1],
bytestring_path(r"x:\This\is\another\path\tö_a_file.mp3"),
bytestring_path(path.join(
Expand Down
7 changes: 5 additions & 2 deletions test/test_ui_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def test_create_yes(self):
test_config = deepcopy(config)
test_config['library'] = non_exist_path
with control_stdin('y'):
ui._open_library(test_config)
lib = ui._open_library(test_config)
lib._close()

def test_create_no(self):
non_exist_path_parent = _common.util.py3_path(
Expand All @@ -147,12 +148,14 @@ def test_create_no(self):

with control_stdin('n'):
try:
ui._open_library(test_config)
lib = ui._open_library(test_config)
except ui.UserError:
if os.path.exists(non_exist_path_parent):
shutil.rmtree(non_exist_path_parent)
raise OSError("Parent directories should not be created.")
else:
if lib:
lib._close()
raise OSError("Parent directories should not be created.")


Expand Down