Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5bedcaf

Browse files
committed
try v2
1 parent e058894 commit 5bedcaf

File tree

8 files changed

+66
-63
lines changed

8 files changed

+66
-63
lines changed

circle.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ machine:
44

55
PLOTLY_PACKAGE_ROOT: /home/ubuntu/${CIRCLE_PROJECT_REPONAME}
66
PLOTLY_CONFIG_DIR: ${HOME}/.plotly
7-
PLOTLY_PYTHON_VERSIONS: 3.3.3 3.4.1
7+
PLOTLY_PYTHON_VERSIONS: 2.7.8 3.3.3 3.4.1
88
PLOTLY_CORE_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/requirements.txt
99
PLOTLY_OPTIONAL_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/optional-requirements.txt
1010
PLOTLY_JUPYTER_TEST_DIR: ${PLOTLY_PACKAGE_ROOT}/plotly/tests/test_core/test_jupyter
@@ -48,6 +48,6 @@ test:
4848
- sudo chmod -R 777 ${PLOTLY_CONFIG_DIR} && python -c "import plotly"
4949

5050
# test core things in the general 2.7 version that circle has
51-
- export PYENV_VERSION=python2 && nosetests -x plotly/tests/test_core --with-coverage --cover-package=plotly
51+
- nosetests -x plotly/tests/test_core --with-coverage --cover-package=plotly
5252
- mkdir "${CIRCLE_ARTIFACTS}/2.7" || true
5353
- coverage html -d "${CIRCLE_ARTIFACTS}/2.7" --title=2.7

circle/setup.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,4 @@ for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
3838
# install optional (including test) requirements
3939
pip install -r ${PLOTLY_OPTIONAL_REQUIREMENTS_FILE} ||
4040
error_exit "${SIG} ${LINENO}: can't install optional for Python ${version}."
41-
42-
# add python version to available jupyter kernel list
43-
python -m ipykernel install --user --name ${version}
44-
echo "${SIG} jupyter kernelspec list"
45-
jupyter kernelspec list
4641
done

optional-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ numpy
1414
## testing dependencies ##
1515
nose
1616
coverage
17+
ipykernel
1718

1819
## ipython ##
1920
ipython

plotly/tests/test_core/test_jupyter/js_tests/connected_false.js

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,30 @@
22

33
var test = require('../lib/tape-wrapper');
44

