Ticket #1329: 1329.diff

File 1329.diff, 25.8 KB (added by zooko, at 2011-01-18T07:26:18Z)
  • Makefile

    diff -rN -u old-ticket1329/Makefile new-ticket1329/Makefile
    old new  
    179179
    180180
    181181pyflakes:
    182         $(PYTHON) -OOu `which pyflakes` src/allmydata |sort |uniq
     182        $(PYTHON) -OOu `which pyflakes` src/allmydata static |sort |uniq
    183183check-umids:
    184184        $(PYTHON) misc/coding_tools/check-umids.py `find src/allmydata -name '*.py'`
    185185
  • src/allmydata/__init__.py

    diff -rN -u old-ticket1329/src/allmydata/__init__.py new-ticket1329/src/allmydata/__init__.py
    old new  
    44community web site: U{http://tahoe-lafs.org/}
    55"""
    66
    7 # We want to call require_auto_deps() before other imports, because the setuptools
    8 # docs claim that if a distribution is installed with --multi-version, it might not
    9 # be importable until after pkg_resources.require() has been called for it. We don't
    10 # have an example of this happening at this time. It is possible that require() isn't
    11 # actually needed because we set __requires__ in the generated startup script, but
    12 # that would be an undocumented property of the setuptools implementation.
    13 
    14 from allmydata import _auto_deps
    15 _auto_deps.require_auto_deps()
    16 
    17 # This is just to suppress DeprecationWarnings from nevow and twisted.
    18 # See http://allmydata.org/trac/tahoe/ticket/859 and
    19 # http://divmod.org/trac/ticket/2994 .
    20 import warnings
    21 warnings.filterwarnings("ignore", category=DeprecationWarning,
    22     message="the sha module is deprecated; use the hashlib module instead",
    23     append=True)
    24 warnings.filterwarnings("ignore", category=DeprecationWarning,
    25     message="object.__new__\(\) takes no parameters",
    26     append=True)
    27 warnings.filterwarnings("ignore", category=DeprecationWarning,
    28     message="The popen2 module is deprecated.  Use the subprocess module.",
    29     append=True)
    30 warnings.filterwarnings("ignore", category=DeprecationWarning,
    31     message="the md5 module is deprecated; use hashlib instead",
    32     append=True)
    33 warnings.filterwarnings("ignore", category=DeprecationWarning,
    34     message="twisted.web.error.NoResource is deprecated since Twisted 9.0.  See twisted.web.resource.NoResource.",
    35     append=True)
    36 try:
    37     import nevow
    38     from twisted.persisted import sob
    39     from twisted.python import filepath
    40     hush_pyflakes = (nevow, sob, filepath)
    41     del hush_pyflakes
    42 finally:
    43     warnings.filters.pop()
    44     warnings.filters.pop()
    45     warnings.filters.pop()
    46     warnings.filters.pop()
    47     # Don't pop the filter for the sha module warning because it is also generated
    48     # by pycrypto (which we don't want to import unless needed).
    49     # warnings.filters.pop()
    50 
    51 # This warning is generated by twisted, PyRex, and possibly other packages,
    52 # but can happen at any time, not only when they are imported. See
    53 # http://tahoe-lafs.org/trac/tahoe-lafs/ticket/1129 .
    54 warnings.filterwarnings("ignore", category=DeprecationWarning,
    55     message="BaseException.message has been deprecated as of Python 2.6",
    56     append=True)
    57 
    587__version__ = "unknown"
    598try:
    609    from allmydata._version import __version__
     
    175124    else:
    176125        return platform.platform()
    177126
    178 def get_package_versions_from_setuptools():
    179     import pkg_resources
    180     return dict([(p.project_name, (p.version, p.location)) for p in pkg_resources.require(__appname__)])
    181 
    182 def package_dir(srcfile):
    183     return os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
    184 
    185 def get_package_versions_and_locations():
    186     # because there are a few dependencies that are outside setuptools's ken
    187     # (Python and platform, and sqlite3 if you are on Python >= 2.5), and
    188     # because setuptools might fail to find something even though import
    189     # finds it:
    190     import OpenSSL, allmydata, foolscap.api, nevow, platform, pycryptopp, setuptools, simplejson, twisted, zfec, zope.interface
    191     pysqlitever = None
    192     pysqlitefile = None
    193     sqlitever = None
    194     try:
    195         import sqlite3
    196     except ImportError:
    197         try:
    198             from pysqlite2 import dbapi2
    199         except ImportError:
    200             pass
    201         else:
    202             pysqlitever = dbapi2.version
    203             pysqlitefile = package_dir(dbapi2.__file__)
    204             sqlitever = dbapi2.sqlite_version
    205     else:
    206         pysqlitever = sqlite3.version
    207         pysqlitefile = package_dir(sqlite3.__file__)
    208         sqlitever = sqlite3.sqlite_version
    209 
    210     d1 = {
    211         'pyOpenSSL': (OpenSSL.__version__, package_dir(OpenSSL.__file__)),
    212         __appname__: (allmydata.__version__, package_dir(allmydata.__file__)),
    213         'foolscap': (foolscap.api.__version__, package_dir(foolscap.__file__)),
    214         'Nevow': (nevow.__version__, package_dir(nevow.__file__)),
    215         'pycryptopp': (pycryptopp.__version__, package_dir(pycryptopp.__file__)),
    216         'setuptools': (setuptools.__version__, package_dir(setuptools.__file__)),
    217         'simplejson': (simplejson.__version__, package_dir(simplejson.__file__)),
    218         'pysqlite': (pysqlitever, pysqlitefile),
    219         'sqlite': (sqlitever, 'unknown'),
    220         'zope.interface': ('unknown', package_dir(zope.interface.__file__)),
    221         'Twisted': (twisted.__version__, package_dir(twisted.__file__)),
    222         'zfec': (zfec.__version__, package_dir(zfec.__file__)),
    223         'python': (platform.python_version(), sys.executable),
    224         'platform': (get_platform(), None),
    225         }
    226127
    227     # But we prefer to get all the dependencies as known by setuptools:
    228     import pkg_resources
    229     try:
    230         d2 = get_package_versions_from_setuptools()
    231     except pkg_resources.DistributionNotFound:
    232         # See docstring in _auto_deps.require_auto_deps() to explain why it makes sense to ignore this exception.
    233         pass
     128from allmydata._auto_deps import get_package_versions_and_locations
     129
     130_vers_and_locs = get_package_versions_and_locations()
     131_vers_and_locs['platform'] = (get_platform(), None)
     132
     133
     134def check_all_requirements():
     135    import platform
     136    from distutils.version import LooseVersion
     137    from allmydata._auto_deps import install_requires
     138
     139    # we require 2.4.4 on non-UCS-2, non-Redhat builds to avoid <http://www.python.org/news/security/PSF-2006-001/>
     140    # we require 2.4.3 on non-UCS-2 Redhat, because 2.4.3 is common on Redhat-based distros and will have patched the above bug
     141    # we require at least 2.4.2 in any case to avoid a bug in the base64 module: <http://bugs.python.org/issue1171487>
     142    if sys.maxunicode == 65535:
     143        if sys.version_info < (2, 4, 2) or sys.version_info[0] > 2:
     144            raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.2 or greater "
     145                                      "for a UCS-2 build (but less than v3), not %r" %
     146                                      (sys.version_info,))
     147    elif platform.platform().lower().find('redhat') >= 0:
     148        if sys.version_info < (2, 4, 3) or sys.version_info[0] > 2:
     149            raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.3 or greater "
     150                                      "on Redhat-based distributions (but less than v3), not %r" %
     151                                      (sys.version_info,))
    234152    else:
    235         d1.update(d2)
     153        if sys.version_info < (2, 4, 4) or sys.version_info[0] > 2:
     154            raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.4 or greater "
     155                                      "for a non-UCS-2 build (but less than v3), not %r" %
     156                                      (sys.version_info,))
     157
     158    def check_requirement(req):
     159        # We only support a single >= or ==.
     160        def _check(s, ok, relation):
     161            name = s[0].strip(' ').partition('[')[0]
     162            required = s[1].strip(' ')
     163            if name not in _vers_and_locs:
     164                raise AssertionError("no version info for %s" % (name,))
     165            (actual, location) = _vers_and_locs[name]
     166            actual = str(actual)
     167            if actual != 'unknown' and not ok(LooseVersion(actual), LooseVersion(required)):
     168                msg = ("We require %s version %s of %s, but could only find version %s.\n"
     169                      % (relation, required, name, actual))
     170                if location and location != 'unknown':
     171                    msg += "The version we found is from %r.\n" % (location,)
     172                msg += ("To resolve this problem, uninstall that version, either using your\n"
     173                        "operating system's package manager or by moving aside the directory.")
     174                raise AssertionError(msg)
     175
     176        s = req.split('>=')
     177        if len(s) == 2:
     178            _check(s, lambda x, y: x >= y, "at least")
     179            return
     180        s = req.split('==')
     181        if len(s) == 2:
     182            _check(s, lambda x, y: x == y, "exactly")
     183            return
     184        if req not in _vers_and_locs:
     185            raise AssertionError("no version info or could not understand requirement for %r" % (req))
     186
     187    for requirement in install_requires:
     188        check_requirement(requirement)
     189
     190check_all_requirements()
    236191
    237     return d1
    238192
    239193def get_package_versions():
    240     return dict([(k, v) for k, (v, l) in get_package_versions_and_locations().iteritems()])
     194    return dict([(k, v) for k, (v, l) in _vers_and_locs.iteritems()])
    241195
    242196def get_package_locations():
    243     return dict([(k, l) for k, (v, l) in get_package_versions_and_locations().iteritems()])
     197    return dict([(k, l) for k, (v, l) in _vers_and_locs.iteritems()])
    244198
    245199def get_package_versions_string(show_paths=False):
    246     vers_and_locs = get_package_versions_and_locations()
    247200    res = []
    248     for p in [__appname__, "foolscap", "pycryptopp", "zfec", "Twisted", "Nevow", "zope.interface", "python", "platform"]:
    249         (ver, loc) = vers_and_locs.get(p, ('UNKNOWN', 'UNKNOWN'))
     201    first = [__appname__, "foolscap", "pycryptopp", "zfec", "Twisted", "Nevow", "zope.interface", "python", "platform"]
     202    for p in first:
     203        (ver, loc) = _vers_and_locs.get(p, ('UNKNOWN', 'UNKNOWN'))
    250204        info = str(p) + ": " + str(ver)
    251205        if show_paths:
    252206            info = info + " (%s)" % str(loc)
    253207        res.append(info)
    254         if vers_and_locs.has_key(p):
    255             del vers_and_locs[p]
    256208
    257     for p, (v, loc) in vers_and_locs.iteritems():
    258         info = str(p) + ": " + str(v)
    259         if show_paths:
    260             info = info + " (%s)" % str(loc)
    261         res.append(info)
     209    for p, (v, loc) in _vers_and_locs.iteritems():
     210        if p not in first:
     211            info = str(p) + ": " + str(v)
     212            if show_paths:
     213                info = info + " (%s)" % str(loc)
     214            res.append(info)
     215
    262216    return ', '.join(res)
  • src/allmydata/_auto_deps.py

    diff -rN -u old-ticket1329/src/allmydata/_auto_deps.py new-ticket1329/src/allmydata/_auto_deps.py
    old new  
    11# Note: do not import any module from Tahoe-LAFS itself in this
    22# file. Also please avoid importing modules from other packages than
    3 # the Python Standard Library if at all possible (exception: we rely
    4 # on importing pkg_resources, which is provided by setuptools,
    5 # zetuptoolz, distribute, and perhaps in the future distutils2, for
    6 # the require_auto_deps() function.)
     3# the Python Standard Library if at all possible. That includes
     4# setuptools and pkg_resources.
     5
     6# If you add or remove dependencies, please remember to update
     7# get_package_versions_and_locations() below.
    78
    89install_requires=[
    910                  # we require newer versions of setuptools (actually
     
    2728
    2829                  # Needed for SFTP. pyasn1 is needed by twisted.conch in Twisted >= 9.0.
    2930                  # pycrypto 2.2 doesn't work due to https://bugs.launchpad.net/pycrypto/+bug/620253
    30                   "pycrypto == 2.0.1, == 2.1, >= 2.3",
     31                  "pycrypto >= 2.3",
    3132                  "pyasn1 >= 0.0.8a",
    3233
    3334                  # Will be needed to test web apps, but not yet. See #1001.
     
    7475    install_requires=[]
    7576del sys # clean up namespace
    7677
    77 def require_python_version():
    78     import sys, platform
    7978
    80     # we require 2.4.4 on non-UCS-2, non-Redhat builds to avoid <http://www.python.org/news/security/PSF-2006-001/>
    81     # we require 2.4.3 on non-UCS-2 Redhat, because 2.4.3 is common on Redhat-based distros and will have patched the above bug
    82     # we require at least 2.4.2 in any case to avoid a bug in the base64 module: <http://bugs.python.org/issue1171487>
    83     if sys.maxunicode == 65535:
    84         if sys.version_info < (2, 4, 2) or sys.version_info[0] > 2:
    85             raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.2 or greater "
    86                                       "for a UCS-2 build (but less than v3), not %r" %
    87                                       (sys.version_info,))
    88     elif platform.platform().lower().find('redhat') >= 0:
    89         if sys.version_info < (2, 4, 3) or sys.version_info[0] > 2:
    90             raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.3 or greater "
    91                                       "on Redhat-based distributions (but less than v3), not %r" %
    92                                       (sys.version_info,))
     79def get_package_versions_and_locations():
     80    import warnings, os, sys
     81    def package_dir(srcfile):
     82        return os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
     83
     84    # pkg_resources.require returns the distribution that pkg_resources attempted to put
     85    # on sys.path, which can differ from the one that we actually import due to #1258,
     86    # or any other bug that causes sys.path to be set up incorrectly. Therefore we
     87    # must import the packages in order to check their versions and paths. Note that
     88    # this needs to be updated if dependencies are added or removed.
     89
     90    # This warning is generated by twisted, PyRex, and possibly other packages,
     91    # but can happen at any time, not only when they are imported. See
     92    # http://tahoe-lafs.org/trac/tahoe-lafs/ticket/1129 .
     93    warnings.filterwarnings("ignore", category=DeprecationWarning,
     94        message="BaseException.message has been deprecated as of Python 2.6",
     95        append=True)
     96
     97    # This is to suppress DeprecationWarnings from nevow, twisted, and pycrypto.
     98    # See http://allmydata.org/trac/tahoe/ticket/859 and
     99    # http://divmod.org/trac/ticket/2994 .
     100    warnings.filterwarnings("ignore", category=DeprecationWarning,
     101        message="the sha module is deprecated; use the hashlib module instead",
     102        append=True)
     103    warnings.filterwarnings("ignore", category=DeprecationWarning,
     104        message="object.__new__\(\) takes no parameters",
     105        append=True)
     106    warnings.filterwarnings("ignore", category=DeprecationWarning,
     107        message="The popen2 module is deprecated.  Use the subprocess module.",
     108        append=True)
     109    warnings.filterwarnings("ignore", category=DeprecationWarning,
     110        message="the md5 module is deprecated; use hashlib instead",
     111        append=True)
     112    warnings.filterwarnings("ignore", category=DeprecationWarning,
     113        message="twisted.web.error.NoResource is deprecated since Twisted 9.0.  See twisted.web.resource.NoResource.",
     114        append=True)
     115    warnings.filterwarnings("ignore", category=DeprecationWarning,
     116        message="the sets module is deprecated",
     117        append=True)
     118    try:
     119        import nevow
     120        from twisted.persisted import sob
     121        from twisted.python import filepath
     122        import Crypto
     123        import foolscap.api
     124        [sob, filepath]  # hush pyflakes
     125    finally:
     126        for n in range(6):
     127            warnings.filters.pop()
     128
     129    import OpenSSL, allmydata, platform, pycryptopp, simplejson, twisted, zfec, zope.interface, pyasn1, mock
     130    pysqlitever = None
     131    pysqlitefile = None
     132    sqlitever = None
     133    try:
     134        import sqlite3
     135    except ImportError:
     136        try:
     137            from pysqlite2 import dbapi2
     138        except ImportError:
     139            pass
     140        else:
     141            pysqlitever = dbapi2.version
     142            pysqlitefile = package_dir(dbapi2.__file__)
     143            sqlitever = dbapi2.sqlite_version
    93144    else:
    94         if sys.version_info < (2, 4, 4) or sys.version_info[0] > 2:
    95             raise NotImplementedError("Tahoe-LAFS current requires Python v2.4.4 or greater "
    96                                       "for a non-UCS-2 build (but less than v3), not %r" %
    97                                       (sys.version_info,))
    98 
    99 def require_auto_deps():
    100     """
    101     The purpose of this function is to raise a pkg_resources exception if any of the
    102     requirements can't be imported.  This is just to give earlier and more explicit error
    103     messages, as opposed to waiting until the source code tries to import some module from one
    104     of these packages and gets an ImportError.  This function gets called from
    105     src/allmydata/__init__.py .
    106     """
    107     require_python_version()
     145        pysqlitever = sqlite3.version
     146        pysqlitefile = package_dir(sqlite3.__file__)
     147        sqlitever = sqlite3.sqlite_version
     148
     149    packages = {
     150        'pyopenssl': (OpenSSL.__version__, package_dir(OpenSSL.__file__)),
     151        allmydata.__appname__: (allmydata.__version__, package_dir(allmydata.__file__)),
     152        'foolscap': (foolscap.api.__version__, package_dir(foolscap.__file__)),
     153        'Nevow': (nevow.__version__, package_dir(nevow.__file__)),
     154        'pycryptopp': (pycryptopp.__version__, package_dir(pycryptopp.__file__)),
     155        'simplejson': (simplejson.__version__, package_dir(simplejson.__file__)),
     156        'pysqlite': (pysqlitever, pysqlitefile),
     157        'sqlite': (sqlitever, 'unknown'),
     158        'zope.interface': ('unknown', package_dir(zope.interface.__file__)),
     159        'Twisted': (twisted.__version__, package_dir(twisted.__file__)),
     160        'zfec': (zfec.__version__, package_dir(zfec.__file__)),
     161        'pycrypto': (Crypto.__version__, package_dir(Crypto.__file__)),
     162        'pyasn1': ('unknown', package_dir(pyasn1.__file__)),
     163        'mock': (mock.__version__, package_dir(mock.__file__)),
     164        'python': (platform.python_version(), sys.executable),
     165        }
    108166
    109     import pkg_resources
    110     for requirement in install_requires:
     167    if sys.platform == 'win32':
    111168        try:
    112             pkg_resources.require(requirement)
    113         except pkg_resources.DistributionNotFound:
    114             # there is no .egg-info present for this requirement, which
    115             # either means that it isn't installed, or it is installed in a
    116             # way that pkg_resources can't find it (but regular python
    117             # might).  There are several older Linux distributions which
    118             # provide our dependencies just fine, but they don't ship
    119             # .egg-info files. Note that if there *is* an .egg-info file,
    120             # but it shows a too-old version, then we'll get a
    121             # VersionConflict error instead of DistributionNotFound.
     169            import win32api
     170            packages['pywin32'] = ('unknown', package_dir(win32api.__file__))
     171        except ImportError:
    122172            pass
     173
     174    if not hasattr(sys, 'frozen'):
     175        # Don't try to get the setuptools version if using bbfreeze, py2exe etc. See #585.
     176        import setuptools
     177        packages['setuptools'] = (setuptools.__version__, package_dir(setuptools.__file__))
     178
     179    return packages
  • src/allmydata/test/test_runner.py

    diff -rN -u old-ticket1329/src/allmydata/test/test_runner.py new-ticket1329/src/allmydata/test/test_runner.py
    old new  
    33
    44from twisted.python import usage, runtime
    55from twisted.internet import utils
    6 import os.path, re, sys
     6import os.path, re, sys, subprocess
    77from cStringIO import StringIO
    88from allmydata.util import fileutil, pollmixin
    99from allmydata.util.encodingutil import unicode_to_argv, unicode_to_output, get_filesystem_encoding
     
    1414
    1515timeout = 240
    1616
     17def get_root_from_file(src):
     18    srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(src))))
     19
     20    root = os.path.dirname(srcdir)
     21    if os.path.basename(srcdir) == 'site-packages':
     22        if re.search(r'python.+\..+', os.path.basename(root)):
     23            root = os.path.dirname(root)
     24        root = os.path.dirname(root)
     25    elif os.path.basename(root) == 'src':
     26        root = os.path.dirname(root)
     27
     28    return root
     29
    1730srcfile = allmydata.__file__
    18 srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
     31rootdir = get_root_from_file(srcfile)
    1932
    20 rootdir = os.path.dirname(srcdir)
    21 if os.path.basename(srcdir) == 'site-packages':
    22     if re.search(r'python.+\..+', os.path.basename(rootdir)):
    23         rootdir = os.path.dirname(rootdir)
    24     rootdir = os.path.dirname(rootdir)
    25 elif os.path.basename(rootdir) == 'src':
    26     rootdir = os.path.dirname(rootdir)
    27 
    28 bintahoe = os.path.join(rootdir, 'bin', 'tahoe')
    29 if sys.platform == "win32":
    30     bintahoe += ".pyscript"
    31     if not os.path.exists(bintahoe):
    32        alt_bintahoe = os.path.join(rootdir, 'Scripts', 'tahoe.pyscript')
    33        if os.path.exists(alt_bintahoe):
    34            bintahoe = alt_bintahoe
     33
     34if hasattr(sys, 'frozen'):
     35    bintahoe = os.path.join(rootdir, 'tahoe')
     36
     37    if sys.platform == "win32" and os.path.exists(bintahoe + '.exe'):
     38        bintahoe += '.exe'
     39else:
     40    bintahoe = os.path.join(rootdir, 'bin', 'tahoe')
     41    if sys.platform == "win32":
     42        bintahoe += '.pyscript'
     43        if not os.path.exists(bintahoe):
     44            alt_bintahoe = os.path.join(rootdir, 'Scripts', 'tahoe.pyscript')
     45            if os.path.exists(alt_bintahoe):
     46                bintahoe = alt_bintahoe
    3547
    3648
    3749class SkipMixin:
     
    4961
    5062
    5163class BinTahoe(common_util.SignalMixin, unittest.TestCase, SkipMixin):
    52     def test_the_right_code(self):
     64    def _check_right_code(self, file_to_check):
     65        root_to_check = get_root_from_file(file_to_check)
     66        if os.path.basename(root_to_check) == 'dist':
     67            root_to_check = os.path.dirname(root_to_check)
     68
    5369        cwd = os.path.normcase(os.path.realpath("."))
    5470        root_from_cwd = os.path.dirname(cwd)
    5571        if os.path.basename(root_from_cwd) == 'src':
    5672            root_from_cwd = os.path.dirname(root_from_cwd)
    5773
    58         same = (root_from_cwd == rootdir)
     74        same = (root_from_cwd == root_to_check)
    5975        if not same:
    6076            try:
    61                 same = os.path.samefile(root_from_cwd, rootdir)
     77                same = os.path.samefile(root_from_cwd, root_to_check)
    6278            except AttributeError, e:
    6379                e  # hush pyflakes
    6480
     
    6682            msg = ("We seem to be testing the code at %r,\n"
    6783                   "(according to the source filename %r),\n"
    6884                   "but expected to be testing the code at %r.\n"
    69                    % (rootdir, srcfile, root_from_cwd))
     85                   % (root_to_check, file_to_check, root_from_cwd))
    7086
    71             root_from_cwdu = os.path.normcase(os.path.normpath(os.getcwdu()))
     87            root_from_cwdu = os.path.dirname(os.path.normcase(os.path.normpath(os.getcwdu())))
    7288            if os.path.basename(root_from_cwdu) == u'src':
    7389                root_from_cwdu = os.path.dirname(root_from_cwdu)
    7490
     
    8197                msg += "Please run the tests from the root of the Tahoe-LAFS distribution."
    8298                self.fail(msg)
    8399
     100    def test_the_right_code(self):
     101        self._check_right_code(srcfile)
     102
     103    def test_import_in_repl(self):
     104        self.skip_if_cannot_run_bintahoe()
     105
     106        args = [bintahoe, "debug", "repl"]
     107        if not hasattr(sys, 'frozen'):
     108            args = [sys.executable] + args
     109
     110        p = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     111        (out, err) = p.communicate("import allmydata; print allmydata.__file__")
     112
     113        self.failUnlessEqual(p.returncode, 0)
     114        first = out.splitlines()[0]
     115        self.failUnless(first.startswith('>>> '))
     116        self._check_right_code(first[4:])
     117
    84118    def test_path(self):
    85119        self.skip_if_cannot_run_bintahoe()
    86120        d = utils.getProcessOutputAndValue(bintahoe, args=["--version-and-path"], env=os.environ)
     
    112146                else:
    113147                    altverstr = verstr
    114148
     149            srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
    115150            required_ver_and_path = "%s: %s (%s)" % (allmydata.__appname__, verstr, srcdir)
    116151            alt_required_ver_and_path = "%s: %s (%s)" % (allmydata.__appname__, altverstr, srcdir)
    117152
     
    121156
    122157    def test_unicode_arguments_and_output(self):
    123158        self.skip_if_cannot_run_bintahoe()
     159        if hasattr(sys, 'frozen') and sys.platform == "win32":
     160            raise unittest.SkipTest("This test can't currently be made to work for frozen executables on Windows,\ndue to lack of support for Unicode in twisted.internet.utils.getProcessOutputAndValue.")
    124161
    125162        tricky = u"\u2621"
    126163        try:
     
    139176
    140177    def test_run_with_python_options(self):
    141178        self.skip_if_cannot_run_bintahoe()
     179        if hasattr(sys, 'frozen'):
     180            raise unittest.SkipTest("This test doesn't apply to frozen executables.")
    142181
    143182        # -t is a harmless option that warns about tabs.
    144183        d = utils.getProcessOutputAndValue(sys.executable, args=['-t', bintahoe, '--version'],
  • src/allmydata/test/test_system.py

    diff -rN -u old-ticket1329/src/allmydata/test/test_system.py new-ticket1329/src/allmydata/test/test_system.py
    old new  
    17691769
    17701770        if env is None:
    17711771            env = os.environ
    1772         d = utils.getProcessOutputAndValue(sys.executable, args=[bintahoe] + argv,
    1773                                            env=env)
     1772        d = utils.getProcessOutputAndValue(bintahoe, argv, env=env)
    17741773        return d
    17751774
    17761775    def _test_checker(self, res):