run-test.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (c) Jupyter Development Team.
  2. # Distributed under the terms of the Modified BSD License.
  3. from __future__ import print_function, absolute_import
  4. from os.path import join as pjoin
  5. import json
  6. import os
  7. import sys
  8. from jupyterlab.tests.test_app import TestApp
  9. HERE = os.path.abspath(os.path.dirname(__file__))
  10. class JupyterLabTestApp(TestApp):
  11. """A notebook app that runs the jupyterlab karma tests.
  12. """
  13. def get_command(self):
  14. """Get the command to run."""
  15. terminalsAvailable = self.web_app.settings['terminals_available']
  16. # Compatibility with Notebook 4.2.
  17. token = getattr(self, 'token', '')
  18. config = dict(baseUrl=self.connection_url, token=token,
  19. terminalsAvailable=str(terminalsAvailable),
  20. foo='bar')
  21. print('\n\nNotebook config:')
  22. print(json.dumps(config))
  23. with open(pjoin(HERE, 'build', 'injector.js'), 'w') as fid:
  24. fid.write("""
  25. var node = document.createElement('script');
  26. node.id = 'jupyter-config-data';
  27. node.type = 'application/json';
  28. node.textContent = '%s';
  29. document.body.appendChild(node);
  30. """ % json.dumps(config))
  31. return ['karma', 'start'] + sys.argv[1:], dict(cwd=HERE)
  32. if __name__ == '__main__':
  33. JupyterLabTestApp.launch_instance([])