Skip to content

Commit

Permalink
Add test to check relative path when dumping
Browse files Browse the repository at this point in the history
  • Loading branch information
mauricioabreu committed Aug 3, 2024
1 parent be770e2 commit 4acf27d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
)
from m3u8.protocol import ext_x_part, ext_x_preload_hint, ext_x_start


utc = datetime.timezone.utc


Expand Down Expand Up @@ -748,6 +747,23 @@ def test_dump_should_raise_if_create_sub_directories_fails(tmpdir):
m3u8.M3U8(playlists.SIMPLE_PLAYLIST).dump(file_name)


def test_create_sub_directories_with_relative_path(tmpdir, monkeypatch):
relative_path = os.path.join("relative", "path", "playlist.m3u8")

# Use a temporary directory as the current working directory for the test
monkeypatch.chdir(tmpdir)

obj = m3u8.M3U8(playlists.SIMPLE_PLAYLIST)

obj.dump(relative_path)

expected_file_path = os.path.join(tmpdir, relative_path)
assert os.path.exists(expected_file_path)

with open(expected_file_path, "r") as file:
assert file.read().strip() == playlists.SIMPLE_PLAYLIST.strip()


def test_dump_should_work_for_variant_streams():
obj = m3u8.M3U8(playlists.VARIANT_PLAYLIST)

Expand Down

0 comments on commit 4acf27d

Please sign in to comment.