mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Replace assertAlmostEqual
This commit is contained in:
parent
fcc4d8481d
commit
d3bdd93bf6
4 changed files with 18 additions and 13 deletions
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from beets import importer
|
||||
from beets.test.helper import AutotagStub, ImportTestCase, PluginMixin
|
||||
from beets.util import displayable_path, syspath
|
||||
|
|
@ -74,7 +76,7 @@ class ImportAddedTest(PluginMixin, ImportTestCase):
|
|||
|
||||
def assertEqualTimes(self, first, second, msg=None): # noqa
|
||||
"""For comparing file modification times at a sufficient precision"""
|
||||
self.assertAlmostEqual(first, second, places=4, msg=msg)
|
||||
assert first == pytest.approx(second, rel=1e-4), msg
|
||||
|
||||
def assertAlbumImport(self): # noqa
|
||||
self.importer.run()
|
||||
|
|
|
|||
|
|
@ -12,8 +12,7 @@
|
|||
# The above copyright notice and this permission notice shall be
|
||||
# included in all copies or substantial portions of the Software.
|
||||
|
||||
"""Tests for BPD's implementation of the MPD protocol.
|
||||
"""
|
||||
"""Tests for BPD's implementation of the MPD protocol."""
|
||||
|
||||
import importlib.util
|
||||
import multiprocessing as mp
|
||||
|
|
@ -30,6 +29,7 @@ from contextlib import contextmanager
|
|||
from unittest import mock
|
||||
|
||||
import confuse
|
||||
import pytest
|
||||
import yaml
|
||||
|
||||
from beets.test.helper import PluginTestCase
|
||||
|
|
@ -703,13 +703,13 @@ class BPDPlaybackTest(BPDTestHelper):
|
|||
self._assert_failed(responses, bpd.ERROR_ARG, pos=3)
|
||||
self._assert_failed(response, bpd.ERROR_ARG)
|
||||
assert "xfade" not in responses[0].data
|
||||
self.assertAlmostEqual(123, int(responses[2].data["xfade"]))
|
||||
assert 123 == pytest.approx(int(responses[2].data["xfade"]))
|
||||
|
||||
def test_cmd_mixrampdb(self):
|
||||
with self.run_bpd() as client:
|
||||
responses = client.send_commands(("mixrampdb", "-17"), ("status",))
|
||||
self._assert_ok(*responses)
|
||||
self.assertAlmostEqual(-17, float(responses[1].data["mixrampdb"]))
|
||||
assert -17 == pytest.approx(float(responses[1].data["mixrampdb"]))
|
||||
|
||||
def test_cmd_mixrampdelay(self):
|
||||
with self.run_bpd() as client:
|
||||
|
|
@ -721,7 +721,7 @@ class BPDPlaybackTest(BPDTestHelper):
|
|||
("mixrampdelay", "-2"),
|
||||
)
|
||||
self._assert_failed(responses, bpd.ERROR_ARG, pos=4)
|
||||
self.assertAlmostEqual(2, float(responses[1].data["mixrampdelay"]))
|
||||
assert 2 == pytest.approx(float(responses[1].data["mixrampdelay"]))
|
||||
assert "mixrampdelay" not in responses[3].data
|
||||
|
||||
def test_cmd_setvol(self):
|
||||
|
|
@ -753,7 +753,7 @@ class BPDPlaybackTest(BPDTestHelper):
|
|||
("replay_gain_mode", "notanoption"),
|
||||
)
|
||||
self._assert_failed(responses, bpd.ERROR_ARG, pos=2)
|
||||
self.assertAlmostEqual("track", responses[1].data["replay_gain_mode"])
|
||||
assert "track" == responses[1].data["replay_gain_mode"]
|
||||
|
||||
|
||||
class BPDControlTest(BPDTestHelper):
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import math
|
|||
import unittest
|
||||
from random import Random
|
||||
|
||||
import pytest
|
||||
|
||||
from beets import random
|
||||
from beets.test.helper import TestHelper
|
||||
|
||||
|
|
@ -74,6 +76,6 @@ class RandomTest(TestHelper, unittest.TestCase):
|
|||
|
||||
mean1, stdev1, median1 = experiment("artist")
|
||||
mean2, stdev2, median2 = experiment("track")
|
||||
self.assertAlmostEqual(0, median1, delta=1)
|
||||
self.assertAlmostEqual(len(self.items) // 2, median2, delta=1)
|
||||
assert 0 == pytest.approx(median1, abs=1)
|
||||
assert len(self.items) // 2 == pytest.approx(median2, abs=1)
|
||||
assert stdev2 > stdev1
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
import unittest
|
||||
from typing import ClassVar
|
||||
|
||||
import pytest
|
||||
from mediafile import MediaFile
|
||||
|
||||
from beets import config
|
||||
|
|
@ -149,11 +150,11 @@ class ReplayGainCliTest:
|
|||
assert item.rg_track_peak is not None
|
||||
assert item.rg_track_gain is not None
|
||||
mediafile = MediaFile(item.path)
|
||||
self.assertAlmostEqual(
|
||||
mediafile.rg_track_peak, item.rg_track_peak, places=6
|
||||
assert mediafile.rg_track_peak == pytest.approx(
|
||||
item.rg_track_peak, abs=1e-6
|
||||
)
|
||||
self.assertAlmostEqual(
|
||||
mediafile.rg_track_gain, item.rg_track_gain, places=2
|
||||
assert mediafile.rg_track_gain == pytest.approx(
|
||||
item.rg_track_gain, abs=1e-2
|
||||
)
|
||||
|
||||
def test_cli_skips_calculated_tracks(self):
|
||||
|
|
|
|||
Loading…
Reference in a new issue