From: W. Trevor King Date: Sat, 14 May 2011 18:11:50 +0000 (-0400) Subject: Adjust asymptote and gnuplot doctests to be directory independent. X-Git-Tag: v1.0~357 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=a22b4247a18ee19b86b7499d03d1270642825edb;p=thesis.git Adjust asymptote and gnuplot doctests to be directory independent. Now you can run the doctests from any directory and they will still find the files they are scanning to test. Note that SCons may not be installed in your PYTHONPATH by default: > From: Steven Knight > Date: May 28, 2008; 10:01am > Subject: Re: easy_installed scons not working > > ... > > In essence, we've tried to make SCons more like a standalone > application that happens to use Python, instead of a Python > application that only exists "within" the Python installation itself. > This separation also allows you, for example, to experiment with > upgrading your Python version without having to re-install SCons. > > ... > > Note that the hacking we've done on our setup.py does allow you to > install into the site-package/ subdirectory if you wish, using an > extended --standard-lib option. > > ... So you may need to try something like: PYTHONPATH=/usr/lib/scons-2.0.1/ python site_cons/site_tools/asymptote.py to run the tests. --- diff --git a/tex/site_cons/site_tools/asymptote.py b/tex/site_cons/site_tools/asymptote.py index f954bd1..9d7f2f4 100644 --- a/tex/site_cons/site_tools/asymptote.py +++ b/tex/site_cons/site_tools/asymptote.py @@ -15,6 +15,8 @@ asyfigs = [] def asymptote_scan(node, env, path, arg=None): """ + >>> this_dir = os.path.dirname(__file__) + >>> src_dir = os.path.join(this_dir, '..', '..', 'src') >>> class node (object): ... def __init__(self, path): ... self.path = path @@ -28,7 +30,7 @@ def asymptote_scan(node, env, path, arg=None): ... def srcnode(self): ... return self >>> for p in asymptote_scan( - ... node('../../src/figures/cantilever-sim/v-dep.asy'), + ... node(os.path.join(src_dir, 'figures', 'cantilever-sim', 'v-dep.asy')), ... None, None, None): ... print p v-dep.d/v_dep_127_8 @@ -37,6 +39,12 @@ def asymptote_scan(node, env, path, arg=None): v-dep.d/v_dep_27_30 v-dep.d/v_dep_0.1_1 v-dep.d/v_dep_0.1_30 + v-dep.d/v_dep_127_8.fit.dat + v-dep.d/v_dep_27_8.fit.dat + v-dep.d/v_dep_127_30.fit.dat + v-dep.d/v_dep_27_30.fit.dat + v-dep.d/v_dep_0.1_1.fit.dat + v-dep.d/v_dep_0.1_30.fit.dat """ try: contents = node.get_text_contents() diff --git a/tex/site_cons/site_tools/gnuplot.py b/tex/site_cons/site_tools/gnuplot.py index bcb5b32..20bd3e7 100644 --- a/tex/site_cons/site_tools/gnuplot.py +++ b/tex/site_cons/site_tools/gnuplot.py @@ -10,6 +10,8 @@ quoted_string_re = re.compile(r"'([^']*)'", re.M) def gnuplot_scan(node, env, path, arg=None): """ + >>> this_dir = os.path.dirname(__file__) + >>> src_dir = os.path.join(this_dir, '..', '..', 'src') >>> class node (object): ... def __init__(self, path): ... self.path = path @@ -23,7 +25,7 @@ def gnuplot_scan(node, env, path, arg=None): ... def srcnode(self): ... return self >>> for p in gnuplot_scan( - ... node('../../src/figures/order-dep/fig.gp'), + ... node(os.path.join(src_dir, 'figures', 'order-dep', 'fig.gp')), ... None, None, None): ... print p data/order.avg-4