5-
test('should have the correct number of script tags', function(t) {
5+
test('should load plotly.js', function(t) {
66
t.plan(1);
77

8-
var nodes = document.querySelectorAll('script');
9-
t.equal(nodes.length, 8);
8+
window.require(['plotly'], function(Plotly) {
9+
t.equal(typeof Plotly, 'object');
10+
});
11+
});
12+
13+
test('should have one plotly.js graph', function(t) {
14+
t.plan(1);
15+
16+
var nodes = document.querySelectorAll('.js-plotly-plot');
17+
t.equal(nodes.length, 1);
1018
});
1119

12-
// test('should have one plotly.js graph', function(t) {
13-
// t.plan(1);
14-
//
15-
// var nodes = document.querySelectorAll('.js-plotly-plot');
16-
// t.equal(nodes.length, 1);
17-
// });
18-
//
19-
// test('should inject raw plotly.js code into DOM', function(t) {
20-
// t.plan(1);
21-
//
22-
// var nodes = document.querySelectorAll('script');
23-
// nodes = Array.prototype.slice.call(nodes, 0, 10);
24-
//
25-
// var results = nodes.filter(function(node) {
26-
// return node.innerHTML.substr(0, 19) === 'if(!window.Plotly){';
27-
// });
28-
//
29-
// t.equal(results.length, 1);
30-
// });
20+
test('should inject raw plotly.js code into DOM', function(t) {
21+
t.plan(1);
22+
23+
var nodes = document.querySelectorAll('script');
24+
nodes = Array.prototype.slice.call(nodes, 0, 10);
25+
26+
var results = nodes.filter(function(node) {
27+
return node.innerHTML.substr(0, 19) === 'if(!window.Plotly){';
28+
});
29+
30+
t.equal(results.length, 1);
31+
});

plotly/tests/test_core/test_jupyter/js_tests/connected_true.js

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,30 @@
22

33
var test = require('../lib/tape-wrapper');
44

5-
test('should have the correct number of script tags', function(t) {
5+
test('should load plotly.js', function(t) {
66
t.plan(1);
77

8-
var nodes = document.querySelectorAll('script');
9-
t.equal(nodes.length, 9);
8+
window.require(['plotly'], function(Plotly) {
9+
t.equal(typeof Plotly, 'object');
10+
});
11+
});
12+
13+
test('should have one plotly.js graph', function(t) {
14+
t.plan(1);
15+
16+
var nodes = document.querySelectorAll('.js-plotly-plot');
17+
t.equal(nodes.length, 1);
1018
});
1119

12-
// test('should not crash browser', function(t) {
13-
// t.plan(1);
14-
// window.onload = function() { t.pass('window onload'); };
15-
// });
16-
//
17-
// test('should have one plotly.js graph', function(t) {
18-
// t.plan(1);
19-
//
20-
// var nodes = document.querySelectorAll('.js-plotly-plot');
21-
// t.equal(nodes.length, 1);
22-
// });
23-
//
24-
// test('should link to plotly.js CDN', function(t) {
25-
// t.plan(1);
26-
//
27-
// var nodes = document.querySelectorAll('script');
28-
// nodes = Array.prototype.slice.call(nodes, 0);
29-
//
30-
// var results = nodes.filter(function(node) {
31-
// return node.src === 'https://cdn.plot.ly/plotly-latest.min.js';
32-
// });
33-
//
34-
// t.equal(results.length, 1);
35-
// });
20+
test('should link to plotly.js CDN', function(t) {
21+
t.plan(1);
22+
23+
var nodes = document.querySelectorAll('script');
24+
nodes = Array.prototype.slice.call(nodes, 0);
25+
26+
var results = nodes.filter(function(node) {
27+
return node.src === 'https://cdn.plot.ly/plotly-latest.min.js';
28+
});
29+
30+
t.equal(results.length, 1);
31+
});

plotly/tests/test_core/test_jupyter/lib/tape-wrapper.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
'use strict';
2+
13
var test = require('tape');
24
var xhr = require('xhr');
5+
var domready = require('domready');
36

47
var cnt = 0;
58
var noop = function() {};
@@ -19,4 +22,12 @@ test.onFinish(function() {
1922
post('done');
2023
});
2124

25+
test('should not crash browser', function(t) {
26+
t.plan(1);
27+
28+
domready(function() {
29+
t.pass('domready');
30+
});
31+
});
32+
2233
module.exports = test;

plotly/tests/test_core/test_jupyter/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"browserify": "^13.1.0",
1212
"cheerio": "^0.20.0",
1313
"chrome-launch": "^1.1.4",
14+
"domready": "^1.0.8",
1415
"ecstatic": "^2.1.0",
1516
"tap-parser": "^2.0.0",
1617
"tape": "^4.6.0",

plotly/tests/test_core/test_jupyter/test_jupyter.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import nbformat
66
from nbconvert import HTMLExporter
77
from nbconvert.preprocessors import ExecutePreprocessor
8+
from ipykernel import kernelspec
89

910
from unittest import TestCase
1011
from os import path, environ
@@ -24,16 +25,13 @@ def setUp(self):
2425
self.path_test_html = path.join(PATH_FIXTURES, self.name + '.html')
2526
self.path_test_js = path.join(PATH_JS_TESTS, self.name + '.js')
2627

28+
self.kernel_name = kernelspec.KERNEL_NAME
29+
2730
with open(self.path_test_nb, 'r') as f:
2831
self.nb = nbformat.read(f, as_version=4)
2932

30-
if 'PYENV_VERSION' in environ:
31-
kernel_name = environ['PYENV_VERSION']
32-
print(kernel_name)
33-
self.ep = ExecutePreprocessor(timeout=600, kernel_name=kernel_name)
34-
else:
35-
print('no kernel found in environment')
36-
self.ep = ExecutePreprocessor(timeout=600)
33+
self.ep = ExecutePreprocessor(timeout=600,
34+
kernel_name=self.kernel_name)
3735

3836
self.html_exporter = HTMLExporter()
3937

0 commit comments

Comments
 (0)