/usr/lib/python2.7/dist-packages/rpy2/rinterface/tests/test_SexpExtPtr.py is in python-rpy2 2.4.4-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 | import unittest
import rpy2.rinterface as rinterface
rinterface.initr()
class SexpExtPtrTestCase(unittest.TestCase):
def setUp(self):
self.console = rinterface.get_writeconsole()
def noconsole(x):
pass
rinterface.set_writeconsole(noconsole)
def tearDown(self):
rinterface.set_writeconsole(self.console)
def testNewDefault(self):
pyobject = "ahaha"
sexp_new = rinterface.SexpExtPtr(pyobject)
# R External pointer are never copied
self.assertEqual(rinterface.EXTPTRSXP, sexp_new.typeof)
def testNewTag(self):
pyobject = "ahaha"
sexp_new = rinterface.SexpExtPtr(pyobject,
tag = rinterface.StrSexpVector("b"))
self.assertEqual(rinterface.EXTPTRSXP, sexp_new.typeof)
self.assertEqual('b', sexp_new.__tag__[0])
def testNewInvalidTag(self):
pyobject = "ahaha"
self.assertRaises(TypeError, rinterface.SexpExtPtr,
pyobject, tag = True)
def testNewProtected(self):
pyobject = "ahaha"
sexp_new = rinterface.SexpExtPtr(pyobject,
protected = rinterface.StrSexpVector("c"))
self.assertEqual(rinterface.EXTPTRSXP, sexp_new.typeof)
self.assertEqual('c', sexp_new.__protected__[0])
def testNewInvalidProtected(self):
pyobject = "ahaha"
self.assertRaises(TypeError, rinterface.SexpExtPtr,
pyobject, protected = True)
def suite():
suite = unittest.TestLoader().loadTestsFromTestCase(SexpExtPtrTestCase)
return suite
if __name__ == '__main__':
tr = unittest.TextTestRunner(verbosity = 2)
tr.run(suite())
|