diff --git a/tests/test_model.py b/tests/test_model.py index dd66a4bc..0789ad15 100755 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -28,7 +28,6 @@ ) from m3u8.protocol import ext_x_part, ext_x_preload_hint, ext_x_start - utc = datetime.timezone.utc @@ -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)