1. zjes
  2. rope_py3k

Commits

Ali Gholami Rudi  committed 9c29528

similarfinder: better wildcard pattern

  • Participants
  • Parent commits de4f3d0
  • Branches trunk

Comments (0)

Files changed (2)

File rope/refactor/similarfinder.py

View file
         if cls._match_pattern is None:
             pattern = codeanalyze.get_comment_pattern() + '|' + \
                       codeanalyze.get_string_pattern() + '|' + \
-                      r'(?P<name>\$\{[^\s\$]*\})'
+                      r'(?P<name>\$\{[^\s\$\}]*\})'
             cls._match_pattern = re.compile(pattern)
         return cls._match_pattern
 

File ropetest/refactor/similarfindertest.py

View file
         finder = self._create_finder(source)
         self.assertEquals(1, len(list(finder.get_matches(pattern))))
 
+    def test_matching_dicts_inside_functions(self):
+        source = 'def f(p):\n    d = {1: p.x}\n'
+        pattern = '{1: ${a}.x}'
+        finder = self._create_finder(source)
+        self.assertEquals(1, len(list(finder.get_matches(pattern))))
+
 
 class CheckingFinderTest(unittest.TestCase):