Skip to content

Commit 38b8b4f

Browse files
authored
Changing test file structure to ensure pytest discoverability (#289)
1 parent b25a373 commit 38b8b4f

10 files changed

Lines changed: 37 additions & 37 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ If you want to contribute a new feature or fix, please:
77
- Check if there isn't any open issue for the same problem
88
- Fork the project
99
- Implement your feature or fix
10-
- Bonus points if you provide a test case in `test/test.py`
10+
- Bonus points if you provide a test case in `test/test_*.py`
1111
- Provide a commit for the change you want to make (one feature per commit, please)
1212
- Create a pull request
1313

@@ -17,4 +17,4 @@ If you want to contribute a new feature or fix, please:
1717

1818
## Issues and Questions
1919

20-
If you simply have a question or want to raise an issue, head to the issue tracker. There's a template there that you're kindly asked to fill out. It helps me understand what the problem might be.
20+
If you simply have a question or want to raise an issue, head to the issue tracker. There's a template there that you're kindly asked to fill out. It helps me understand what the problem might be.

.github/workflows/python-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
mypy ffmpeg_normalize
3535
- name: Test with pytest
3636
run: |
37-
pytest test/test.py
37+
pytest

DEVELOPERS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## Tests
44

5-
Tests are located in `test/test.py`. To run them:
5+
Tests are located in `tests/test_*.py`. To run them:
66

77
- Install `requirements.txt` and `requirements.dev.txt`
8-
- Run `pytest test/test.py`
8+
- Run `pytest`
99

1010
## Creating API Docs
1111

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

test/test.py renamed to tests/test_filetypes.py

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -148,21 +148,21 @@ def cleanup(self):
148148
shutil.rmtree("normalized")
149149

150150
def test_output_filename_and_folder(self):
151-
ffmpeg_normalize_call(["test/test.mp4"])
151+
ffmpeg_normalize_call(["tests/test.mp4"])
152152
assert os.path.isfile("normalized/test.mkv")
153153

154154
def test_default_warnings(self):
155155
_, stderr = ffmpeg_normalize_call(
156-
["test/test.mp4", "--dynamic", "-o", "normalized/test2.wav"]
156+
["tests/test.mp4", "--dynamic", "-o", "normalized/test2.wav"]
157157
)
158158
assert "sample rate will automatically be set" in stderr
159159

160160
def test_multiple_outputs(self):
161161
os.makedirs("normalized", exist_ok=True)
162162
ffmpeg_normalize_call(
163163
[
164-
"test/test.mp4",
165-
"test/test.mp4",
164+
"tests/test.mp4",
165+
"tests/test.mp4",
166166
"-o",
167167
"normalized/test1.mkv",
168168
"normalized/test2.mkv",
@@ -172,23 +172,23 @@ def test_multiple_outputs(self):
172172
assert os.path.isfile("normalized/test2.mkv")
173173

174174
def test_overwrites(self):
175-
ffmpeg_normalize_call(["test/test.mp4", "-v"])
176-
_, stderr = ffmpeg_normalize_call(["test/test.mp4", "-v"])
175+
ffmpeg_normalize_call(["tests/test.mp4", "-v"])
176+
_, stderr = ffmpeg_normalize_call(["tests/test.mp4", "-v"])
177177
assert "exists" in stderr
178178

179179
def test_dry(self):
180-
ffmpeg_normalize_call(["test/test.mp4", "-n"])
180+
ffmpeg_normalize_call(["tests/test.mp4", "-n"])
181181
assert not os.path.isfile("normalized/test.mkv")
182182

183183
def test_only_supports_one_stream_output(self):
184184
os.makedirs("normalized", exist_ok=True)
185185
_, stderr = ffmpeg_normalize_call(
186-
["test/test.mp4", "-o", "normalized/test.wav", "-v"]
186+
["tests/test.mp4", "-o", "normalized/test.wav", "-v"]
187187
)
188188
assert "Output file only supports one stream" in stderr
189189

190190
def test_peak(self):
191-
ffmpeg_normalize_call(["test/test.mp4", "-nt", "peak", "-t", "0"])
191+
ffmpeg_normalize_call(["tests/test.mp4", "-nt", "peak", "-t", "0"])
192192
assert os.path.isfile("normalized/test.mkv")
193193
assert fuzzy_equal(
194194
_get_stats("normalized/test.mkv", "peak"),
@@ -215,7 +215,7 @@ def test_peak(self):
215215
)
216216

217217
def test_rms(self):
218-
ffmpeg_normalize_call(["test/test.mp4", "-nt", "rms", "-t", "-15"])
218+
ffmpeg_normalize_call(["tests/test.mp4", "-nt", "rms", "-t", "-15"])
219219
assert os.path.isfile("normalized/test.mkv")
220220
assert fuzzy_equal(
221221
_get_stats("normalized/test.mkv", "rms"),
@@ -242,7 +242,7 @@ def test_rms(self):
242242
)
243243

244244
def test_ebu(self):
245-
ffmpeg_normalize_call(["test/test.mp4", "-nt", "ebu"])
245+
ffmpeg_normalize_call(["tests/test.mp4", "-nt", "ebu"])
246246
assert os.path.isfile("normalized/test.mkv")
247247
assert fuzzy_equal(
248248
_get_stats("normalized/test.mkv", "ebu"),
@@ -291,15 +291,15 @@ def test_ebu(self):
291291
)
292292

293293
def test_acodec(self):
294-
ffmpeg_normalize_call(["test/test.mp4", "-c:a", "aac"])
294+
ffmpeg_normalize_call(["tests/test.mp4", "-c:a", "aac"])
295295
assert os.path.isfile("normalized/test.mkv")
296296
assert _get_stream_info("normalized/test.mkv")[1]["codec_name"] == "aac"
297297

298298
def test_abr(self):
299299
os.makedirs("normalized", exist_ok=True)
300300
ffmpeg_normalize_call(
301301
[
302-
"test/test.mp4",
302+
"tests/test.mp4",
303303
"-c:a",
304304
"aac",
305305
"-b:a",
@@ -316,37 +316,37 @@ def test_abr(self):
316316
)
317317

318318
def test_ar(self):
319-
ffmpeg_normalize_call(["test/test.mp4", "-ar", "48000"])
319+
ffmpeg_normalize_call(["tests/test.mp4", "-ar", "48000"])
320320
assert os.path.isfile("normalized/test.mkv")
321321
assert _get_stream_info("normalized/test.mkv")[1]["sample_rate"] == "48000"
322322

323323
def test_vcodec(self):
324-
ffmpeg_normalize_call(["test/test.mp4", "-c:v", "libx265"])
324+
ffmpeg_normalize_call(["tests/test.mp4", "-c:v", "libx265"])
325325
assert os.path.isfile("normalized/test.mkv")
326326
assert _get_stream_info("normalized/test.mkv")[0]["codec_name"] == "hevc"
327327

328328
def test_extra_input_options_json(self):
329329
ffmpeg_normalize_call(
330-
["test/test.mp4", "-c:a", "aac", "-ei", '[ "-f", "mp4" ]']
330+
["tests/test.mp4", "-c:a", "aac", "-ei", '[ "-f", "mp4" ]']
331331
)
332332
# FIXME: some better test that options are respected?
333333
assert os.path.isfile("normalized/test.mkv")
334334

335335
def test_extra_output_options_json(self):
336-
ffmpeg_normalize_call(["test/test.mp4", "-c:a", "aac", "-e", '[ "-vbr", "3" ]'])
336+
ffmpeg_normalize_call(["tests/test.mp4", "-c:a", "aac", "-e", '[ "-vbr", "3" ]'])
337337
# FIXME: some better test that options are respected?
338338
assert os.path.isfile("normalized/test.mkv")
339339

340340
def test_ofmt_fail(self):
341341
_, stderr = ffmpeg_normalize_call(
342-
["test/test.mp4", "-ofmt", "mp3", "-o", "normalized/test.mp3", "-vn", "-sn"]
342+
["tests/test.mp4", "-ofmt", "mp3", "-o", "normalized/test.mp3", "-vn", "-sn"]
343343
)
344344
assert "does not support" in stderr
345345

346346
def test_ofmt_mp3(self):
347347
ffmpeg_normalize_call(
348348
[
349-
"test/test.mp4",
349+
"tests/test.mp4",
350350
"-ofmt",
351351
"mp3",
352352
"-o",
@@ -360,31 +360,31 @@ def test_ofmt_mp3(self):
360360
assert os.path.isfile("normalized/test.mp3")
361361

362362
def test_ext_fail(self):
363-
_, stderr = ffmpeg_normalize_call(["test/test.mp4", "-ext", "mp3"])
363+
_, stderr = ffmpeg_normalize_call(["tests/test.mp4", "-ext", "mp3"])
364364
assert "does not support" in stderr
365365

366366
def test_ext_mp3(self):
367-
ffmpeg_normalize_call(["test/test.mp4", "-ext", "mp3", "-c:a", "libmp3lame"])
367+
ffmpeg_normalize_call(["tests/test.mp4", "-ext", "mp3", "-c:a", "libmp3lame"])
368368
assert os.path.isfile("normalized/test.mp3")
369369

370370
def test_version(self):
371371
stdout, _ = ffmpeg_normalize_call(["--version"])
372372
assert "ffmpeg-normalize v" in stdout
373373

374374
def test_progress(self):
375-
_, stderr = ffmpeg_normalize_call(["test/test.mp4", "-pr"])
375+
_, stderr = ffmpeg_normalize_call(["tests/test.mp4", "-pr"])
376376
assert "0/100" in stderr
377377
assert "100/100" in stderr or "100%" in stderr
378378
assert os.path.isfile("normalized/test.mkv")
379379

380380
def test_duration(self):
381-
_, stderr = ffmpeg_normalize_call(["test/test.wav", "--debug"])
381+
_, stderr = ffmpeg_normalize_call(["tests/test.wav", "--debug"])
382382
assert "Found duration: " in stderr
383383

384384
def test_pre_filters(self):
385385
ffmpeg_normalize_call(
386386
[
387-
"test/test.wav",
387+
"tests/test.wav",
388388
"-o",
389389
"normalized/test2.wav",
390390
"-prf",
@@ -421,7 +421,7 @@ def test_pre_filters(self):
421421
def test_post_filters(self):
422422
ffmpeg_normalize_call(
423423
[
424-
"test/test.wav",
424+
"tests/test.wav",
425425
"-o",
426426
"normalized/test2.wav",
427427
"-pof",
@@ -457,31 +457,31 @@ def test_post_filters(self):
457457

458458
def test_quiet(self):
459459
_, stderr = ffmpeg_normalize_call(
460-
["test/test.mp4", "-ext", "wav", "-vn", "-f", "q"]
460+
["tests/test.mp4", "-ext", "wav", "-vn", "-f", "q"]
461461
)
462462
assert "only supports one stream" not in stderr
463463

464464
def test_audio_channels(self):
465465
ffmpeg_normalize_call(
466-
["test/test.mp4", "-ac", "1", "-o", "normalized/test.wav"]
466+
["tests/test.mp4", "-ac", "1", "-o", "normalized/test.wav"]
467467
)
468468
assert os.path.isfile("normalized/test.wav")
469469
stream_info = _get_stream_info("normalized/test.wav")[0]
470470
assert stream_info["channels"] == 1
471471

472472
ffmpeg_normalize_call(
473-
["test/test.mp4", "-ac", "2", "-o", "normalized/test2.wav"]
473+
["tests/test.mp4", "-ac", "2", "-o", "normalized/test2.wav"]
474474
)
475475
assert os.path.isfile("normalized/test2.wav")
476476
stream_info = _get_stream_info("normalized/test2.wav")[0]
477477
assert stream_info["channels"] == 2
478478

479479
def test_replaygain(self):
480480
for file in [
481-
"test/test.mp4",
482-
"test/test.mp3",
483-
"test/test.ogg",
484-
"test/test.opus",
481+
"tests/test.mp4",
482+
"tests/test.mp3",
483+
"tests/test.ogg",
484+
"tests/test.opus",
485485
]:
486486
original_mtime = os.path.getmtime(file)
487487
ffmpeg_normalize_call([file, "--replaygain"])

0 commit comments

Comments
 (0)