-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
80 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
comtypes==1.1.2 | ||
enum34==1.1.4 | ||
psutil==4.1.0 | ||
future==0.15.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
""" | ||
Verifies core features run as expected. | ||
""" | ||
from __future__ import print_function | ||
import sys | ||
import unittest | ||
from contextlib import contextmanager | ||
from pycaw.pycaw import AudioUtilities | ||
try: | ||
from StringIO import StringIO | ||
except ImportError: | ||
from io import StringIO | ||
|
||
|
||
@contextmanager | ||
def captured_output(): | ||
new_out, new_err = StringIO(), StringIO() | ||
old_out, old_err = sys.stdout, sys.stderr | ||
try: | ||
sys.stdout, sys.stderr = new_out, new_err | ||
yield sys.stdout, sys.stderr | ||
finally: | ||
sys.stdout, sys.stderr = old_out, old_err | ||
|
||
|
||
class TestCore(unittest.TestCase): | ||
|
||
def test_session_unicode(self): | ||
""" | ||
Makes sure printing a session doesn't crash. | ||
""" | ||
with captured_output() as (out, err): | ||
sessions = AudioUtilities.GetAllSessions() | ||
print("sessions: %s" % sessions) | ||
for session in sessions: | ||
print("session: %s" % session) | ||
print("session.Process: %s" % session.Process) | ||
|
||
def test_device_unicode(self): | ||
""" | ||
Makes sure printing a device doesn't crash. | ||
""" | ||
with captured_output() as (out, err): | ||
devices = AudioUtilities.GetAllDevices() | ||
print("devices: %s" % devices) | ||
for device in devices: | ||
print("device: %s" % device) | ||
|
||
def test_getallsessions_reliability(self): | ||
""" | ||
Verifies AudioUtilities.GetAllSessions() is reliable | ||
even calling it multiple times, refs: | ||
https://github.com/AndreMiras/pycaw/issues/1 | ||
""" | ||
for _ in range(100): | ||
sessions = AudioUtilities.GetAllSessions() | ||
self.assertTrue(len(sessions) > 0) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |