File: conftest.py

package info (click to toggle)
pytorch-audio 2.9.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 108,884 kB
  • sloc: python: 44,403; cpp: 3,384; sh: 126; makefile: 32
file content (23 lines) | stat: -rw-r--r-- 958 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import sys
from pathlib import Path

# Note: [TorchCodec test dependency mocking hack]
# We are adding the `test/` directory to the system path. This causes the
# `tests/torchcodec` folder to be importable, and in particular, this makes it
# possible to mock torchcodec utilities. E.g. executing:
#
# ```
# from torchcodec.decoders import AudioDecoder
# ```
# directly or indirectly when running the tests will effectively be loading the
# mocked `AudioDecoder` implemented in `test/torchcodec/decoders.py`, which
# relies on scipy instead of relying on torchcodec.
#
# So whenever `torchaudio.load()` is called from within the tests, it's the
# mocked scipy `AudioDecoder` that gets used.  Ultimately, this allows us *not*
# to add torchcodec as a test dependency of torchaudio: we can just rely on
# scipy.
#
# This is VERY hacky and ideally we should implement a more robust way to mock
# torchcodec.
sys.path.append(str(Path(__file__).parent.resolve()))