Permalink
Browse files

Better passing of command line arguments, tests

  • Loading branch information...
1 parent 167e8cd commit 6e7801b4ea9d59167f7606e9745add080e2d8274 @pafcu committed Oct 11, 2010
Showing with 21 additions and 4 deletions.
  1. +8 −1 pymplb.py
  2. +13 −3 tests.py
View
@@ -23,6 +23,8 @@
>>> import pymplb
>>> player = pymplb.MPlayer()
>>> player.loadfile('test.ogv')
+>>> player.p_filename
+'test.ogv'
"""
from functools import partial
@@ -60,7 +62,8 @@ def __init__(self, mplayer_args_d=None, **mplayer_args):
cmd_args = [mplayer_bin, '-slave', '-quiet', '-idle', '-msglevel', 'all=-1:global=4']
for (name, value) in mplayer_args.items():
cmd_args.append('-'+name)
- cmd_args.append(value)
+ if value != None and value != True:
+ cmd_args.append(str(value))
self.__player = _MPlayer._run_player(cmd_args)
@@ -227,3 +230,7 @@ def set_prop(name, prop_type, islist, prop_min, prop_max, self, value):
return _MPlayer
MPlayer = make_mplayer_class() # pylint: disable-msg=C0103
+
+if __name__ == "__main__":
+ import doctest
+ doctest.testmod(optionflags=doctest.ELLIPSIS)
View
@@ -1,5 +1,4 @@
import unittest
-import time
import pymplb
class TestMPlayer(unittest.TestCase):
@@ -23,7 +22,6 @@ def testMethod(self):
def testListProperty(self):
player = pymplb.MPlayer()
player.loadfile('test.ogv')
- time.sleep(0.1)
r = player.p_metadata
self.assertEqual(type(r),type([]))
@@ -33,7 +31,7 @@ def testNullProperty(self):
self.assertEqual(r,None)
def testLoadedFileProperties(self):
- player = pymplb.MPlayer()
+ player = pymplb.MPlayer(fs=True)
player.loadfile('test.ogv')
r = player.p_filename
self.assertNotEqual(r,None)
@@ -69,5 +67,17 @@ def testGetpropertyType(self):
r = player.p_loop
self.assertEqual(type(r),type(0))
+ def testInitArgumentsDict(self):
+ player = pymplb.MPlayer({'fs':True,'speed':2.0})
+ player.loadfile('test.ogv')
+
+ def testInitArgumentsKw(self):
+ player = pymplb.MPlayer(fs=True,speed=2.0)
+ player.loadfile('test.ogv')
+
+ def testPausing(self):
+ player = pymplb.MPlayer()
+ player.get_property('loop',pausing='pausing')
+
if __name__ == '__main__':
unittest.main()

0 comments on commit 6e7801b

Please sign in to comment.