beets/test/ui/commands/test_fields.py
Šarūnas Nejus ed43387778
Replace custom stdio mocks with pytest io fixture
Create a centralised pytest fixture to provide controllable stdin and
captured stdout in all tests. Simplify DummyIO/DummyIn and remove the
custom DummyOut implementation and make use of pytest builtin fixtures.

Create a centralised pytest fixture to provide controllable stdin and
captured stdout that can be applied to any tests, regardless whether
they are based on pytest or unittest.

* `io` fixture can be used as a fixture in pytest-based tests
* `IOMixin` can be used to attach `io` attribute to any test class,
  including `unittest.TestCase`
2026-01-16 21:44:16 +00:00

24 lines
684 B
Python

from beets import library
from beets.test.helper import IOMixin, ItemInDBTestCase
from beets.ui.commands.fields import fields_func
class FieldsTest(IOMixin, ItemInDBTestCase):
def remove_keys(self, keys, text):
for i in text:
try:
keys.remove(i)
except ValueError:
pass
def test_fields_func(self):
fields_func(self.lib, [], [])
items = library.Item.all_keys()
albums = library.Album.all_keys()
output = self.io.getoutput().split()
self.remove_keys(items, output)
self.remove_keys(albums, output)
assert len(items) == 0
assert len(albums) == 0