Ticket #14331: trac14331.patch

File trac14331.patch, 41.6 KB (added by ohanar, 9 years ago)

apply to sage library

  • sage/doctest/control.py

    # HG changeset patch
    # User R. Andrew Ohana <andrew.ohana@gmail.com>
    # Date 1363927839 25200
    # Node ID 329639839af2613fc3178b84f826ef86aa9c704a
    # Parent  aaca93123e55e14e4986569f08b1dc2a20178806
    remove explict references to SAGE_ROOT in the doctesting framework
    
    diff --git a/sage/doctest/control.py b/sage/doctest/control.py
    a b  
    3333    This class is used for doctesting the Sage doctest module.
    3434
    3535    It fills in attributes to be the same as the defaults defined in
    36     ``SAGE_ROOT/local/bin/sage-runtests``, expect for a few places,
     36    ``SAGE_LOCAL/bin/sage-runtests``, expect for a few places,
    3737    which is mostly to make doctesting more predictable.
    3838
    3939    EXAMPLES::
     
    126126
    127127        INPUT:
    128128
    129         - options -- either options generated from the command line by SAGE_ROOT/local/bin/sage-runtests
     129        - options -- either options generated from the command line by SAGE_LOCAL/bin/sage-runtests
    130130                     or a DocTestDefaults object (possibly with some entries modified)
    131131        - args -- a list of filenames to doctest
    132132
     
    335335        EXAMPLES::
    336336
    337337            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     338            sage: from sage.env import SAGE_SRC
    338339            sage: import os
    339340            sage: log_location = os.path.join(SAGE_TMP, 'control_dt_log.log')
    340341            sage: DD = DocTestDefaults(all=True, logfile=log_location)
    341342            sage: DC = DocTestController(DD, [])
    342343            sage: DC.add_files()
    343344            Doctesting entire Sage library.
    344             sage: os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage') in DC.files
     345            sage: os.path.join(SAGE_SRC, 'sage') in DC.files
    345346            True
    346347
    347348        ::
     
    363364            'sagenb'
    364365        """
    365366        opj = os.path.join
    366         SAGE_ROOT = os.environ['SAGE_ROOT']
    367         base = opj(SAGE_ROOT, 'devel', 'sage')
     367        from sage.env import SAGE_SRC as base
    368368        if self.options.all:
    369369            self.log("Doctesting entire Sage library.")
    370370            from glob import glob
     
    381381                if len(tup) != 2: continue
    382382                c, filename = tup
    383383                if c in ['M','A']:
    384                     filename = opj(os.environ['SAGE_ROOT'], 'devel', 'sage', filename)
     384                    filename = opj(base, filename)
    385385                    self.files.append(filename)
    386386        if self.options.sagenb:
    387387            if not self.options.all:
     
    400400        EXAMPLES::
    401401
    402402            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     403            sage: from sage.env import SAGE_SRC
    403404            sage: import os
    404             sage: dirname = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'doctest')
     405            sage: dirname = os.path.join(SAGE_SRC, 'sage', 'doctest')
    405406            sage: DD = DocTestDefaults(optional='all')
    406407            sage: DC = DocTestController(DD, [dirname])
    407408            sage: DC.expand_files_into_sources()
     
    452453
    453454    def filter_sources(self):
    454455        """
    455        
     456
    456457        EXAMPLES::
    457458
    458459            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     460            sage: from sage.env import SAGE_SRC
    459461            sage: import os
    460             sage: dirname = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'doctest')
     462            sage: dirname = os.path.join(SAGE_SRC, 'sage', 'doctest')
    461463            sage: DD = DocTestDefaults(failed=True)
    462464            sage: DC = DocTestController(DD, [dirname])
    463465            sage: DC.expand_files_into_sources()
     
    484486        EXAMPLES::
    485487
    486488            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     489            sage: from sage.env import SAGE_SRC
    487490            sage: import os
    488             sage: dirname = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'doctest')
     491            sage: dirname = os.path.join(SAGE_SRC, 'sage', 'doctest')
    489492            sage: DD = DocTestDefaults(nthreads=2)
    490493            sage: DC = DocTestController(DD, [dirname])
    491494            sage: DC.expand_files_into_sources()
     
    522525        EXAMPLES::
    523526
    524527            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     528            sage: from sage.env import SAGE_SRC
    525529            sage: import os
    526             sage: dirname = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'rings', 'homset.py')
     530            sage: dirname = os.path.join(SAGE_SRC, 'sage', 'rings', 'homset.py')
    527531            sage: DD = DocTestDefaults()
    528532            sage: DC = DocTestController(DD, [dirname])
    529533            sage: DC.expand_files_into_sources()
     
    588592
    589593        EXAMPLES::
    590594
    591              sage: from sage.doctest.control import DocTestDefaults, DocTestController
    592              sage: import os
    593              sage: dirname = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'rings', 'infinity.py')
    594              sage: DD = DocTestDefaults()
     595            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     596            sage: from sage.env import SAGE_SRC
     597            sage: import os
     598            sage: dirname = os.path.join(SAGE_SRC, 'sage', 'rings', 'infinity.py')
     599            sage: DD = DocTestDefaults()
    595600
    596              sage: DC = DocTestController(DD, [dirname])
    597              sage: DC.expand_files_into_sources()
    598              sage: DC.sources.sort(key=lambda s:s.basename)
     601            sage: DC = DocTestController(DD, [dirname])
     602            sage: DC.expand_files_into_sources()
     603            sage: DC.sources.sort(key=lambda s:s.basename)
    599604
    600              sage: for i, source in enumerate(DC.sources):
    601              ....:     DC.stats[source.basename] = {'walltime': 0.1*(i+1)}
    602              ....:
     605            sage: for i, source in enumerate(DC.sources):
     606            ....:     DC.stats[source.basename] = {'walltime': 0.1*(i+1)}
     607            ....:
    603608
    604              sage: DC.run()
    605              Running doctests with ID ...
    606              Doctesting 1 file.
    607              sage -t .../rings/infinity.py
    608                  [... tests, ... s]
    609              ----------------------------------------------------------------------
    610              All tests passed!
    611              ----------------------------------------------------------------------
    612              Total time for all tests: ... seconds
    613                  cpu time: ... seconds
    614                  cumulative wall time: ... seconds
    615              0
    616              sage: DC.cleanup()
     609            sage: DC.run()
     610            Running doctests with ID ...
     611            Doctesting 1 file.
     612            sage -t .../rings/infinity.py
     613                [... tests, ... s]
     614            ----------------------------------------------------------------------
     615            All tests passed!
     616            ----------------------------------------------------------------------
     617            Total time for all tests: ... seconds
     618                cpu time: ... seconds
     619                cumulative wall time: ... seconds
     620            0
     621            sage: DC.cleanup()
    617622        """
    618623        self.stats.update(self.reporter.stats)
    619624        self.save_stats(self.options.stats_path)
     
    756761        EXAMPLES::
    757762
    758763            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     764            sage: from sage.env import SAGE_SRC
    759765            sage: import os
    760766            sage: DD = DocTestDefaults()
    761             sage: filename = os.path.join(os.environ["SAGE_ROOT"], "devel", "sage", "sage", "sets", "non_negative_integers.py")
     767            sage: filename = os.path.join(SAGE_SRC, "sage", "sets", "non_negative_integers.py")
    762768            sage: DC = DocTestController(DD, [filename])
    763769            sage: DC.run()
    764770            Running doctests with ID ...
  • sage/doctest/forker.py

    diff --git a/sage/doctest/forker.py b/sage/doctest/forker.py
    a b  
    381381            sage: from sage.doctest.forker import SageDocTestRunner
    382382            sage: from sage.doctest.sources import FileDocTestSource
    383383            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     384            sage: from sage.env import SAGE_SRC
    384385            sage: import doctest, sys, os
    385386            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    386             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     387            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    387388            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    388389            sage: doctests, extras = FDS.create_doctests(globals())
    389390            sage: DTR.run(doctests[0], clear_globs=False) # indirect doctest
     
    556557            sage: from sage.doctest.forker import SageDocTestRunner
    557558            sage: from sage.doctest.sources import FileDocTestSource
    558559            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     560            sage: from sage.env import SAGE_SRC
    559561            sage: import doctest, sys, os
    560562            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    561             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     563            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    562564            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    563565            sage: doctests, extras = FDS.create_doctests(globals())
    564566            sage: DTR.run(doctests[0], clear_globs=False)
     
    700702            sage: from sage.doctest.forker import SageDocTestRunner
    701703            sage: from sage.doctest.sources import FileDocTestSource
    702704            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     705            sage: from sage.env import SAGE_SRC
    703706            sage: import doctest, sys, os, hashlib
    704707            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    705             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     708            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    706709            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    707710            sage: doctests, extras = FDS.create_doctests(globals())
    708711            sage: DTR.running_global_digest.hexdigest()
     
    757760            sage: from sage.doctest.sources import FileDocTestSource
    758761            sage: from sage.doctest.util import RecordingDict
    759762            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     763            sage: from sage.env import SAGE_SRC
    760764            sage: import doctest, sys, os, hashlib
    761765            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    762766            sage: DTR.running_doctest_digest = hashlib.md5()
    763             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     767            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    764768            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    765769            sage: globs = RecordingDict(globals())
    766770            sage: globs.has_key('doctest_var')
     
    847851            sage: from sage.doctest.forker import SageDocTestRunner
    848852            sage: from sage.doctest.sources import FileDocTestSource
    849853            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     854            sage: from sage.env import SAGE_SRC
    850855            sage: import doctest, sys, os
    851856            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    852             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     857            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    853858            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    854859            sage: doctests, extras = FDS.create_doctests(globals())
    855860            sage: ex = doctests[0].examples[0]
     
    895900            sage: from sage.doctest.forker import SageDocTestRunner
    896901            sage: from sage.doctest.sources import FileDocTestSource
    897902            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     903            sage: from sage.env import SAGE_SRC
    898904            sage: import doctest, sys, os
    899905            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=True, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    900             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     906            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    901907            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    902908            sage: doctests, extras = FDS.create_doctests(globals())
    903909            sage: ex = doctests[0].examples[0]
     
    942948            sage: from sage.doctest.sources import FileDocTestSource
    943949            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
    944950            sage: from sage.misc.misc import walltime
     951            sage: from sage.env import SAGE_SRC
    945952            sage: import doctest, sys, os
    946953            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=True, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    947             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     954            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    948955            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    949956            sage: doctests, extras = FDS.create_doctests(globals())
    950957            sage: ex = doctests[0].examples[0]
     
    982989            sage: from sage.doctest.forker import SageDocTestRunner
    983990            sage: from sage.doctest.sources import FileDocTestSource
    984991            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     992            sage: from sage.env import SAGE_SRC
    985993            sage: import doctest, sys, os
    986994            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=True, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    987             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     995            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    988996            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    989997            sage: doctests, extras = FDS.create_doctests(globals())
    990998            sage: ex = doctests[0].examples[0]
     
    10291037            sage: from sage.doctest.sources import FileDocTestSource
    10301038            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
    10311039            sage: from sage.misc.misc import walltime
     1040            sage: from sage.env import SAGE_SRC
    10321041            sage: import doctest, sys, os
    10331042            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=True, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    1034             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     1043            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    10351044            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    10361045            sage: doctests, extras = FDS.create_doctests(globals())
    10371046            sage: ex = doctests[0].examples[0]
     
    11471156            sage: from sage.doctest.forker import SageDocTestRunner
    11481157            sage: from sage.doctest.sources import FileDocTestSource, DictAsObject
    11491158            sage: from sage.doctest.control import DocTestDefaults; DD = DocTestDefaults()
     1159            sage: from sage.env import SAGE_SRC
    11501160            sage: import doctest, sys, os
    11511161            sage: DTR = SageDocTestRunner(SageOutputChecker(), verbose=False, sage_options=DD, optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS)
    1152             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     1162            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    11531163            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    11541164            sage: doctests, extras = FDS.create_doctests(globals())
    11551165            sage: from sage.doctest.util import Timer
     
    12241234            sage: from sage.doctest.forker import DocTestDispatcher
    12251235            sage: from sage.doctest.reporting import DocTestReporter
    12261236            sage: from sage.doctest.util import Timer
     1237            sage: from sage.env import SAGE_SRC
    12271238            sage: import os
    1228             sage: homset = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'rings', 'homset.py')
    1229             sage: ideal = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'rings', 'ideal.py')
     1239            sage: homset = os.path.join(SAGE_SRC, 'sage', 'rings', 'homset.py')
     1240            sage: ideal = os.path.join(SAGE_SRC, 'sage', 'rings', 'ideal.py')
    12301241            sage: DC = DocTestController(DocTestDefaults(), [homset, ideal])
    12311242            sage: DC.expand_files_into_sources()
    12321243            sage: DD = DocTestDispatcher(DC)
     
    12621273            sage: from sage.doctest.forker import DocTestDispatcher
    12631274            sage: from sage.doctest.reporting import DocTestReporter
    12641275            sage: from sage.doctest.util import Timer
     1276            sage: from sage.env import SAGE_SRC
    12651277            sage: import os
    1266             sage: crem = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'databases', 'cremona.py')
    1267             sage: bigo = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'rings', 'big_oh.py')
     1278            sage: crem = os.path.join(SAGE_SRC, 'sage', 'databases', 'cremona.py')
     1279            sage: bigo = os.path.join(SAGE_SRC, 'sage', 'rings', 'big_oh.py')
    12681280            sage: DC = DocTestController(DocTestDefaults(), [crem, bigo])
    12691281            sage: DC.expand_files_into_sources()
    12701282            sage: DD = DocTestDispatcher(DC)
     
    15081520            sage: from sage.doctest.forker import DocTestDispatcher
    15091521            sage: from sage.doctest.reporting import DocTestReporter
    15101522            sage: from sage.doctest.util import Timer
     1523            sage: from sage.env import SAGE_SRC
    15111524            sage: import os
    1512             sage: freehom = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'modules', 'free_module_homspace.py')
    1513             sage: bigo = os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage', 'sage', 'rings', 'big_oh.py')
     1525            sage: freehom = os.path.join(SAGE_SRC, 'sage', 'modules', 'free_module_homspace.py')
     1526            sage: bigo = os.path.join(SAGE_SRC, 'sage', 'rings', 'big_oh.py')
    15141527            sage: DC = DocTestController(DocTestDefaults(), [freehom, bigo])
    15151528            sage: DC.expand_files_into_sources()
    15161529            sage: DD = DocTestDispatcher(DC)
     
    15601573        sage: from sage.doctest.sources import FileDocTestSource
    15611574        sage: from sage.doctest.reporting import DocTestReporter
    15621575        sage: from sage.doctest.control import DocTestController, DocTestDefaults
    1563         sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1576        sage: from sage.env import SAGE_SRC
     1577        sage: filename = os.path.join(SAGE_SRC,'sage','doctest','util.py')
    15641578        sage: DD = DocTestDefaults()
    15651579        sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    15661580        sage: W = DocTestWorker(FDS, DD)
     
    16811695            sage: from sage.doctest.sources import FileDocTestSource
    16821696            sage: from sage.doctest.reporting import DocTestReporter
    16831697            sage: from sage.doctest.control import DocTestController, DocTestDefaults
    1684             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1698            sage: from sage.env import SAGE_SRC
     1699            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','util.py')
    16851700            sage: DD = DocTestDefaults()
    16861701            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    16871702            sage: W = DocTestWorker(FDS, DD)
     
    17201735            sage: from sage.doctest.sources import FileDocTestSource
    17211736            sage: from sage.doctest.reporting import DocTestReporter
    17221737            sage: from sage.doctest.control import DocTestController, DocTestDefaults
    1723             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1738            sage: from sage.env import SAGE_SRC
     1739            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','util.py')
    17241740            sage: DD = DocTestDefaults(verbose=True,nthreads=2)
    17251741            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    17261742            sage: W = DocTestWorker(FDS, DD)
     
    17541770            sage: from sage.doctest.sources import FileDocTestSource
    17551771            sage: from sage.doctest.reporting import DocTestReporter
    17561772            sage: from sage.doctest.control import DocTestController, DocTestDefaults
    1757             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     1773            sage: from sage.env import SAGE_SRC
     1774            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','util.py')
    17581775            sage: DD = DocTestDefaults()
    17591776            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    17601777            sage: W = DocTestWorker(FDS, DD)
     
    17901807            sage: from sage.doctest.sources import FileDocTestSource
    17911808            sage: from sage.doctest.reporting import DocTestReporter
    17921809            sage: from sage.doctest.control import DocTestController, DocTestDefaults
    1793             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','tests','99seconds.rst')
     1810            sage: from sage.env import SAGE_SRC
     1811            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','tests','99seconds.rst')
    17941812            sage: DD = DocTestDefaults()
    17951813            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    17961814
     
    18441862        sage: from sage.doctest.forker import DocTestTask
    18451863        sage: from sage.doctest.sources import FileDocTestSource
    18461864        sage: from sage.doctest.control import DocTestDefaults, DocTestController
     1865        sage: from sage.env import SAGE_SRC
    18471866        sage: import os
    1848         sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     1867        sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    18491868        sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    18501869        sage: DTT = DocTestTask(FDS)
    18511870        sage: DD = DocTestDefaults()
    18521871        sage: DC = DocTestController(DD,[filename])
    18531872        sage: ntests, results = DTT(options=DD)
    18541873        sage: ntests
    1855         275
     1874        292
    18561875        sage: sorted(results.keys())
    18571876        ['cputime', 'err', 'failures', 'walltime']
    18581877    """
     
    18641883
    18651884            sage: from sage.doctest.forker import DocTestTask
    18661885            sage: from sage.doctest.sources import FileDocTestSource
     1886            sage: from sage.env import SAGE_SRC
    18671887            sage: import os
    1868             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     1888            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    18691889            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    18701890            sage: DocTestTask(FDS)
    18711891            <sage.doctest.forker.DocTestTask object at ...>
     
    19031923            sage: from sage.doctest.forker import DocTestTask
    19041924            sage: from sage.doctest.sources import FileDocTestSource
    19051925            sage: from sage.doctest.control import DocTestDefaults, DocTestController
     1926            sage: from sage.env import SAGE_SRC
    19061927            sage: import os
    1907             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','parsing.py')
     1928            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','parsing.py')
    19081929            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    19091930            sage: DTT = DocTestTask(FDS)
    19101931            sage: DD = DocTestDefaults()
     
    19131934            sage: runner.failures
    19141935            0
    19151936            sage: ntests
    1916             202
     1937            206
    19171938        """
    19181939        result = None
    19191940        try:
  • sage/doctest/parsing.py

    diff --git a/sage/doctest/parsing.py b/sage/doctest/parsing.py
    a b  
    275275    EXAMPLES::
    276276
    277277        sage: from sage.doctest.sources import FileDocTestSource
     278        sage: from sage.env import SAGE_SRC
    278279        sage: import os
    279         sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     280        sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    280281        sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    281282        sage: doctests, extras = FDS.create_doctests(globals())
    282283        sage: ex = doctests[0].examples[0]
     
    300301        EXAMPLES::
    301302
    302303            sage: from sage.doctest.sources import FileDocTestSource
     304            sage: from sage.env import SAGE_SRC
    303305            sage: import os
    304             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     306            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    305307            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    306308            sage: doctests, extras = FDS.create_doctests(globals())
    307309            sage: ex = doctests[0].examples[0]
     
    316318        EXAMPLES::
    317319
    318320            sage: from sage.doctest.sources import FileDocTestSource
     321            sage: from sage.env import SAGE_SRC
    319322            sage: import os
    320             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     323            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    321324            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    322325            sage: doctests, extras = FDS.create_doctests(globals())
    323326            sage: ex = doctests[0].examples[0]
     
    335338        EXAMPLES::
    336339
    337340            sage: from sage.doctest.sources import FileDocTestSource
     341            sage: from sage.env import SAGE_SRC
    338342            sage: import os
    339             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','forker.py')
     343            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','forker.py')
    340344            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    341345            sage: doctests, extras = FDS.create_doctests(globals())
    342346            sage: ex = doctests[0].examples[0]
  • sage/doctest/reporting.py

    diff --git a/sage/doctest/reporting.py b/sage/doctest/reporting.py
    a b  
    9797
    9898            sage: from sage.doctest.reporting import DocTestReporter
    9999            sage: from sage.doctest.control import DocTestController, DocTestDefaults
     100            sage: from sage.env import SAGE_SRC
    100101            sage: import os
    101             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','reporting.py')
     102            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','reporting.py')
    102103            sage: DC = DocTestController(DocTestDefaults(),[filename])
    103104            sage: DTR = DocTestReporter(DC)
    104105        """
     
    122123            sage: from sage.doctest.control import DocTestController, DocTestDefaults
    123124            sage: from sage.doctest.sources import FileDocTestSource
    124125            sage: from sage.doctest.forker import SageDocTestRunner
    125             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','reporting.py')
     126            sage: from sage.env import SAGE_SRC
     127            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','reporting.py')
    126128            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    127129            sage: DD = DocTestDefaults()
    128130            sage: DC = DocTestController(DD, [filename])
     
    183185            sage: from sage.doctest.forker import SageDocTestRunner
    184186            sage: from sage.doctest.parsing import SageOutputChecker
    185187            sage: from sage.doctest.util import Timer
     188            sage: from sage.env import SAGE_SRC
    186189            sage: import os, sys, doctest
    187             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','reporting.py')
     190            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','reporting.py')
    188191            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    189192            sage: DD = DocTestDefaults()
    190193            sage: DC = DocTestController(DD,[filename])
     
    397400            sage: from sage.doctest.forker import SageDocTestRunner
    398401            sage: from sage.doctest.parsing import SageOutputChecker
    399402            sage: from sage.doctest.util import Timer
     403            sage: from sage.env import SAGE_SRC
    400404            sage: import os, sys, doctest
    401             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','reporting.py')
     405            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','reporting.py')
    402406            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    403407            sage: DD = DocTestDefaults()
    404408            sage: DC = DocTestController(DD,[filename])
  • sage/doctest/sources.py

    diff --git a/sage/doctest/sources.py b/sage/doctest/sources.py
    a b  
    2424from parsing import SageDocTestParser
    2525from util import NestedName
    2626from sage.structure.dynamic_class import dynamic_class
     27from sage.env import SAGE_SRC, SAGE_LOCAL
    2728
    2829# Python file parsing
    2930triple_quotes = re.compile("\s*[rRuU]*((''')|(\"\"\"))")
     
    5758    EXAMPLES::
    5859
    5960        sage: from sage.doctest.sources import get_basename
     61        sage: from sage.env import SAGE_SRC
    6062        sage: import os
    61         sage: get_basename(os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py'))
     63        sage: get_basename(os.path.join(SAGE_SRC,'sage','doctest','sources.py'))
    6264        'sage.doctest.sources'
    6365    """
    6466    if path is None:
     
    6971    root = os.path.dirname(path)
    7072    # If the file is in the sage library, we can use our knowledge of
    7173    # the directory structure
    72     sage_root = os.environ['SAGE_ROOT']
    73     dev = os.path.join(sage_root, 'devel', 'sage')
    74     sp = os.path.join(sage_root, 'local', 'lib', 'python', 'site-packages')
     74    dev = SAGE_SRC
     75    sp = os.path.join(SAGE_LOCAL, 'lib', 'python', 'site-packages')
    7576    if path.startswith(dev):
    7677        # there will be a branch name
    7778        i = path.find(os.path.sep, len(dev))
     
    111112        EXAMPLES::
    112113
    113114            sage: from sage.doctest.sources import FileDocTestSource
     115            sage: from sage.env import SAGE_SRC
    114116            sage: import os
    115             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     117            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    116118            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),0)
    117119            sage: TestSuite(FDS).run()
    118120        """
     
    127129        EXAMPLES::
    128130
    129131            sage: from sage.doctest.sources import FileDocTestSource
     132            sage: from sage.env import SAGE_SRC
    130133            sage: import os
    131             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     134            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    132135            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),0)
    133136            sage: FDS2 = FileDocTestSource(filename,True,False,set(['sage']),0)
    134137            sage: FDS == FDS2
     
    166169
    167170            sage: from sage.doctest.sources import FileDocTestSource
    168171            sage: from sage.doctest.parsing import SageDocTestParser
     172            sage: from sage.env import SAGE_SRC
    169173            sage: import os
    170             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     174            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','util.py')
    171175            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    172176            sage: doctests, _ = FDS.create_doctests({})
    173177            sage: manual_doctests = []
     
    215219
    216220            sage: from sage.doctest.sources import FileDocTestSource
    217221            sage: from sage.doctest.util import NestedName
     222            sage: from sage.env import SAGE_SRC
    218223            sage: import os
    219             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     224            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    220225            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    221226            sage: FDS.qualified_name = NestedName('sage.doctest.sources')
    222227            sage: doctests, extras = FDS._create_doctests({})
     
    430435    EXAMPLES::
    431436
    432437        sage: from sage.doctest.sources import FileDocTestSource
     438        sage: from sage.env import SAGE_SRC
    433439        sage: import os
    434         sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     440        sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    435441        sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    436442        sage: FDS.basename
    437443        'sage.doctest.sources'
     
    447453        EXAMPLES::
    448454
    449455            sage: from sage.doctest.sources import FileDocTestSource
     456            sage: from sage.env import SAGE_SRC
    450457            sage: import os
    451             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     458            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    452459            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),0)
    453460            sage: FDS.randorder
    454461            0
     
    495502        EXAMPLES::
    496503
    497504            sage: from sage.doctest.sources import FileDocTestSource
     505            sage: from sage.env import SAGE_SRC
    498506            sage: import os
    499             sage: br = os.readlink(os.path.join(os.environ['SAGE_ROOT'], 'devel', 'sage'))
    500             sage: root = os.path.join(os.environ['SAGE_ROOT'],'devel',br,'sage')
     507            sage: root = os.path.realpath(os.path.join(SAGE_SRC,'sage'))
    501508            sage: filename = os.path.join(root,'doctest','sources.py')
    502509            sage: cwd = os.getcwd()
    503510            sage: os.chdir(root)
     
    526533        EXAMPLES::
    527534
    528535            sage: from sage.doctest.sources import FileDocTestSource
     536            sage: from sage.env import SAGE_SRC
    529537            sage: import os
    530             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','rings','integer.pyx')
     538            sage: filename = os.path.join(SAGE_SRC,'sage','rings','integer.pyx')
    531539            sage: FDS = FileDocTestSource(filename,False,False,set(['sage']),None)
    532540            sage: FDS.basename
    533541            'sage.rings.integer'
     
    544552        EXAMPLES::
    545553
    546554            sage: from sage.doctest.sources import FileDocTestSource
     555            sage: from sage.env import SAGE_SRC
    547556            sage: import os
    548             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','rings','integer.pyx')
     557            sage: filename = os.path.join(SAGE_SRC,'sage','rings','integer.pyx')
    549558            sage: FDS = FileDocTestSource(filename,False,False,set(['sage']),None)
    550559            sage: FDS.in_lib
    551560            True
     
    579588        EXAMPLES::
    580589
    581590            sage: from sage.doctest.sources import FileDocTestSource
     591            sage: from sage.env import SAGE_SRC
    582592            sage: import os
    583             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     593            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    584594            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    585595            sage: doctests, extras = FDS.create_doctests(globals())
    586596            sage: len(doctests)
     
    592602
    593603            sage: doctests[17].name
    594604            'sage.doctest.sources.FileDocTestSource.create_doctests'
    595             sage: doctests[17].examples[8].source
    596             'doctests[Integer(17)].examples[Integer(8)].source\n'
     605            sage: doctests[17].examples[9].source
     606            'doctests[Integer(17)].examples[Integer(9)].source\n'
    597607
    598608        TESTS:
    599609
     
    605615            sage: n = -920390823904823094890238490238484; hash(n) > 0
    606616            False # 32-bit
    607617            True  # 64-bit
    608             sage: ex = doctests[17].examples[11]
     618            sage: ex = doctests[17].examples[12]
    609619            sage: (bitness == '64' and ex.want == 'True  \n') or (bitness == '32' and ex.want == 'False \n')
    610620            True
    611621
     
    648658        TESTS::
    649659
    650660            sage: from sage.doctest.sources import FileDocTestSource
     661            sage: from sage.env import SAGE_SRC
    651662            sage: cwd = os.getcwd()
    652             sage: os.chdir(os.path.join(os.environ['SAGE_ROOT'],'devel','sage'))
     663            sage: os.chdir(SAGE_SRC)
    653664            sage: import itertools
    654665            sage: for path, dirs, files in itertools.chain(os.walk('sage'), os.walk('doc')): # long time
    655666            ....:     path = os.path.relpath(path)
     
    754765            sage: from sage.doctest.sources import FileDocTestSource
    755766            sage: from sage.doctest.parsing import SageDocTestParser
    756767            sage: from sage.doctest.util import NestedName
     768            sage: from sage.env import SAGE_SRC
    757769            sage: import os
    758             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','util.py')
     770            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','util.py')
    759771            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    760772            sage: doctests, _ = FDS.create_doctests({})
    761773            sage: for dt in doctests:
     
    773785    EXAMPLES::
    774786
    775787        sage: from sage.doctest.sources import FileDocTestSource
     788        sage: from sage.env import SAGE_SRC
    776789        sage: import os
    777         sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     790        sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    778791        sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    779792        sage: type(FDS)
    780793        <class 'sage.doctest.sources.PythonFileSource'>
     
    789802        EXAMPLES::
    790803
    791804            sage: from sage.doctest.sources import FileDocTestSource
     805            sage: from sage.env import SAGE_SRC
    792806            sage: import os
    793             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     807            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    794808            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    795809            sage: FDS._init()
    796810            sage: FDS.last_indent
     
    824838        EXAMPLES::
    825839
    826840            sage: from sage.doctest.sources import FileDocTestSource
     841            sage: from sage.env import SAGE_SRC
    827842            sage: import os
    828             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     843            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    829844            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    830845            sage: FDS._init()
    831846            sage: FDS._update_quotetype('\"\"\"'); print " ".join(list(FDS.quotetype))
     
    919934
    920935            sage: from sage.doctest.sources import FileDocTestSource
    921936            sage: from sage.doctest.util import NestedName
     937            sage: from sage.env import SAGE_SRC
    922938            sage: import os
    923             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     939            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    924940            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    925941            sage: FDS._init()
    926942            sage: FDS.starting_docstring("r'''")
     
    983999
    9841000            sage: from sage.doctest.sources import FileDocTestSource
    9851001            sage: from sage.doctest.util import NestedName
     1002            sage: from sage.env import SAGE_SRC
    9861003            sage: import os
    987             sage: filename = os.path.join(os.environ['SAGE_ROOT'],'devel','sage','sage','doctest','sources.py')
     1004            sage: filename = os.path.join(SAGE_SRC,'sage','doctest','sources.py')
    9881005            sage: FDS = FileDocTestSource(filename,True,False,set(['sage']),None)
    9891006            sage: FDS._init()
    9901007            sage: FDS.quotetype = "'''"
  • sage/doctest/test.py

    diff --git a/sage/doctest/test.py b/sage/doctest/test.py
    a b  
    99    sage: import signal
    1010    sage: import subprocess
    1111    sage: import time
    12     sage: tests_dir = os.path.join(SAGE_ROOT, 'devel', 'sage', 'sage', 'doctest', 'tests')
     12    sage: from sage.env import SAGE_SRC
     13    sage: tests_dir = os.path.join(SAGE_SRC, 'sage', 'doctest', 'tests')
    1314
    1415Check that :trac:`2235` has been fixed::
    1516