File: PYMOL-3171.py

package info (click to toggle)
pymol 3.1.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 74,084 kB
  • sloc: cpp: 482,660; python: 89,328; ansic: 29,512; javascript: 6,792; sh: 84; makefile: 25
file content (30 lines) | stat: -rw-r--r-- 847 bytes parent folder | download
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
from pymol import cmd, stored, testing

@testing.requires_version('2.3')
class TestParserNesting(testing.PyMOLTestCase):
    def test(self):
        # basic
        stored.x = []
        cmd.do(
            'cmd.do("'
            '  stored.x.append(1);'
            '  stored.x.append(2)'
            '");'
            'stored.x.append(3)',
            echo=0)
        self.assertEqual(stored.x, [1, 2, 3])

        # extra level of nesting
        stored.x = []
        cmd.do(
            'cmd.do("'
            '  stored.x.append(1);'
            "  cmd.do('"
            '    stored.x.append(2);'
            '    stored.x.append(3)'
            "  ');"
            '  stored.x.append(4)'
            '");'
            'stored.x.append(5)',
            echo=0)
        self.assertEqual(stored.x, [1, 2, 3, 4, 5])