/usr/lib/python2.7/dist-packages/rpy2/tests.py is in python-rpy2 2.7.8-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | #!/usr/bin/env python
'''tests.py - run all the tests worth running
The goal is that "ERRORS" and "FAILURES" are true failures, and expected
problems sould be dealt with using decorators.'''
from __future__ import print_function
# if `singledispatch` is absent, the unit tests are failing with a rather
# obscure / misleading error message. Test it now and report the problem.
import sys
if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 4):
try:
from singledispatch import singledispatch
except ImportError as ie:
print('The module "singledispatch is required for Python < 3.4')
raise ie
from os.path import dirname
import unittest
import rpy2
import rpy2.tests_rpy_classic
def load_tests(loader, tests, pattern):
'''Run tests a little faster than with TestLoader.discover()
Note that we are using the unittest API here, but blithely ignore the values
passed in for `tests` and `pattern`'''
# For some reason, the commented code directly below is slow and loads some
# things twice One specific message is regarding package_dependencies from
# the tools package.
# rpy_root = dirname(rpy2.__file__)
# alltests = unittest.defaultTestLoader.discover(rpy_root, pattern='test*')
rpy_root = dirname(rpy2.__file__)
tests = unittest.TestSuite()
pattern = 'test*'
# This now catches some extra tests (bypassing the suite() functions),
# at least in a virtualenv that lacks various packages, like numpy &
# pandas
suite_robjects = loader.discover('robjects', pattern, rpy_root)
suite_rinterface = loader.discover('rinterface', pattern, rpy_root)
suite_rlike = loader.discover('rlike', pattern, rpy_root)
# This is once again testless
suite_interactive = loader.discover('interactive', pattern, rpy_root)
# ipython is a little trickier because it is an optional
# dependency.
try:
import IPython
has_ipython = True
except ImportError as ie:
has_ipython = False
if has_ipython:
suite_ipython= loader.discover('ipython', pattern, rpy_root)
else:
class MissingIpythonTestCase(unittest.TestCase):
@unittest.skip("The optional dependency IPython is required in order to test features using it.")
def testHasIpython(self):
pass
suite_ipython = unittest.TestLoader().loadTestsFromTestCase(MissingIpythonTestCase)
suite_rpy_classic = rpy2.tests_rpy_classic.suite()
tests.addTests([suite_rinterface,
suite_robjects,
suite_rlike,
suite_interactive,
suite_ipython,
suite_rpy_classic
])
return tests
if __name__ == "__main__":
import sys, rpy2.rinterface
print("rpy2 version: %s" % rpy2.__version__)
print("- built against R version: %s" % '-'.join(str(x)
for x in rpy2.rinterface.R_VERSION_BUILD))
try:
import rpy2.rinterface
except Exception as e:
print("'rpy2.rinterface' could not be imported:")
print(e)
sys.exit(1)
try:
rpy2.rinterface.initr()
except Exception as e:
print("- The embedded R could not be initialized")
print(e)
sys.exit(1)
try:
rv = rpy2.rinterface.baseenv['R.version.string']
print("- running linked to R version: %s" % rv[0])
except KeyError as ke:
print("The R version dynamically linked cannot be identified.")
# This will sys.exit() with an appropriate error code
unittest.main(buffer=True)
|