Commits

Vinay Sajip committed 21f0f57

Improved direct reference parsing, refined test.

Comments (0)

Files changed (2)

         d = m.groupdict()
         name = d['dn']
         cons = d['c1'] or d['c2']
-        if d['diref']:
+        if not d['diref']:
+            url = None
+        else:
             # direct reference
             cons = None
+            url = d['diref'].strip()
         if not cons:
             cons = None
             constr = ''
         else:
             extras = COMMA_RE.split(d['ex'])
         result = Container(name=name, constraints=cons, extras=extras,
-                           requirement=rs, source=s, url=d['diref'])
+                           requirement=rs, source=s, url=url)
     return result
 
 

tests/test_util.py

         r = parse_requirement('a (== 1.2.*, != 1.2.1.*)')
         validate(r, ('a', [('==', '1.2.*'), ('!=', '1.2.1.*')], None,
                  'a (== 1.2.*, != 1.2.1.*)', None))
-        r = parse_requirement('a (from http://domain.com/path#abc=def)')
+        r = parse_requirement('a (from http://domain.com/path#abc=def )')
         validate(r, ('a', None, None, 'a', 'http://domain.com/path#abc=def'))
-        for e in ('*', ':*:', ':meta:'):
+        for e in ('*', ':*:', ':meta:', '-', '-abc'):
             r = parse_requirement('a [%s]' % e)
             validate(r, ('a', None, [e], 'a', None))