コード例 #1
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testFindFullScopesHangingScope(self):
     #a = 1
     #def b(f):
     #    pass
     scp1 = scopes.Scope('__main__',0,-1, line_end=3)
     scp2 = scopes.Scope('def',2,0, parent=scp1)
     lines = [(0,0),(1,0),(2,4)]
     new_scopes = list(scp1.create_scope_list(lines))
     self.assertEqual(new_scopes[1].line_end,3)
コード例 #2
0
ファイル: test_expressions.py プロジェクト: furbrain/tested
 def getType(self, expr, context=None):
     if context is None:
         context = scopes.Scope('__test__', 0, -1)
     return expressions.get_expression_type(expr, context)
コード例 #3
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testScopeListFailsOutsideArea(self):
     s = scopes.ScopeList()
     dcta = {'a':int}
     s.add(scopes.Scope('name',line_start=0, indent=4, line_end=10, context=dcta))
     self.assertIsNone(s.get_scope(12,0))
コード例 #4
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testIndentedScopeMatches(self):
     sc = scopes.Scope('name', line_start=0, indent=0, line_end=100)
     self.assertTrue(sc.matches(50,4))
コード例 #5
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testScopeListFailsWithWrongIndent(self):
     s = scopes.ScopeList()
     dcta = {'a':int}
     s.add(scopes.Scope('name',line_start=0, indent=4, line_end=10, context=dcta))
     self.assertIsNone(s.get_scope(5,0))
コード例 #6
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def checkScope(self, scope_list, position, match):
     s = scopes.ScopeList()
     for scope in scope_list:
         s.add(scopes.Scope(*scope))
     result = s.get_scope(*position)
     self.assertEqual(result.context,match)
コード例 #7
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testBaseScopeMatches(self):
     sc = scopes.Scope('name', line_start=0, indent=-1, line_end=100)
     self.assertTrue(sc.matches(50,0))
コード例 #8
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testScopeTrees(self):
     sc1 = scopes.Scope('sc1', line_start=0, indent=-1)
     sc2 = scopes.Scope('sc2', line_start=4, indent=0, parent=sc1)
     self.assertIn(sc2,sc1.get_all_children())
コード例 #9
0
ファイル: test_scopes.py プロジェクト: furbrain/tested
 def testOutsideScopeDoesNotMatch(self):
     sc = scopes.Scope('name', line_start=0, indent=0, line_end=10)
     self.assertFalse(sc.matches(50,0))