| 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 |
|
|