Skip to content

Commit

Permalink
Updated test file paths for consistency
Browse files Browse the repository at this point in the history
Previously, test file paths were specified relative to the working
directory (e.g., `test_file_path = './<path>/'`). This approach led to
test failures, especially when using Poetry to run tests from the root
directory with the command `poetry run pytest`. The paths have now been
adjusted to ensure consistent behavior across directories, resolving the
issue.
  • Loading branch information
mbsantiago committed Nov 16, 2023
1 parent 5cd5695 commit 88055ab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 4 additions & 2 deletions tests/test_new_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@
import pyhydrophone as pyhy
import unittest

TEST_DATA_DIR = pathlib.Path(__file__).parent / "test_data"


class TestHydrophones(unittest.TestCase):
def test_st(self):
# Hydrophone Setup
model = 1
name = 'SoundTrap'
serial_number = 67416073
calibration_file = pathlib.Path("./test_data/soundtrap/calibration_data.xlsx")
calibration_file = TEST_DATA_DIR / "soundtrap" / "calibration_data.xlsx"

st = pyhy.SoundTrap(name, model, serial_number, calibration_file=calibration_file, val='sensitivity',
freq_col_id=1, val_col_id=29, start_data_id=6)
Expand Down Expand Up @@ -67,7 +69,7 @@ def test_rtsys(self):
rtsys_preamp_gain = 0
rtsys_Vpp = 2.0
serial_number = 3
calibration_file = pathlib.Path("./test_data/rtsys/SN130.csv")
calibration_file = TEST_DATA_DIR / "rtsys" / "SN130.csv"
rtsys = pyhy.RTSys(name=rtsys_name, model=rtsys_model, serial_number=serial_number,
sensitivity=rtsys_sensitivity,
preamp_gain=rtsys_preamp_gain, Vpp=rtsys_Vpp, mode='lowpower', channel='A',
Expand Down
7 changes: 4 additions & 3 deletions tests/test_rtsys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import unittest
import numpy as np

CURRENT_DIR = pathlib.Path(__file__).parent

test_folder = pathlib.Path("./test_data/rtsys/")
test_file = pathlib.Path("./test_data/rtsys/channelA_2021-10-11_13-11-09.wav")
test_folder = CURRENT_DIR / "test_data" / "rtsys"
test_file = test_folder / "channelA_2021-10-11_13-11-09.wav"

rtsys_name = 'RTSys'
rtsys_model = 'RESEA320'
Expand All @@ -14,7 +15,7 @@
rtsys_preamp = 0
rtsys_vpp = 5
mode = 'lowpower'
calibration_file = pathlib.Path("./test_data/rtsys/SN130.csv")
calibration_file = test_folder / "SN130.csv"
rtsys = pyhy.RTSys(name=rtsys_name, model=rtsys_model, serial_number=rtsys_serial_number, sensitivity=rtsys_sens,
preamp_gain=rtsys_preamp, Vpp=rtsys_vpp, mode=mode, calibration_file=calibration_file)

Expand Down

0 comments on commit 88055ab

Please sign in to comment.