mirror of
https://github.com/jupyter/notebook.git
synced 2025-02-05 12:19:58 +08:00
Merge pull request #6706 from jhamrick/display-prompt-numbers
Correctly display prompt numbers that are 'None'
This commit is contained in:
commit
e3372d532c
@ -410,7 +410,7 @@ define([
|
||||
|
||||
CodeCell.input_prompt_classical = function (prompt_value, lines_number) {
|
||||
var ns;
|
||||
if (prompt_value === undefined) {
|
||||
if (prompt_value === undefined || prompt_value === null) {
|
||||
ns = " ";
|
||||
} else {
|
||||
ns = encodeURIComponent(prompt_value);
|
||||
|
36
IPython/html/tests/notebook/prompt_numbers.js
Normal file
36
IPython/html/tests/notebook/prompt_numbers.js
Normal file
@ -0,0 +1,36 @@
|
||||
|
||||
// Test
|
||||
casper.notebook_test(function () {
|
||||
|
||||
var that = this;
|
||||
var set_prompt = function (i, val) {
|
||||
that.evaluate(function (i, val) {
|
||||
var cell = IPython.notebook.get_cell(i);
|
||||
cell.set_input_prompt(val);
|
||||
}, [i, val]);
|
||||
};
|
||||
|
||||
var get_prompt = function (i) {
|
||||
return that.evaluate(function (i) {
|
||||
var elem = IPython.notebook.get_cell(i).element;
|
||||
return elem.find('div.input_prompt').html();
|
||||
}, [i]);
|
||||
};
|
||||
|
||||
this.then(function () {
|
||||
var a = 'print("a")';
|
||||
var index = this.append_cell(a);
|
||||
|
||||
this.test.assertEquals(get_prompt(index), "In [ ]:", "prompt number is by default");
|
||||
set_prompt(index, 2);
|
||||
this.test.assertEquals(get_prompt(index), "In [2]:", "prompt number is 2");
|
||||
set_prompt(index, 0);
|
||||
this.test.assertEquals(get_prompt(index), "In [0]:", "prompt number is 0");
|
||||
set_prompt(index, "*");
|
||||
this.test.assertEquals(get_prompt(index), "In [*]:", "prompt number is *");
|
||||
set_prompt(index, undefined);
|
||||
this.test.assertEquals(get_prompt(index), "In [ ]:", "prompt number is ");
|
||||
set_prompt(index, null);
|
||||
this.test.assertEquals(get_prompt(index), "In [ ]:", "prompt number is ");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user