~ubuntu-branches/ubuntu/wily/python-networkx/wily

« back to all changes in this revision

Viewing changes to doc/test.py

  • Committer: Bazaar Package Importer
  • Author(s): Cyril Brulebois
  • Date: 2008-03-02 01:06:32 UTC
  • mfrom: (1.2.1 upstream) (3.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080302010632-1lp6qe1orf59jl8b
* debian/control:
   + Replace python-setuptools with python-pkg-resources in the
     “Recommends:” since pkg_resources is now available in this
     separate package, thanks Matthias Klose (Closes: #468721).
* debian/copyright:
   + Use “© $years $name” instead of invalid “$name, $years” and
     “(C) $years, $name”, thanks to lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# uses docutils to execute python statements in documentation files
3
 
#
4
 
# python test.py tutorial.txt
5
 
#
6
 
# success means that all of the python comands in the documentation
7
 
# ran successfully and produced the correct output
8
 
 
9
 
import glob
10
 
import sys
11
 
import doctest
12
 
import unittest
13
 
import time
14
 
import os
15
 
 
16
 
if sys.version_info[:2] < (2, 4):
17
 
    print "Python version 2.4 or later required for tests (%d.%d detected)." %  sys.version_info[:2]
18
 
    sys.exit(-1)
19
 
 
20
 
nxbase=sys.path[0]+"/../.."  # directory of NX package (relative to this)
21
 
sys.path.insert(0,nxbase)    # prepend to search path
22
 
 
23
 
try:
24
 
    import networkx
25
 
except:
26
 
    print "Can't import networkx module"
27
 
    print sys.path
28
 
    raise
29
 
    
30
 
 
31
 
# argv is list of modules to test
32
 
sys.argv.pop(0)
33
 
 
34
 
files=[]
35
 
for a in sys.argv:
36
 
    files.extend(glob.glob(a))
37
 
 
38
 
 
39
 
print ('Testing networkx %s with Python %s on %s at %s'
40
 
       % (networkx.__version__, sys.version.split()[0],
41
 
          time.strftime('%Y-%m-%d'), time.strftime('%H:%M:%S')))
42
 
sys.stdout.flush()
43
 
 
44
 
for fname in files:
45
 
    suite = unittest.TestSuite()
46
 
    s = doctest.DocFileSuite(fname,module_relative=False)
47
 
    suite.addTest(s)
48
 
    runner = unittest.TextTestRunner()
49
 
    runner.run(suite)