1 from panda3d
.core
import load_prc_file_data
2 load_prc_file_data('', 'window-type none')
3 from pathlib
import Path
5 if '' in sys
.path
: sys
.path
.remove('')
6 sys
.path
.append(str(Path(__file__
).parent
.parent
.parent
))
7 from unittest
import TestCase
8 from unittest
.mock
import patch
9 from direct
.showbase
.ShowBase
import ShowBase
10 from ya2
.utils
.audio
import AudioTools
13 class AudioTests(TestCase
):
16 self
.__app
= ShowBase()
22 with (patch
.object(base
, 'musicManager', autospec
=True) as m
,
23 patch
.object(base
, 'sfxManagerList', autospec
=True) as s
):
24 AudioTools
.set_volume(.8)
25 m
.set_volume
.assert_called_once()
26 m_args
= m
.set_volume
.call_args_list
[0].args
27 self
.assertAlmostEqual(m_args
[0], .64, delta
=.01)
28 self
.assertEqual(len(m_args
), 1)
29 s
[0].set_volume
.assert_called_once()
30 s_args
= s
[0].set_volume
.call_args_list
[0].args
31 self
.assertAlmostEqual(s_args
[0], .8, delta
=.01)
32 self
.assertEqual(len(s_args
), 1)