summaryrefslogtreecommitdiff
path: root/tests/lexers/pycon
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lexers/pycon')
-rw-r--r--tests/lexers/pycon/example.txt693
-rw-r--r--tests/lexers/pycon/example2.txt83
2 files changed, 776 insertions, 0 deletions
diff --git a/tests/lexers/pycon/example.txt b/tests/lexers/pycon/example.txt
new file mode 100644
index 00000000..161f1094
--- /dev/null
+++ b/tests/lexers/pycon/example.txt
@@ -0,0 +1,693 @@
+---input---
+x = r"""
+>>> import os
+>>> print os
+<module 'os' from '/file/path.py'>
+>>> for x in range(10):
+... y = x + 2
+... print(x)
+... if x > 5:
+... raise Exception
+...
+0
+1
+2
+3
+4
+5
+6
+Traceback (most recent call last):
+ File "<stdin>", line 5, in <module>
+Exception
+>>>
+>>> while True:
+... pass
+...
+^CTraceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+KeyboardInterrupt
+
+>>> class A(Exception):pass
+...
+>>> class B(Exception):pass
+...
+>>> try:
+... try:
+... raise A('first')
+... finally:
+... raise B('second')
+... except A as c:
+... print(c)
+...
+Traceback (most recent call last):
+ File "<stdin>", line 3, in <module>
+__main__.A: first
+
+During handling of the above exception, another exception occurred:
+
+Traceback (most recent call last):
+ File "<stdin>", line 5, in <module>
+__main__.B: second
+
+>>> x =
+ File "<stdin>", line 1
+ x =
+ ^
+SyntaxError: invalid syntax
+>>>
+
+>>> x = 3
+>>> with 5 as y:
+... print(x + y)
+...
+8
+
+# TODO
+#>>> raise ValueError('multi\n line\ndetail')
+#Traceback (most recent call last):
+#........
+#ValueError: multi
+# line
+#detail
+
+>>> raise ValueError('multi\n line\ndetail')
+Traceback (most recent call last):
+ .123
+ValueError: multi
+ line
+detail
+
+>>> raise ValueError('multi\n line\ndetail')
+Traceback (most recent call last):
+ ...
+ValueError: multi
+ line
+detail
+
+>>> raise ValueError('multi\n line\ndetail')
+Traceback (most recent call last):
+ ....
+ValueError: multi
+ line
+detail
+
+>>> raise ValueError('multi\n line\ndetail')
+Traceback (most recent call last):
+ ....
+ValueError: multi
+ line
+detail
+
+>>> raise ValueError('multi\n line\ndetail')
+Traceback (most recent call last):
+ ...
+ValueError: multi
+ line
+detail
+
+>>> raise Exception
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+Exception
+>>> import somemodule
+>>> somemodule.blah()
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ File "/path/to/stuff/somemodule/blah.py", line 658, in blah
+ raise Exception('Hi.')
+Exception: Hi.
+
+
+---tokens---
+'x = r"""\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'import' Keyword.Namespace
+' ' Text
+'os' Name.Namespace
+'\n' Text
+
+'>>> ' Generic.Prompt
+'print' Name.Builtin
+' ' Text
+'os' Name
+'\n' Text
+
+"<module 'os' from '/file/path.py'>\n" Generic.Output
+
+'>>> ' Generic.Prompt
+'for' Keyword
+' ' Text
+'x' Name
+' ' Text
+'in' Operator.Word
+' ' Text
+'range' Name.Builtin
+'(' Punctuation
+'10' Literal.Number.Integer
+')' Punctuation
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'y' Name
+' ' Text
+'=' Operator
+' ' Text
+'x' Name
+' ' Text
+'+' Operator
+' ' Text
+'2' Literal.Number.Integer
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'print' Name.Builtin
+'(' Punctuation
+'x' Name
+')' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'if' Keyword
+' ' Text
+'x' Name
+' ' Text
+'>' Operator
+' ' Text
+'5' Literal.Number.Integer
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'raise' Keyword
+' ' Text
+'Exception' Name.Exception
+'\n' Text
+
+'...' Generic.Prompt
+'\n' Text
+
+'0\n' Generic.Output
+
+'1\n' Generic.Output
+
+'2\n' Generic.Output
+
+'3\n' Generic.Output
+
+'4\n' Generic.Output
+
+'5\n' Generic.Output
+
+'6\n' Generic.Output
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'5' Literal.Number
+', in ' Text
+'<module>' Name
+'\n' Text
+
+'Exception' Generic.Error
+'\n' Text
+
+'>>>\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'while' Keyword
+' ' Text
+'True' Keyword.Constant
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'pass' Keyword
+'\n' Text
+
+'...' Generic.Prompt
+'\n' Text
+
+'^CTraceback (most recent call last):\n' Generic.Output
+
+' File "<stdin>", line 1, in <module>\n' Generic.Output
+
+'KeyboardInterrupt\n' Name.Class
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'class' Keyword
+' ' Text
+'A' Name.Class
+'(' Punctuation
+'Exception' Name.Exception
+')' Punctuation
+':' Punctuation
+'pass' Keyword
+'\n' Text
+
+'...' Generic.Prompt
+'\n' Text
+
+'>>> ' Generic.Prompt
+'class' Keyword
+' ' Text
+'B' Name.Class
+'(' Punctuation
+'Exception' Name.Exception
+')' Punctuation
+':' Punctuation
+'pass' Keyword
+'\n' Text
+
+'...' Generic.Prompt
+'\n' Text
+
+'>>> ' Generic.Prompt
+'try' Keyword
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'try' Keyword
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'raise' Keyword
+' ' Text
+'A' Name
+'(' Punctuation
+"'" Literal.String.Single
+'first' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'finally' Keyword
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'raise' Keyword
+' ' Text
+'B' Name
+'(' Punctuation
+"'" Literal.String.Single
+'second' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+'except' Keyword
+' ' Text
+'A' Name
+' ' Text
+'as' Keyword
+' ' Text
+'c' Name
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'print' Name.Builtin
+'(' Punctuation
+'c' Name
+')' Punctuation
+'\n' Text
+
+'...' Generic.Prompt
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'3' Literal.Number
+', in ' Text
+'<module>' Name
+'\n' Text
+
+'__main__.A' Generic.Error
+': ' Text
+'first' Name
+'\n' Text
+
+'\n' Generic.Output
+
+'During handling of the above exception, another exception occurred:\n' Generic.Output
+
+'\n' Generic.Output
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'5' Literal.Number
+', in ' Text
+'<module>' Name
+'\n' Text
+
+'__main__.B' Generic.Error
+': ' Text
+'second' Name
+'\n' Text
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'x' Name
+' ' Text
+'=' Operator
+'\n' Text
+
+'' Generic.Traceback
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'1' Literal.Number
+'\n' Text
+
+' ' Text
+'x' Name
+' ' Text
+'=' Operator
+'\n' Text
+
+' ' Text
+' ' Text
+'^' Operator
+'\n' Text
+
+'SyntaxError' Generic.Error
+': ' Text
+'invalid syntax' Name
+'\n' Text
+
+'>>>\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'x' Name
+' ' Text
+'=' Operator
+' ' Text
+'3' Literal.Number.Integer
+'\n' Text
+
+'>>> ' Generic.Prompt
+'with' Keyword
+' ' Text
+'5' Literal.Number.Integer
+' ' Text
+'as' Keyword
+' ' Text
+'y' Name
+':' Punctuation
+'\n' Text
+
+'... ' Generic.Prompt
+' ' Text
+'print' Name.Builtin
+'(' Punctuation
+'x' Name
+' ' Text
+'+' Operator
+' ' Text
+'y' Name
+')' Punctuation
+'\n' Text
+
+'...' Generic.Prompt
+'\n' Text
+
+'8\n' Generic.Output
+
+'\n' Generic.Output
+
+'# TODO\n' Generic.Output
+
+"#>>> raise ValueError('multi\\n line\\ndetail')\n" Generic.Output
+
+'#Traceback (most recent call last):\n' Generic.Output
+
+'#........\n' Generic.Output
+
+'#ValueError: multi\n' Generic.Output
+
+'# line\n' Generic.Output
+
+'#detail\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'raise' Keyword
+' ' Text
+'ValueError' Name.Exception
+'(' Punctuation
+"'" Literal.String.Single
+'multi' Literal.String.Single
+'\\n' Literal.String.Escape
+' line' Literal.String.Single
+'\\n' Literal.String.Escape
+'detail' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' .123\nValueError' Generic.Error
+': ' Text
+'multi' Name
+'\n' Text
+
+' line\n' Generic.Output
+
+'detail\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'raise' Keyword
+' ' Text
+'ValueError' Name.Exception
+'(' Punctuation
+"'" Literal.String.Single
+'multi' Literal.String.Single
+'\\n' Literal.String.Escape
+' line' Literal.String.Single
+'\\n' Literal.String.Escape
+'detail' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' ' Text
+'.' Operator
+'.' Operator
+'.' Operator
+'\n' Text
+
+'ValueError' Generic.Error
+': ' Text
+'multi' Name
+'\n' Text
+
+' line\n' Generic.Output
+
+'detail\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'raise' Keyword
+' ' Text
+'ValueError' Name.Exception
+'(' Punctuation
+"'" Literal.String.Single
+'multi' Literal.String.Single
+'\\n' Literal.String.Escape
+' line' Literal.String.Single
+'\\n' Literal.String.Escape
+'detail' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' ' Text
+'.' Operator
+'.' Operator
+'.' Operator
+'.' Operator
+'\n' Text
+
+'ValueError' Generic.Error
+': ' Text
+'multi' Name
+'\n' Text
+
+' line\n' Generic.Output
+
+'detail\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'raise' Keyword
+' ' Text
+'ValueError' Name.Exception
+'(' Punctuation
+"'" Literal.String.Single
+'multi' Literal.String.Single
+'\\n' Literal.String.Escape
+' line' Literal.String.Single
+'\\n' Literal.String.Escape
+'detail' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' ' Text
+' ' Text
+'.' Operator
+'.' Operator
+'.' Operator
+'.' Operator
+'\n' Text
+
+'ValueError' Generic.Error
+': ' Text
+'multi' Name
+'\n' Text
+
+' line\n' Generic.Output
+
+'detail\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'raise' Keyword
+' ' Text
+'ValueError' Name.Exception
+'(' Punctuation
+"'" Literal.String.Single
+'multi' Literal.String.Single
+'\\n' Literal.String.Escape
+' line' Literal.String.Single
+'\\n' Literal.String.Escape
+'detail' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' ' Text
+'...' Comment
+'\n' Text
+
+'ValueError' Generic.Error
+': ' Text
+'multi' Name
+'\n' Text
+
+' line\n' Generic.Output
+
+'detail\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'raise' Keyword
+' ' Text
+'Exception' Name.Exception
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'1' Literal.Number
+', in ' Text
+'<module>' Name
+'\n' Text
+
+'Exception' Generic.Error
+'\n' Text
+
+'>>> ' Generic.Prompt
+'import' Keyword.Namespace
+' ' Text
+'somemodule' Name.Namespace
+'\n' Text
+
+'>>> ' Generic.Prompt
+'somemodule' Name
+'.' Operator
+'blah' Name
+'(' Punctuation
+')' Punctuation
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'1' Literal.Number
+', in ' Text
+'<module>' Name
+'\n' Text
+
+' File ' Text
+'"/path/to/stuff/somemodule/blah.py"' Name.Builtin
+', line ' Text
+'658' Literal.Number
+', in ' Text
+'blah' Name
+'\n' Text
+
+' ' Text
+'raise' Keyword
+' ' Text
+'Exception' Name.Exception
+'(' Punctuation
+"'" Literal.String.Single
+'Hi.' Literal.String.Single
+"'" Literal.String.Single
+')' Punctuation
+'\n' Text
+
+'Exception' Generic.Error
+': ' Text
+'Hi.' Name
+'\n' Text
diff --git a/tests/lexers/pycon/example2.txt b/tests/lexers/pycon/example2.txt
new file mode 100644
index 00000000..3df988a2
--- /dev/null
+++ b/tests/lexers/pycon/example2.txt
@@ -0,0 +1,83 @@
+---input---
+>>> :
+ File "<stdin>", line 1
+ :
+ ^
+SyntaxError: invalid syntax
+>>>
+KeyboardInterrupt
+>>>
+
+>>> 1/0
+Traceback (most recent call last):
+ ...
+ZeroDivisionError
+
+>>> 1/0 # this used to swallow the traceback
+Traceback (most recent call last):
+ ...
+
+---tokens---
+'>>> ' Generic.Prompt
+':' Punctuation
+'\n' Text
+
+'' Generic.Traceback
+' File ' Text
+'"<stdin>"' Name.Builtin
+', line ' Text
+'1' Literal.Number
+'\n' Text
+
+' ' Text
+':' Punctuation
+'\n' Text
+
+' ' Text
+'^' Operator
+'\n' Text
+
+'SyntaxError' Generic.Error
+': ' Text
+'invalid syntax' Name
+'\n' Text
+
+'>>> ' Generic.Prompt
+'\n' Text
+
+'KeyboardInterrupt\n' Name.Class
+
+'>>>\n' Generic.Output
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'1' Literal.Number.Integer
+'/' Operator
+'0' Literal.Number.Integer
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' ' Text
+'...' Comment
+'\n' Text
+
+'ZeroDivisionError' Generic.Error
+'\n' Text
+
+'\n' Generic.Output
+
+'>>> ' Generic.Prompt
+'1' Literal.Number.Integer
+'/' Operator
+'0' Literal.Number.Integer
+' ' Text
+'# this used to swallow the traceback' Comment.Single
+'\n' Text
+
+'Traceback (most recent call last):\n' Generic.Traceback
+
+' ' Text
+'...' Comment
+'\n' Text