Skip to content

Commit a1e8b9e

Browse files
committed
Merge from 3.x: PR #4353
2 parents b61b2e7 + 6bcd201 commit a1e8b9e

File tree

5 files changed

+73
-6
lines changed

5 files changed

+73
-6
lines changed

Diff for: MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
recursive-include spyder *.pot *.po *.svg *.png *.css *.qss *.c, *.cpp, *.html, *.java, *.md, *.R, *.csv, *.pyx
1+
recursive-include spyder *.pot *.po *.svg *.png *.css *.qss *.c, *.cpp, *.html, *.java, *.md, *.R, *.csv, *.pyx, *.ipynb
22
recursive-include spyder_breakpoints *.pot *.po *.svg *.png
33
recursive-include spyder_profiler *.pot *.po *.svg *.png
44
recursive-include spyder_pylint *.pot *.po *.svg *.png

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def run(self):
218218
#==============================================================================
219219
EXTLIST = ['.mo', '.svg', '.png', '.css', '.html', '.js', '.chm', '.ini',
220220
'.txt', '.rst', '.qss', '.ttf', '.json', '.c', '.cpp', '.java',
221-
'.md', '.R', '.csv', '.pyx']
221+
'.md', '.R', '.csv', '.pyx', '.ipynb']
222222
if os.name == 'nt':
223223
SCRIPTS += ['spyder.bat']
224224
EXTLIST += ['.ico']

Diff for: spyder/app/tests/notebook.ipynb

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 1,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"data": {
10+
"text/plain": [
11+
"2"
12+
]
13+
},
14+
"execution_count": 1,
15+
"metadata": {},
16+
"output_type": "execute_result"
17+
}
18+
],
19+
"source": [
20+
"1 + 1"
21+
]
22+
},
23+
{
24+
"cell_type": "code",
25+
"execution_count": null,
26+
"metadata": {
27+
"collapsed": true
28+
},
29+
"outputs": [],
30+
"source": []
31+
}
32+
],
33+
"metadata": {
34+
"kernelspec": {
35+
"display_name": "Python 3",
36+
"language": "python",
37+
"name": "python3"
38+
},
39+
"language_info": {
40+
"codemirror_mode": {
41+
"name": "ipython",
42+
"version": 3
43+
},
44+
"file_extension": ".py",
45+
"mimetype": "text/x-python",
46+
"name": "python",
47+
"nbconvert_exporter": "python",
48+
"pygments_lexer": "ipython3",
49+
"version": "3.5.2+"
50+
}
51+
},
52+
"nbformat": 4,
53+
"nbformat_minor": 2
54+
}

Diff for: spyder/app/tests/test_mainwindow.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
import os
1212
import os.path as osp
13+
import shutil
1314
import tempfile
1415

1516
from flaky import flaky
16-
import nbformat
1717
import numpy as np
1818
from numpy.testing import assert_array_equal
1919
import pytest
@@ -147,8 +147,8 @@ def test_open_notebooks_from_project_explorer(main_window, qtbot):
147147
project_dir = tempfile.mkdtemp()
148148

149149
# Create an empty notebook in the project dir
150-
nb_contents = nbformat.v4.new_notebook()
151-
nbformat.write(nb_contents, osp.join(project_dir, 'notebook.ipynb'))
150+
nb = osp.join(LOCATION, 'notebook.ipynb')
151+
shutil.copy(nb, osp.join(project_dir, 'notebook.ipynb'))
152152

153153
# Create project
154154
with qtbot.waitSignal(projects.sig_project_loaded):
@@ -164,6 +164,19 @@ def test_open_notebooks_from_project_explorer(main_window, qtbot):
164164
# Assert that notebook was open
165165
assert 'notebook.ipynb' in editorstack.get_current_filename()
166166

167+
# Convert notebook to a Python file
168+
projects.explorer.treewidget.convert_notebook(osp.join(project_dir, 'notebook.ipynb'))
169+
170+
# Assert notebook was open
171+
assert 'untitled0.py' in editorstack.get_current_filename()
172+
173+
# Assert its contents are the expected ones
174+
file_text = editorstack.get_current_editor().toPlainText()
175+
assert file_text == '\n# coding: utf-8\n\n# In[1]:\n\n1 + 1\n\n\n# In[ ]:\n\n\n\n\n'
176+
177+
# Close last file (else tests hang here)
178+
editorstack.close_file(force=True)
179+
167180
# Close project
168181
projects.close_project()
169182

Diff for: spyder/utils/tests/test_encoding.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_is_text_file(tmpdir):
3131
def test_files_encodings(expected_encoding, text_file):
3232
with open(os.path.join(__location__, text_file), 'rb') as f:
3333
text = f.read()
34-
assert get_coding(text) == expected_encoding
34+
assert get_coding(text).lower() == expected_encoding.lower()
3535

3636

3737
if __name__ == '__main__':

0 commit comments

Comments
 (0)