Closed BoPeng closed 5 years ago
@jma7 Please have a look. Note that I changed your add_cell_and_execute_cell_in_kernel
to append_cell_and_execute_cell_in_kernel
without the cell index so that the cell will always be added to the end of notebook. This allows tests to be run in any other without fixed indexes.
Also, I do not understand why this test passes, but fails if I change
command = "sosa = '24' "
to
command = "sosa = f'{24}'"
I doubt that is something wrong with Python3 kernel, but the command works fine outside of selenium.
The error message for the first cell is
File "<ipython-input-1-a279d06a4059>", line 1
sosa = f'{24}' '
^
SyntaxError: EOL while scanning string literal
so for whatever reason an extra quote was added to command
.
The split version is moved to split_test
branch, but the master still fails after merging the tests.
I think it is important to first figure out why
sosa = f'{24}'
fails to execute in Python 3 kernel.
Just want to let you know that in conftest.py, if you change
elif os.environ.get('JUPYTER_TEST_BROWSER') == 'chrome':
#driver = Chrome()
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--window-size=1420,1080')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
driver = Chrome(options=chrome_options)
to
elif os.environ.get('JUPYTER_TEST_BROWSER') == 'chrome':
driver = Chrome()
You could see the actions in real browser to get some ideas of what went wrong.
In test_magic_expand, an extra curly brace was inserted at the end, I have to remove the right curly brace in the content to get the correct expression, don't know why.
idx = notebook.append_and_execute_cell_in_kernel(content=dedent("""\
%expand ${ }
if (${par} > 50) {
cat('A parameter ${par} greater than 50 is specified.');
"""), kernel="R")
In test_magic_preview
command="%preview -n a \na = [1, 2, 3] "
This line gives error.
Good suggestion! The extra brace thing might also explain why a = f'{24}'
becomes a=f'{24}' '
.
I tried
sosa = f'{3*8}'''
The f string got executed without error, so you might use this as a temporary fix. I still don't know what causes the extra quote. I tried to send sosa=f'{24}'
to original notebook cell, the extra quote was still added. So I suspect the problem is in selenium.
If you can execute JS code, you can use something like IPython.notebook.get_cell(idx).set_text()
to set text to cell directly...
self.browser.execute_script("IPython.notebook.get_cell("+str(index)+").set_text("+repr(content)+")")
This seems working.
Good. Let me test.
Great. It seems to be working all right. Thanks!
After I separate the
test_magics
test into tests for each magic (eg. here, each individual test passes but overall only the first test passes, and all others fail with a time out error. It seems that each test needs to conclude in some way.