older Ipython, failing test

This commit is contained in:
Aaron Munger
2023-10-16 15:57:14 -07:00
committed by Aaron Munger
parent fe8ac3f89e
commit 4540b9ba1f
2 changed files with 62 additions and 28 deletions

View File

@@ -20,15 +20,16 @@ suite('StackTraceHelper', () => {
test('IPython stack line numbers are linkified', () => {
const stack =
'---------------------------------------------------------------------------\n' +
'Exception Traceback(most recent call last)\n' +
'Cell In[3], line 2\n' +
' 1 import myLib\n' +
'----> 2 myLib.throwEx()\n' +
'\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n' +
'\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n' +
'Cell \u001b[1;32mIn[3], line 2\u001b[0m\n' +
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmyLib\u001b[39;00m\n' +
'\u001b[1;32m----> 2\u001b[0m \u001b[43mmyLib\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mthrowEx\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n' +
'\n' +
'File C:\\venvs\\myLib.py:2, in throwEx()\n' +
' 1 def throwEx():\n' +
'----> 2 raise Exception\n';
'File \u001b[1;32mC:\\venvs\\myLib.py:2\u001b[0m, in \u001b[0;36mthrowEx\u001b[1;34m()\u001b[0m\n' +
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mthrowEx\u001b[39m():\n' +
'\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m\n\n' +
'\u001b[1;31mException\u001b[0m\n:';
const formatted = formatStackTrace(stack);
assert.ok(formatted.indexOf('<a href=\'vscode-notebook-cell:?execution=3\'>Cell In[3]</a>') > 0, formatted);
@@ -36,18 +37,33 @@ suite('StackTraceHelper', () => {
assert.ok(formatted.indexOf('<a href=\'C:\\venvs\\myLib.py:2\'>2</a>') > 0, formatted);
});
test('IPython stack trace lines without associated location are not linkified', () => {
test('IPython stack line numbers are linkified for IPython 8.3', () => {
const stack =
'---------------------------------------------------------------------------\n' +
'Exception Traceback(most recent call last)\n' +
'File C:\\venvs\\myLib.py:2, in throwEx()\n' +
'\n' +
'unkown reference' +
' 1 import myLib\n' + // trace lines without an associated file
'----> 2 myLib.throwEx()\n';
'\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n' +
'\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n' +
'Input \u001b[1;32mIn [2]\u001b[0m, in \u001b[0;36m<cell line: 5>\u001b[1;34m()\u001b[0m\n' +
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mimport\u001b[39;00m \u001b[38;5;21;01mmyLib\u001b[39;00m\n' +
'\u001b[1;32m----> 2\u001b[0m \u001b[43mmyLib\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mthrowEx\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n';
const formatted = formatStackTrace(stack);
assert.ok(formatted.indexOf('<a') === -1, formatted);
assert.ok(formatted.indexOf('<a href=\'vscode-notebook-cell:?execution=3\'>Input [2]</a>') > 0, formatted);
assert.ok(formatted.indexOf('<a href=\'vscode-notebook-cell:?execution=3:2\'>2</a>') > 0, formatted);
assert.ok(formatted.indexOf('<a href=\'C:\\venvs\\myLib.py:2\'>2</a>') > 0, formatted);
});
test('IPython stack trace lines without associated location are not linkified', () => {
const stack =
'\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n' +
'\u001b[1;31mException\u001b[0m Traceback (most recent call last)\n' +
'Cell \u001b[1;32mIn[3], line 2\u001b[0m\n' +
'\n' +
'unknown source\n' +
'\u001b[0;32m 1\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mthrowEx\u001b[39m():\n' +
'\u001b[1;32m----> 2\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m\n\n' +
'\u001b[1;31mException\u001b[0m\n:';
const formatted = formatStackTrace(stack);
assert.ok(!/<a href=.*>\d<\/a>/.test(formatted), formatted);
});
});