Skip to content

Commit b283aa4

Browse files
committed
fix settings.ini not located in correct path
1 parent 71a22c6 commit b283aa4

File tree

9 files changed

+48
-18
lines changed

9 files changed

+48
-18
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ prof/
99
.venv/
1010
.env/
1111
.vscode/
12-
tests/data/log/
13-
tests/data/settings.ini
14-
tests/data/autosave.avp
12+
tests/data/config/log/
13+
tests/data/config/settings.ini
14+
tests/data/config/autosave.avp
1515
*.mkv
1616
*.mp4
1717
*.wav

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "uv_build"
66
name = "audio-visualizer-python"
77
description = "Create audio visualization videos from a GUI or commandline"
88
readme = "README.md"
9-
version = "2.2.2"
9+
version = "2.2.3"
1010
requires-python = ">= 3.12"
1111
license = "MIT"
1212
classifiers=[

src/avp/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import logging
44

55

6-
__version__ = "2.2.2"
6+
__version__ = "2.2.3"
77

88

99
class Logger(logging.getLoggerClass()):

src/avp/core.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,7 @@ def storeSettings(cls, dataDir=None):
426426
from .toolkit.ffmpeg import findFfmpeg
427427

428428
cls.wd = wd
429-
dataDir = (
430-
QtCore.QStandardPaths.writableLocation(
431-
QtCore.QStandardPaths.StandardLocation.AppConfigLocation
432-
)
433-
if dataDir is None
434-
else dataDir
435-
)
429+
dataDir = cls.getConfigPath(dataDir)
436430
# Windows: C:/Users/<USER>/AppData/Local/audio-visualizer
437431
# macOS: ~/Library/Preferences/audio-visualizer
438432
# Linux: ~/.config/audio-visualizer
@@ -593,3 +587,16 @@ def makeLogger(deleteOldLogs=False, fileLogLvl=None):
593587
libLog.addHandler(libLogFile)
594588
# lowest level must be explicitly set on the root Logger
595589
libLog.setLevel(0)
590+
591+
@staticmethod
592+
def getConfigPath(dataDir=None):
593+
return (
594+
os.path.join(
595+
QtCore.QStandardPaths.writableLocation(
596+
QtCore.QStandardPaths.StandardLocation.AppConfigLocation
597+
),
598+
"audio-visualizer",
599+
)
600+
if dataDir is None
601+
else dataDir
602+
)

tests/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def getTestDataPath(filename=""):
4343

4444

4545
def initCore():
46-
testDataDir = getTestDataPath()
46+
testDataDir = getTestDataPath("config")
4747
unwanted = ["autosave.avp", "settings.ini"]
4848
for file in unwanted:
4949
filename = os.path.join(testDataDir, "autosave.avp")

tests/data/projects/testproject.avp renamed to tests/data/config/projects/testproject.avp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ OrderedDict({'LG_end': 0.0, 'LG_start': 0.0, 'RG_centre': 0.0015625, 'RG_end': 0
99
[Settings]
1010
componentDir=tests/data/inputfiles
1111
inputDir=tests/data/inputfiles
12-
presetDir=tests/data/presets
13-
projectDir=tests/data/projects
12+
presetDir=tests/data/config/presets
13+
projectDir=tests/data/config/projects
1414

1515
[WindowFields]
16-
lineEdit_audioFile=tests/data/test.ogg
16+
lineEdit_audioFile=tests/data/inputfiles/test.ogg
1717
lineEdit_outputFile=

tests/test_core_init.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import os
12
from avp.core import Core
3+
from . import getTestDataPath, initCore
24

35

46
def test_component_names():
7+
initCore()
58
core = Core()
69
assert core.compNames == [
710
"Classic Visualizer",
@@ -17,5 +20,15 @@ def test_component_names():
1720

1821

1922
def test_moduleindex():
23+
initCore()
2024
core = Core()
2125
assert core.moduleIndexFor("Classic Visualizer") == 0
26+
27+
28+
def test_configPath_default():
29+
configPath = Core.getConfigPath(None)
30+
assert os.path.basename(configPath) == "audio-visualizer"
31+
32+
33+
def test_configPath_nonstandard():
34+
assert Core.getConfigPath(getTestDataPath("config")) == getTestDataPath("config")

tests/test_mainwindow_projects.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from PyQt6 import QtCore
2+
import os
13
from pytest import fixture
24
from pytestqt import qtbot
35
from . import getTestDataPath, window
@@ -8,9 +10,17 @@ def test_mainwindow_clear(qtbot, window):
810
assert len(window.core.selectedComponents) == 0
911

1012

13+
def test_mainwindow_presetDir_in_tests(qtbot, window):
14+
# FIXME presetDir gets set to projectDir for some reason
15+
assert (
16+
os.path.basename(os.path.dirname(window.core.settings.value("presetDir")))
17+
== "config"
18+
)
19+
20+
1121
def test_mainwindow_openProject(qtbot, window):
1222
"""Open testproject.avp using MainWindow.openProject()"""
13-
window.openProject(getTestDataPath("projects/testproject.avp"), prompt=False)
23+
window.openProject(getTestDataPath("config/projects/testproject.avp"), prompt=False)
1424
assert len(window.core.selectedComponents) == 2
1525

1626

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)