=== added directory 'tests' === added file 'tests/test_core.py' --- tests/test_core.py 1970-01-01 00:00:00 +0000 +++ tests/test_core.py 2007-04-16 20:18:57 +0000 @@ -0,0 +1,48 @@ + +""" Test the basic functionality of the pykhtml module -- test the utility functions it provides, that it imports, etc """ + +import sys +import os +import subprocess +import signal # for constants + +here = os.path.dirname(os.path.abspath(__file__)) +up = os.path.dirname(here) +sys.path.insert(0, up) + +pykhtml = None + +def test_pykhtmlImports(): + """ Test that PyKHTML imports. If it fails, either it's bodged up or you didn't have PyKDE/PyQt """ + global pykhtml + print "Path:", sys.path + import pykhtml + +def test_checkProcessRunningImplementedForPlatform(): + """ Check if pykhtml.checkProcessRunning exists for this platform. If not, it needs to be written and Xvfb support won't work for your platform """ + print "Plaform:", os.name + assert pykhtml.checkProcessRunning != pykhtml._checkProcessRunningDefault + +def test_checkProcessRunning(): + """ Test that checkProcessRunning for this platform works (won't pass if test_checkProcessRunningImplementedForPlatform failed) """ + sleep = subprocess.Popen(["sleep", "5"]) + assert pykhtml.checkProcessRunning("sleep") + os.kill(sleep.pid, signal.SIGINT) + +def test_pathSearch(): + """ Test that we can find executables in pykhtml.path (populated with $PATH by default) """ + # append this directory to pykhtml.path + pykhtml.path.append(here) + fileName = os.path.abspath(__file__).rstrip("c") # strip off pyc + assert pykhtml.pathSearch("test_core.py") + print fileName + assert pykhtml.pathSearch("test_core.py")[0] == fileName + +def test_partial(): + """ Test partial parameter application with pykhtml.partial (both regular arguments and keywords arguments) works """ + foo = lambda *args, **kwargs: (args, kwargs) + # check regular arguments + assert foo("bar", "baz") == pykhtml.partial(foo, "bar")("baz") + # and then keyword arguments + assert foo("bar", b="baz") == pykhtml.partial(foo, b="baz")("bar") + === modified file 'pykhtml/__init__.py' --- pykhtml/__init__.py 2007-04-10 01:22:36 +0000 +++ pykhtml/__init__.py 2007-04-16 20:18:57 +0000 @@ -31,13 +31,18 @@ temp = tempfile.gettempdir() ## If this is being launched from multiple instances it's ## stupid to start Xvfb each time + +def _checkProcessRunningDefault(name): + return False + def _checkProcessRunningPosix(name): procs = os.popen("ps -eo comm").read().strip().split("\n") return name in procs + if os.name == "posix": checkProcessRunning = _checkProcessRunningPosix else: - raise OSError("Need to implement checkProcessRunning(name) for %s" % repr(os.name)) + pass # Xvfb process. # An object with a display attribute (that contains the # X display value (i.e :1)) @@ -111,7 +116,7 @@ wallet.sync() # kick kded = dcopext.DCOPApp("kded", kdecore.KApplication.kApplication().dcopClient()) - print kded.kwalletd.reconfigure() + kded.kwalletd.reconfigure() def _acceptCookiesGlobally(): jar = kdecore.KConfig("kcookiejarrc") === modified file 'todo.txt' --- todo.txt 2007-04-09 23:55:45 +0000 +++ todo.txt 2007-04-16 20:18:57 +0000 @@ -2,7 +2,7 @@ * PyKHTML Todo List * ********************** - + UNIT TESTS! + + More unit tests: KWallet/cookies and 'the rest' + Make the examples available online + Big friendly 'Download (latest)' button + Add Contact section to the website