コード例 #1
0
    def test_delete_del(self):
        val = expando()
        val1 = expando()

        self.branch.set('par1', val, val1)
        self.assertIs(self.branch.par1, val)

        del self.branch.par1
        self.assertTrue(hasattr(self.branch, 'par1'))
        self.assertIs(self.branch.par1, val1)
コード例 #2
0
    def test_setget(self):
        val = expando()

        self.branch.set('par1', val)
        self.assertTrue(hasattr(self.branch, 'par1'))
        self.assertIs(getattr(self.branch, 'par1'), val)
        self.assertIs(self.branch.par1, val)

        name = randomword(8)
        val = expando()

        self.branch.set(name, val)

        self.assertTrue(hasattr(self.branch, name))
        self.assertIs(getattr(self.branch, name), val)
コード例 #3
0
    def test_param_init(self):
        name = randomword(8)
        val = expando()

        par = config.Param(name, val)

        self.assertEqual((name, val, None),
                         (par.name, par.value, par.default_value))

        name = randomword(8)
        val = expando()
        def_val = expando()

        par = config.Param(name, val, def_val)

        self.assertEqual((name, val, def_val),
                         (par.name, par.value, par.default_value))
コード例 #4
0
    def test_classprop(self):
        val = expando()

        self.branch.set('par1', val)

        branch = config.Branch('br1')
        self.assertFalse(hasattr(branch, 'par1'))
        self.assertNotIn('par1', dir(branch))
コード例 #5
0
    def test_set_default(self):
        val = expando()

        self.branch.set_default('par1', val)
        self.assertIs(self.branch.par1, val)

        self.branch.delete('par1')
        self.assertTrue(hasattr(self.branch, 'par1'))
        self.assertIs(self.branch.par1, val)
コード例 #6
0
    def test_delete(self):
        val = expando()

        self.branch.set('par1', val)
        self.assertIs(self.branch.par1, val)

        self.branch.delete('par1')
        self.assertRaisesRegexp(AttributeError, "\'par1\'",
                                lambda: self.branch.par1)
コード例 #7
0
        def test_contact_future(self):
            # test fails because of lack of pydesc.contacts imported
            # their are not imported in order to avoid false-positive result
            # of set_contact_map test in presence of import errors
            whole = list(self.struct)

            for i in range(100):
                r1 = random.choice(whole)
                r2 = random.choice(whole)

                if r1 == r2:
                    continue

                try:
                    el1 = structure.ElementChainable(r1)
                    el2 = structure.ElementChainable(r2)
                except:
                    continue

                def check(c, v, crit):
                    self.assertEqual(
                        (tuple(map(lambda x: x.central_monomer,
                                   c.elements)), c.value, c.criterion),
                        ((r1, r2), v, crit))

                c = structure.Contact(r1, r2)
                check(c, None, None)

                val = syntax_check.expando()
                c = structure.Contact(r1, r2, value=val)
                check(c, val, None)

                cc = contacts.ContactCriterion()
                c = structure.Contact(r1, r2, contact_criterion=cc)
                check(c, None, cc)

                self.assertEqual(c - el1, el2)
                self.assertEqual(c - el2, el1)

                self.assertTrue(
                    isinstance(c.select(), selection.SelectionsUnion)
                    or isinstance(c.select(), selection.Range))