@@ -919,6 +919,14 @@ def test_parse_invalid_expression_with_single_leading_or_raise_exception(self):
919919 }
920920 assert expected == _parse_error_as_dict (pe )
921921
922+ def test_Licensing_can_parse_expressions_with_symbols_that_contain_a_colon (self ):
923+ licensing = Licensing ()
924+ expression = 'DocumentRef-James-1.0:LicenseRef-Eric-2.0'
925+
926+ result = licensing .parse (expression )
927+ expected = 'DocumentRef-James-1.0:LicenseRef-Eric-2.0'
928+ assert expected == result .render ('{symbol.key}' )
929+
922930
923931class LicensingParseWithSymbolsSimpleTest (TestCase ):
924932
@@ -1752,6 +1760,52 @@ def test_simple_tokenizer(self):
17521760 ]
17531761 assert expected == results
17541762
1763+ def test_tokenize_can_handle_expressions_with_symbols_that_contain_a_colon (self ):
1764+ licensing = Licensing ()
1765+ expression = 'DocumentRef-James-1.0:LicenseRef-Eric-2.0'
1766+
1767+ result = list (licensing .tokenize (expression ))
1768+ expected = [
1769+ (LicenseSymbol (u'DocumentRef-James-1.0:LicenseRef-Eric-2.0' , is_exception = False ),
1770+ u'DocumentRef-James-1.0:LicenseRef-Eric-2.0' , 0 )
1771+ ]
1772+
1773+ assert expected == result
1774+
1775+ def test_tokenize_simple_can_handle_expressions_with_symbols_that_contain_a_colon (self ):
1776+ licensing = Licensing ()
1777+ expression = 'DocumentRef-James-1.0:LicenseRef-Eric-2.0'
1778+
1779+ result = list (licensing .tokenize (expression , simple = True ))
1780+ expected = [
1781+ (LicenseSymbol (u'DocumentRef-James-1.0:LicenseRef-Eric-2.0' , is_exception = False ),
1782+ u'DocumentRef-James-1.0:LicenseRef-Eric-2.0' , 0 )
1783+ ]
1784+
1785+ assert expected == result
1786+
1787+ def test_tokenize_can_handle_expressions_with_tabs_and_new_lines (self ):
1788+ licensing = Licensing ()
1789+ expression = 'this\t \t is \n \n an expression'
1790+ result = list (licensing .tokenize (expression , simple = False ))
1791+ expected = [
1792+ (LicenseSymbol (u'this is an expression' , is_exception = False ),
1793+ u'this is an expression' , 0 )
1794+ ]
1795+ assert expected == result
1796+
1797+ def test_tokenize_simple_can_handle_expressions_with_tabs_and_new_lines (self ):
1798+ licensing = Licensing ()
1799+ expression = 'this\t \t is \n \n an expression'
1800+ result = list (licensing .tokenize (expression , simple = True ))
1801+ expected = [
1802+ (LicenseSymbol (u'this' , is_exception = False ), u'this' , 0 ),
1803+ (LicenseSymbol (u'is' , is_exception = False ), u'is' , 7 ),
1804+ (LicenseSymbol (u'an' , is_exception = False ), u'an' , 13 ),
1805+ (LicenseSymbol (u'expression' , is_exception = False ), u'expression' , 16 )
1806+ ]
1807+ assert expected == result
1808+
17551809 def test_tokenize_step_by_step_does_not_munge_trailing_symbols (self ):
17561810 gpl2 = LicenseSymbol (key = 'GPL-2.0' )
17571811 gpl2plus = LicenseSymbol (key = 'GPL-2.0 or LATER' )
0 commit comments