Skip to content

Commit 7fe2d77

Browse files
committed
test: guard against invalid escape SyntaxWarnings in utils
1 parent 996cec4 commit 7fe2d77

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

test/test.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from functools import partial
22
import os
3+
import subprocess
34
import sys
45
import unittest
56
from tempfile import (
@@ -58,6 +59,22 @@ def test_db_float_conversions(self):
5859
self.assertEqual(3, db_to_float(ratio_to_db(3, using_amplitude=False), using_amplitude=False))
5960
self.assertEqual(12, ratio_to_db(db_to_float(12, using_amplitude=False), using_amplitude=False))
6061

62+
def test_utils_module_has_no_invalid_escape_syntax_warnings(self):
63+
project_root = os.path.dirname(os.path.dirname(__file__))
64+
utils_path = os.path.join(project_root, "pydub", "utils.py")
65+
66+
proc = subprocess.Popen(
67+
[sys.executable, "-W", "error::SyntaxWarning", "-m", "py_compile", utils_path],
68+
stdout=subprocess.PIPE,
69+
stderr=subprocess.PIPE,
70+
)
71+
_, stderr = proc.communicate()
72+
self.assertEqual(
73+
proc.returncode,
74+
0,
75+
stderr.decode("utf-8", errors="ignore"),
76+
)
77+
6178

6279
if sys.version_info >= (3, 6):
6380
class PathLikeObjectTests(unittest.TestCase):

0 commit comments

Comments
 (0)