Datasets:
File size: 658 Bytes
70954e8 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
from pathlib import Path
import pytest
@pytest.fixture()
def lyrics_files():
return [f for f in Path("lyrics").glob("*.txt")]
@pytest.fixture()
def lyrics(lyrics_files):
lyrics = []
for lyric_file in lyrics_files:
with open(lyric_file, "r", encoding="utf-8") as file:
lyrics.append((file.read(), str(lyric_file.name)))
return lyrics
@pytest.fixture()
def lines(lyrics):
all_lines = []
for lyric in lyrics:
line_number = 0
lines = lyric[0].splitlines()
for line in lines:
line_number += 1
all_lines.append((line, line_number, lyric[1]))
return all_lines
|