Skip to content

Commit

Permalink
Merge pull request #213 from singingwolfboy/unittest-mock
Browse files Browse the repository at this point in the history
Drop mock dep, use unittest.mock
  • Loading branch information
Evolution0 authored Sep 13, 2023
2 parents f7327d1 + 2fda3a0 commit 6389e48
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 11 deletions.
2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,6 @@ Dependencies
- `Docopt <https://pypi.python.org/pypi/docopt>`_ - CLI help
- `Six <https://pypi.python.org/pypi/six>`_ - Python 2-3 compatibility
- `Unidecode <https://pypi.python.org/pypi/unidecode>`_ - ASCII representation of Unicode text
- `Mock <https://pypi.python.org/pypi/mock>`_ - Library for Python unit testing
- `PBR <https://pypi.python.org/pypi/pbr>`_ - Setuptools injection library required by Mock

Copyright
---------
Expand Down
12 changes: 6 additions & 6 deletions bandcamp_dl/bandcampdownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from bandcamp_dl.utils.unicode_slugify import slugify

if not sys.version_info[:2] == (3, 6):
import mock
import unittest.mock
from bandcamp_dl.utils import requests_patch

from bandcamp_dl.__init__ import __version__
Expand Down Expand Up @@ -163,7 +163,7 @@ def download_album(self, album: dict) -> bool:
while True:
try:
if not sys.version_info[:2] == (3, 6):
with mock.patch('http.client.parse_headers', requests_patch.parse_headers):
with unittest.mock.patch('http.client.parse_headers', requests_patch.parse_headers):
r = self.session.get(track['url'], headers=self.headers, stream=True)
else:
r = self.session.get(track['url'], headers=self.headers, stream=True)
Expand Down Expand Up @@ -253,18 +253,18 @@ def write_id3_tags(self, filepath: str, meta: dict):
audio["APIC"] = APIC(encoding=3, mime='image/jpeg', type=3, desc='Cover', data=cover_bytes)
audio.save()

audio = EasyMP3(filepath)
audio = EasyMP3(filepath)

if meta['track'].isdigit():
audio["tracknumber"] = meta['track']
else:
audio["tracknumber"] = '1'

if meta['artist'] is not None:
audio["artist"] = meta['artist']
else:
audio["artist"] = meta['albumartist']

audio["title"] = meta["title"]
audio["albumartist"] = meta['albumartist']
audio["album"] = meta['album']
Expand Down
1 change: 0 additions & 1 deletion bandcamp_dl/deps.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ docopt-ng==0.8.1
mutagen==1.45.1
requests==2.31.0
unicode-slugify==0.1.5
mock==4.0.3
chardet==4.0.0
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ docopt-ng==0.8.1
mutagen==1.45.1
requests==2.31.0
unicode-slugify==0.1.5
mock==4.0.3
chardet==4.0.0
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
'mutagen',
'requests',
'unicode-slugify',
'mock',
'chardet',
],
extras_require={
Expand Down

0 comments on commit 6389e48

Please sign in to comment.