File: test_at.py

package info (click to toggle)
python-redbaron 0.9.2-4.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 776 kB
  • sloc: python: 6,650; makefile: 146; sh: 28
file content (32 lines) | stat: -rw-r--r-- 799 bytes parent folder | download | duplicates (2)
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
# -*- coding:Utf-8 -*-

"""Test for at method"""

import redbaron
from redbaron import RedBaron

redbaron.DEBUG = True

red = RedBaron("""\
class Foo(object):
    def __init__(self):
        self.a = None
    def bar(self):
        for x in range(5):
            yield self.a + x

setup(name='redbaron',
      version='0.6.1')
""")


def test_at():
    assert red.at(1) is red.class_
    assert red.at(2) is red.find_all('DefNode')[0]
    assert red.at(3) is red.find('AssignmentNode')
    assert red.at(4) is red.find_all('DefNode')[1]
    assert red.at(5) is red.find('ForNode')
    assert red.at(6) is red.find('YieldNode')
    assert red.at(7) is red.find_all('EndlNode')[6]
    assert red.at(8) is red.find_all('AtomTrailersNode')[3]
    assert red.at(9) is red.find_all('CallArgumentNode')[2]