def test___getstate__(self):
     """check OverlapCalculator.__getstate__()
     """
     olc = self.olc
     self.assertIs(None, olc.__getstate__()[-1])
     tb = CovalentRadiiTable()
     olc.atomradiitable = tb
     self.assertIs(tb, olc.__getstate__()[-1])
     olc.atomradiitable = "constant"
     self.assertIs(None, olc.__getstate__()[-1])
     return
 def test_pickling_artb(self):
     '''check pickling and unpickling of OverlapCalculator.atomradiitable.
     '''
     olc = self.olc
     olc.atomradiitable.setDefault(1.3)
     spkl = pickle.dumps(olc)
     olc1 = pickle.loads(spkl)
     self.assertFalse(olc is olc1)
     self.assertEqual(1.3, olc1.atomradiitable.getDefault())
     olc.atomradiitable = CovalentRadiiTable()
     olc.atomradiitable.setCustom('Na', 2)
     olc.atomradiitable.foo = 123
     spkl2 = pickle.dumps(olc)
     olc2 = pickle.loads(spkl2)
     self.assertEqual(2, olc2.atomradiitable.lookup('Na'))
     self.assertEqual(1, len(olc2.atomradiitable.getAllCustom()))
     self.assertEqual(123, olc2.atomradiitable.foo)
     return
Beispiel #3
0
 def setUp(self):
     self.rtb = CovalentRadiiTable()
     return
Beispiel #4
0
class TestCovalentRadiiTable(unittest.TestCase):
    def setUp(self):
        self.rtb = CovalentRadiiTable()
        return

    def tearDown(self):
        return

    def test_pickling(self):
        '''check pickling and unpickling of CovalentRadiiTable.
        '''
        rtb1 = cPickle.loads(cPickle.dumps(self.rtb))
        self.assertTrue(type(rtb1) is CovalentRadiiTable)
        self.assertEqual({}, rtb1.getAllCustom())
        self.rtb.setCustom('Na', 1.3)
        self.rtb.foobar = 'foo'
        rtb2 = cPickle.loads(cPickle.dumps(self.rtb))
        self.assertEqual({'Na': 1.3}, rtb2.getAllCustom())
        self.assertEqual('foo', rtb2.foobar)
        return

    def test__tableLookup(self):
        """check CovalentRadiiTable._tableLookup()
        """
        self.assertEqual(1.22, self.rtb._tableLookup('Ga'))
        return

    def test_fromString(self):
        """check CovalentRadiiTable.fromString()
        """
        self.rtb.fromString('Ga:2.22')
        self.assertEqual(2.22, self.rtb.lookup('Ga'))
        return

    def test_getAllCustom(self):
        """check CovalentRadiiTable.getAllCustom()
        """
        self.assertEqual({}, self.rtb.getAllCustom())
        return

    def test_lookup(self):
        """check CovalentRadiiTable.lookup()
        """
        self.assertEqual(1.22, self.rtb.lookup('Ga'))
        self.rtb.fromString('Ga:2.22')
        self.assertEqual(2.22, self.rtb.lookup('Ga'))
        return

    def test_resetCustom(self):
        """check CovalentRadiiTable.resetCustom()
        """
        self.rtb.fromString('B:2.33, Ga:2.22')
        self.rtb.resetCustom('B')
        self.rtb.resetCustom('nada')
        self.assertEqual(1, len(self.rtb.getAllCustom()))
        self.assertEqual(0.84, self.rtb.lookup('B'))
        self.assertEqual(2.22, self.rtb.lookup('Ga'))
        return

    def test_setCustom(self):
        """check CovalentRadiiTable.setCustom()
        """
        self.assertEqual(0.84, self.rtb.lookup('B'))
        self.rtb.setCustom('B', 0.9)
        self.assertEqual(0.9, self.rtb.lookup('B'))
        return

    def test_toString(self):
        """check CovalentRadiiTable.toString()
        """
        self.assertEqual('', self.rtb.toString(';---'))
        return
 def setUp(self):
     self.rtb = CovalentRadiiTable()
     return
class TestCovalentRadiiTable(TestCasePeriodictableOptional):

    def setUp(self):
        self.rtb = CovalentRadiiTable()
        return

    def tearDown(self):
        return

    def test_pickling(self):
        '''check pickling and unpickling of CovalentRadiiTable.
        '''
        rtb1 = cPickle.loads(cPickle.dumps(self.rtb))
        self.assertTrue(type(rtb1) is CovalentRadiiTable)
        self.assertEqual({}, rtb1.getAllCustom())
        self.rtb.setCustom('Na', 1.3)
        self.rtb.foobar = 'foo'
        rtb2 = cPickle.loads(cPickle.dumps(self.rtb))
        self.assertEqual({'Na' : 1.3}, rtb2.getAllCustom())
        self.assertEqual('foo', rtb2.foobar)
        return

    def test__standardLookup(self):
        """check CovalentRadiiTable._standardLookup()
        """
        self.assertEqual(1.22, self.rtb._standardLookup('Ga'))
        return

    def test_create(self):
        """check CovalentRadiiTable.create()
        """
        self.rtb.setCustom('Na', 1.3)
        rtb2 = self.rtb.create()
        self.assertTrue(isinstance(rtb2, CovalentRadiiTable))
        self.assertEqual(1, len(self.rtb.getAllCustom()))
        self.assertEqual(0, len(rtb2.getAllCustom()))
        return

    def test_clone(self):
        """check CovalentRadiiTable.clone()
        """
        self.rtb.setCustom('Na', 1.3)
        rtb2 = self.rtb.clone()
        self.assertTrue(isinstance(rtb2, CovalentRadiiTable))
        self.assertEqual(1, len(rtb2.getAllCustom()))
        self.assertEqual(1.3, rtb2.lookup('Na'))
        return

    def test_fromString(self):
        """check CovalentRadiiTable.fromString()
        """
        self.rtb.fromString('Ga:2.22')
        self.assertEqual(2.22, self.rtb.lookup('Ga'))
        return

    def test_getAllCustom(self):
        """check CovalentRadiiTable.getAllCustom()
        """
        self.assertEqual({}, self.rtb.getAllCustom())
        return

    def test_lookup(self):
        """check CovalentRadiiTable.lookup()
        """
        self.assertEqual(1.22, self.rtb.lookup('Ga'))
        self.rtb.fromString('Ga:2.22')
        self.assertEqual(2.22, self.rtb.lookup('Ga'))
        return

    def test_resetCustom(self):
        """check CovalentRadiiTable.resetCustom()
        """
        self.rtb.fromString('B:2.33, Ga:2.22')
        self.rtb.resetCustom('B')
        self.rtb.resetCustom('nada')
        self.assertEqual(1, len(self.rtb.getAllCustom()))
        self.assertEqual(0.84, self.rtb.lookup('B'))
        self.assertEqual(2.22, self.rtb.lookup('Ga'))
        return

    def test_setCustom(self):
        """check CovalentRadiiTable.setCustom()
        """
        self.assertEqual(0.84, self.rtb.lookup('B'))
        self.rtb.setCustom('B', 0.9)
        self.assertEqual(0.9, self.rtb.lookup('B'))
        return

    def test_toString(self):
        """check CovalentRadiiTable.toString()
        """
        self.assertEqual('', self.rtb.toString(';---'))
        return