kopia lustrzana https://github.com/F5OEO/tstools
Add some initial doctesting for the Pyrex bindings.
--HG-- extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%4029issue20
rodzic
83cb113b8c
commit
eebcb3e33d
|
@ -35,10 +35,15 @@ PYTHON_INCLUDES=-I$(PYTHON_PREFIX)/include/python$(PYTHON_VERSION)
|
|||
|
||||
LINK_FLAGS=-fPIC -Llib -ltstools -lm -lpython$(PYTHON_VERSION)
|
||||
|
||||
.PHONY: all
|
||||
all:
|
||||
.PHONY: all setup test
|
||||
all: setup test
|
||||
|
||||
setup:
|
||||
python Setup.py build_ext --inplace
|
||||
|
||||
test: setup
|
||||
./rundoctest.py
|
||||
|
||||
# I've never been able to figure out how to stop this grumbling about
|
||||
# a circular dependency. Yet it seems to do the right thing.
|
||||
##%.pyx.c: %.pyx
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#! /usr/bin/env python
|
||||
"""Run the doctest on a text file
|
||||
|
||||
Usage: doctext.py [file]
|
||||
|
||||
[file] defaults to ``test.txt``
|
||||
"""
|
||||
|
||||
import sys
|
||||
import doctest
|
||||
|
||||
def main():
|
||||
args = sys.argv[1:]
|
||||
filename = None
|
||||
verbose = False
|
||||
|
||||
for word in args:
|
||||
if word in ("-v", "-verbose"):
|
||||
verbose = True
|
||||
elif word in ("-h", "-help", "/?", "/help", "--help"):
|
||||
print __doc__
|
||||
return
|
||||
else:
|
||||
if filename:
|
||||
print "Filename '%s' already specified"%filename
|
||||
return
|
||||
else:
|
||||
filename = word
|
||||
|
||||
if not filename:
|
||||
filename = "test.txt"
|
||||
|
||||
try:
|
||||
(failures,tests) = doctest.testfile(filename,verbose=verbose)
|
||||
if failures > 0:
|
||||
print doctest.DIVIDER
|
||||
except:
|
||||
# e.g., Python 2.2
|
||||
tester = doctest.Tester(globs={},verbose=verbose)
|
||||
f = open(filename)
|
||||
(failures,tests) = tester.runstring(f.read(),filename)
|
||||
f.close()
|
||||
if failures > 0:
|
||||
print "*"*65
|
||||
|
||||
testword = "test"
|
||||
if tests != 1: testword = "tests"
|
||||
failword = "failure"
|
||||
if failures != 1: failword = "failures"
|
||||
print "File %s: %d %s, %d %s"%(filename,tests,testword,failures,failword)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,26 @@
|
|||
Some tests for the Python binding of the TS tools
|
||||
=================================================
|
||||
|
||||
It's difficult to find example data files that are generally available. For
|
||||
the moment, I'm going to use a file I have locally, and unfortunately others
|
||||
will have to manage without. This is still better than no testing...
|
||||
|
||||
>>> test_es_file = '/Users/tibs/sw/tstools/data/aladdin.es'
|
||||
|
||||
First, check we've got the basics working:
|
||||
|
||||
>>> from tstools import ESStream
|
||||
>>> stream = ESStream(test_es_file)
|
||||
|
||||
The filename is available as a "readonly" value:
|
||||
|
||||
>>> stream.filename
|
||||
'/Users/tibs/sw/tstools/data/aladdin.es'
|
||||
|
||||
|
||||
// Local Variables:
|
||||
// tab-width: 8
|
||||
// indent-tabs-mode: nil
|
||||
// c-basic-offset: 2
|
||||
// End:
|
||||
// vim: set filetype=rst tabstop=8 shiftwidth=2 expandtab:
|
|
@ -68,8 +68,6 @@ cdef class ESStream:
|
|||
# try the recommended route
|
||||
def __cinit__(self,filename,*args,**kwargs):
|
||||
retval = open_elementary_stream(filename,&self.stream)
|
||||
print 'retval',retval
|
||||
print 'stream %d'%<int>self.stream
|
||||
if retval != 0:
|
||||
raise TSToolsException,'Error opening ES file %s'%filename
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue