mirror of
https://github.com/beetbox/beets.git
synced 2026-02-09 08:52:30 +01:00
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`
24 lines
684 B
Python
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
|