瀏覽代碼

Merge pull request #4604 from jirivrany/remove-uuid

Remove UUID
Jason Grout 6 年之前
父節點
當前提交
ab95c4ef04
共有 40 個文件被更改,包括 261 次插入212 次删除
  1. 4 2
      packages/apputils/src/clientsession.tsx
  2. 3 3
      packages/apputils/src/mainareawidget.ts
  3. 4 2
      packages/cells/src/model.ts
  4. 2 2
      packages/codemirror/src/editor.ts
  5. 4 2
      packages/console/src/panel.ts
  6. 0 1
      packages/coreutils/src/index.ts
  7. 0 17
      packages/coreutils/src/uuid.ts
  8. 2 2
      packages/docmanager/src/manager.ts
  9. 4 3
      packages/notebook-extension/src/index.ts
  10. 6 4
      packages/notebook/src/model.ts
  11. 8 3
      packages/services/src/kernel/default.ts
  12. 4 2
      packages/services/src/kernel/messages.ts
  13. 77 29
      packages/services/test/src/config/config.spec.ts
  14. 22 17
      packages/services/test/src/kernel/ikernel.spec.ts
  15. 9 6
      packages/services/test/src/kernel/kernel.spec.ts
  16. 6 6
      packages/services/test/src/session/manager.spec.ts
  17. 23 21
      packages/services/test/src/session/session.spec.ts
  18. 5 3
      packages/services/test/src/terminal/terminal.spec.ts
  19. 14 12
      packages/services/test/src/utils.ts
  20. 0 1
      tests/test-apputils/package.json
  21. 2 2
      tests/test-apputils/src/clientsession.spec.ts
  22. 1 1
      tests/test-console/package.json
  23. 2 2
      tests/test-console/src/foreign.spec.ts
  24. 0 26
      tests/test-coreutils/src/uuid.spec.ts
  25. 1 1
      tests/test-csvviewer/package.json
  26. 2 2
      tests/test-csvviewer/src/widget.spec.ts
  27. 1 1
      tests/test-docmanager/package.json
  28. 6 2
      tests/test-docmanager/src/savehandler.spec.ts
  29. 2 2
      tests/test-docmanager/src/widgetmanager.spec.ts
  30. 0 1
      tests/test-docregistry/package.json
  31. 16 8
      tests/test-docregistry/src/context.spec.ts
  32. 2 2
      tests/test-docregistry/src/registry.spec.ts
  33. 1 0
      tests/test-filebrowser/package.json
  34. 11 9
      tests/test-filebrowser/src/model.spec.ts
  35. 1 1
      tests/test-fileeditor/package.json
  36. 4 4
      tests/test-fileeditor/src/widget.spec.ts
  37. 1 1
      tests/test-imageviewer/package.json
  38. 3 3
      tests/test-imageviewer/src/widget.spec.ts
  39. 2 2
      tests/test-rendermime/src/registry.spec.ts
  40. 6 4
      tests/utils.ts

+ 4 - 2
packages/apputils/src/clientsession.tsx

@@ -1,7 +1,9 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { PathExt, uuid } from '@jupyterlab/coreutils';
+import { PathExt } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import {
   Kernel,
@@ -213,7 +215,7 @@ export class ClientSession implements IClientSession {
    */
   constructor(options: ClientSession.IOptions) {
     this.manager = options.manager;
-    this._path = options.path || uuid();
+    this._path = options.path || UUID.uuid4();
     this._type = options.type || '';
     this._name = options.name || '';
     this._setBusy = options.setBusy;

+ 3 - 3
packages/apputils/src/mainareawidget.ts

@@ -1,7 +1,7 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { Message } from '@phosphor/messaging';
 
@@ -29,7 +29,7 @@ export class MainAreaWidget<T extends Widget = Widget> extends Widget {
   constructor(options: MainAreaWidget.IOptions<T>) {
     super(options);
     this.addClass('jp-MainAreaWidget');
-    this.id = uuid();
+    this.id = UUID.uuid4();
 
     const content = (this._content = options.content);
     const toolbar = (this._toolbar = options.toolbar || new Toolbar());
@@ -43,7 +43,7 @@ export class MainAreaWidget<T extends Widget = Widget> extends Widget {
     layout.addWidget(content);
 
     if (!content.id) {
-      content.id = uuid();
+      content.id = UUID.uuid4();
     }
     content.node.tabIndex = -1;
 

+ 4 - 2
packages/cells/src/model.ts

@@ -11,7 +11,9 @@ import { IAttachmentsModel, AttachmentsModel } from '@jupyterlab/attachments';
 
 import { CodeEditor } from '@jupyterlab/codeeditor';
 
-import { IChangedArgs, nbformat, uuid } from '@jupyterlab/coreutils';
+import { IChangedArgs, nbformat } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import {
   IObservableJSON,
@@ -154,7 +156,7 @@ export class CellModel extends CodeEditor.Model implements ICellModel {
   constructor(options: CellModel.IOptions) {
     super({ modelDB: options.modelDB });
 
-    this.id = options.id || uuid();
+    this.id = options.id || UUID.uuid4();
 
     this.value.changed.connect(this.onGenericChange, this);
 

+ 2 - 2
packages/codemirror/src/editor.ts

@@ -15,7 +15,7 @@ import { showDialog } from '@jupyterlab/apputils';
 
 import { CodeEditor } from '@jupyterlab/codeeditor';
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import {
   IObservableMap,
@@ -85,7 +85,7 @@ export class CodeMirrorEditor implements CodeEditor.IEditor {
     host.addEventListener('blur', this, true);
     host.addEventListener('scroll', this, true);
 
-    this._uuid = options.uuid || uuid();
+    this._uuid = options.uuid || UUID.uuid4();
 
     // Handle selection style.
     let style = options.selectionStyle || {};

+ 4 - 2
packages/console/src/panel.ts

@@ -5,7 +5,9 @@ import { ClientSession, IClientSession } from '@jupyterlab/apputils';
 
 import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
 
-import { PathExt, Time, uuid } from '@jupyterlab/coreutils';
+import { PathExt, Time } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { RenderMimeRegistry } from '@jupyterlab/rendermime';
 
@@ -50,7 +52,7 @@ export class ConsolePanel extends Panel {
       options.contentFactory || ConsolePanel.defaultContentFactory);
     let count = Private.count++;
     if (!path) {
-      path = `${basePath || ''}/console-${count}-${uuid()}`;
+      path = `${basePath || ''}/console-${count}-${UUID.uuid4()}`;
     }
 
     let session = (this._session = new ClientSession({

+ 0 - 1
packages/coreutils/src/index.ts

@@ -13,4 +13,3 @@ export * from './statedb';
 export * from './text';
 export * from './time';
 export * from './url';
-export * from './uuid';

+ 0 - 17
packages/coreutils/src/uuid.ts

@@ -1,17 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-/**
- * Get a random hex string (not a formal UUID).
- *
- * @param length - The length of the hex string.
- */
-export function uuid(length: number = 32): string {
-  let s = new Array<string>(length);
-  let hexDigits = '0123456789abcdef';
-  let nChars = hexDigits.length;
-  for (let i = 0; i < length; i++) {
-    s[i] = hexDigits.charAt(Math.floor(Math.random() * nChars));
-  }
-  return s.join('');
-}

+ 2 - 2
packages/docmanager/src/manager.ts

@@ -3,7 +3,7 @@
 
 import { IClientSession } from '@jupyterlab/apputils';
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import {
   DocumentRegistry,
@@ -367,7 +367,7 @@ export class DocumentManager implements IDisposable {
   overwrite(oldPath: string, newPath: string): Promise<Contents.IModel> {
     // Cleanly overwrite the file by moving it, making sure the original does
     // not exist, and then renaming to the new path.
-    const tempPath = `${newPath}.${uuid()}`;
+    const tempPath = `${newPath}.${UUID.uuid4()}`;
     const cb = () => this.rename(tempPath, newPath);
     return this.rename(oldPath, tempPath)
       .then(() => {

+ 4 - 3
packages/notebook-extension/src/index.ts

@@ -22,10 +22,11 @@ import {
   ISettingRegistry,
   IStateDB,
   PageConfig,
-  URLExt,
-  uuid
+  URLExt
 } from '@jupyterlab/coreutils';
 
+import { UUID } from '@phosphor/coreutils';
+
 import { IFileBrowserFactory } from '@jupyterlab/filebrowser';
 
 import { ILauncher } from '@jupyterlab/launcher';
@@ -1328,7 +1329,7 @@ function addCommands(
       const content = (nb.activeCell as CodeCell).cloneOutputArea();
       // Create a MainAreaWidget
       const widget = new MainAreaWidget({ content });
-      widget.id = `LinkedOutputView-${uuid()}`;
+      widget.id = `LinkedOutputView-${UUID.uuid4()}`;
       widget.title.label = 'Output View';
       widget.title.icon = NOTEBOOK_ICON_CLASS;
       widget.title.caption = current.title.label

+ 6 - 4
packages/notebook/src/model.ts

@@ -14,7 +14,9 @@ import {
   CellModel
 } from '@jupyterlab/cells';
 
-import { nbformat, uuid } from '@jupyterlab/coreutils';
+import { nbformat } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import {
   IObservableJSON,
@@ -423,7 +425,7 @@ export namespace NotebookModel {
       }
       if (this.modelDB) {
         if (!options.id) {
-          options.id = uuid();
+          options.id = UUID.uuid4();
         }
         options.modelDB = this.modelDB.view(options.id);
       }
@@ -441,7 +443,7 @@ export namespace NotebookModel {
     createMarkdownCell(options: CellModel.IOptions): IMarkdownCellModel {
       if (this.modelDB) {
         if (!options.id) {
-          options.id = uuid();
+          options.id = UUID.uuid4();
         }
         options.modelDB = this.modelDB.view(options.id);
       }
@@ -459,7 +461,7 @@ export namespace NotebookModel {
     createRawCell(options: CellModel.IOptions): IRawCellModel {
       if (this.modelDB) {
         if (!options.id) {
-          options.id = uuid();
+          options.id = UUID.uuid4();
         }
         options.modelDB = this.modelDB.view(options.id);
       }

+ 8 - 3
packages/services/src/kernel/default.ts

@@ -1,7 +1,9 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { URLExt, uuid } from '@jupyterlab/coreutils';
+import { URLExt } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { ArrayExt, each, find } from '@phosphor/algorithm';
 
@@ -53,7 +55,7 @@ export class DefaultKernel implements Kernel.IKernel {
     this._id = id;
     this.serverSettings =
       options.serverSettings || ServerConnection.makeSettings();
-    this._clientId = options.clientId || uuid();
+    this._clientId = options.clientId || UUID.uuid4();
     this._username = options.username || '';
     this._futures = new Map<string, KernelFutureHandler>();
     this._comms = new Map<string, Kernel.IComm>();
@@ -614,7 +616,10 @@ export class DefaultKernel implements Kernel.IKernel {
    * #### Notes
    * If a client-side comm already exists with the given commId, it is returned.
    */
-  connectToComm(targetName: string, commId: string = uuid()): Kernel.IComm {
+  connectToComm(
+    targetName: string,
+    commId: string = UUID.uuid4()
+  ): Kernel.IComm {
     if (this._comms.has(commId)) {
       return this._comms.get(commId);
     }

+ 4 - 2
packages/services/src/kernel/messages.ts

@@ -1,7 +1,9 @@
 // Copyright (c) Jupyter Development Team.
 // Distributed under the terms of the Modified BSD License.
 
-import { nbformat, uuid } from '@jupyterlab/coreutils';
+import { nbformat } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { JSONObject, JSONValue } from '@phosphor/coreutils';
 
@@ -25,7 +27,7 @@ export namespace KernelMessage {
         username: options.username || '',
         version: '5.2',
         session: options.session,
-        msg_id: options.msgId || uuid(),
+        msg_id: options.msgId || UUID.uuid4(),
         msg_type: options.msgType
       },
       parent_header: {},

+ 77 - 29
packages/services/test/src/config/config.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { JSONObject } from '@phosphor/coreutils';
 
@@ -20,27 +20,46 @@ import {
   getRequestHandler
 } from '../utils';
 
+/**
+ * Generate a random config section name.
+ *
+ * #### Notes
+ * Config sections cannot have dashes (see
+ * https://github.com/jupyter/notebook/blob/b2edf8963cc017733f264cca35fd6584f328c8b6/notebook/services/config/handlers.py#L36),
+ * so we remove the dashes.
+ */
+function randomName() {
+  return UUID.uuid4().replace(/-/g, '');
+}
+
 describe('config', () => {
   describe('ConfigSection.create()', () => {
     it('should load a config', () => {
-      return ConfigSection.create({ name: uuid() }).then(config => {
+      return ConfigSection.create({ name: randomName() }).then(config => {
+        expect(Object.keys(config.data).length).to.be(0);
+      });
+    });
+
+    it('should load a config', () => {
+      return ConfigSection.create({ name: randomName() }).then(config => {
         expect(Object.keys(config.data).length).to.be(0);
       });
     });
 
     it('should accept server settings', () => {
       let serverSettings = makeSettings();
-      return ConfigSection.create({ name: uuid(), serverSettings }).then(
-        config => {
-          expect(Object.keys(config.data).length).to.be(0);
-        }
-      );
+      return ConfigSection.create({
+        name: randomName(),
+        serverSettings
+      }).then(config => {
+        expect(Object.keys(config.data).length).to.be(0);
+      });
     });
 
     it('should fail for an incorrect response', done => {
       let serverSettings = getRequestHandler(201, {});
       let configPromise = ConfigSection.create({
-        name: uuid(),
+        name: randomName(),
         serverSettings
       });
       expectFailure(configPromise, done, 'Invalid response: 201 Created');
@@ -50,7 +69,7 @@ describe('config', () => {
   describe('#update()', () => {
     it('should update a config', () => {
       let config: IConfigSection;
-      return ConfigSection.create({ name: uuid() })
+      return ConfigSection.create({ name: randomName() })
         .then(c => {
           config = c;
           return config.update({ foo: 'baz', spam: 'eggs' });
@@ -66,7 +85,7 @@ describe('config', () => {
     it('should accept server settings', () => {
       let config: IConfigSection;
       let serverSettings = makeSettings();
-      return ConfigSection.create({ name: uuid(), serverSettings })
+      return ConfigSection.create({ name: randomName(), serverSettings })
         .then(c => {
           config = c;
           return config.update({ foo: 'baz', spam: 'eggs' });
@@ -80,7 +99,7 @@ describe('config', () => {
     });
 
     it('should fail for an incorrect response', done => {
-      ConfigSection.create({ name: uuid() })
+      ConfigSection.create({ name: randomName() })
         .then(config => {
           handleRequest(config, 201, {});
           let update = config.update({ foo: 'baz' });
@@ -96,8 +115,14 @@ describe('jupyter.services - ConfigWithDefaults', () => {
     it('should complete properly', () => {
       let defaults: JSONObject = { spam: 'eggs' };
       let className = 'testclass';
-      return ConfigSection.create({ name: uuid() }).then(section => {
-        let config = new ConfigWithDefaults({ section, defaults, className });
+      return ConfigSection.create({
+        name: randomName()
+      }).then(section => {
+        let config = new ConfigWithDefaults({
+          section,
+          defaults,
+          className
+        });
         expect(config).to.be.a(ConfigWithDefaults);
       });
     });
@@ -107,8 +132,14 @@ describe('jupyter.services - ConfigWithDefaults', () => {
     it('should get a new config value', () => {
       let defaults: JSONObject = { foo: 'bar' };
       let className = 'testclass';
-      return ConfigSection.create({ name: uuid() }).then(section => {
-        let config = new ConfigWithDefaults({ section, defaults, className });
+      return ConfigSection.create({
+        name: randomName()
+      }).then(section => {
+        let config = new ConfigWithDefaults({
+          section,
+          defaults,
+          className
+        });
         let data = config.get('foo');
         expect(data).to.be('bar');
       });
@@ -117,8 +148,14 @@ describe('jupyter.services - ConfigWithDefaults', () => {
     it('should get a default config value', () => {
       let defaults: JSONObject = { spam: 'eggs' };
       let className = 'testclass';
-      return ConfigSection.create({ name: uuid() }).then(section => {
-        let config = new ConfigWithDefaults({ section, defaults, className });
+      return ConfigSection.create({
+        name: randomName()
+      }).then(section => {
+        let config = new ConfigWithDefaults({
+          section,
+          defaults,
+          className
+        });
         let data = config.get('spam');
         expect(data).to.be('eggs');
       });
@@ -127,8 +164,14 @@ describe('jupyter.services - ConfigWithDefaults', () => {
     it('should get a default config value with no class', () => {
       let defaults: JSONObject = { spam: 'eggs' };
       let className = 'testclass';
-      return ConfigSection.create({ name: uuid() }).then(section => {
-        let config = new ConfigWithDefaults({ section, defaults, className });
+      return ConfigSection.create({
+        name: randomName()
+      }).then(section => {
+        let config = new ConfigWithDefaults({
+          section,
+          defaults,
+          className
+        });
         let data = config.get('spam');
         expect(data).to.be('eggs');
       });
@@ -138,13 +181,18 @@ describe('jupyter.services - ConfigWithDefaults', () => {
       let defaults: JSONObject = { foo: true };
       let className = 'testclass';
       let serverSettings = getRequestHandler(200, { foo: false });
-      return ConfigSection.create({ name: uuid(), serverSettings }).then(
-        section => {
-          let config = new ConfigWithDefaults({ section, defaults, className });
-          let data = config.get('foo');
-          expect(data).to.not.be.ok();
-        }
-      );
+      return ConfigSection.create({
+        name: randomName(),
+        serverSettings
+      }).then(section => {
+        let config = new ConfigWithDefaults({
+          section,
+          defaults,
+          className
+        });
+        let data = config.get('foo');
+        expect(data).to.not.be.ok();
+      });
     });
   });
 
@@ -152,7 +200,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
     it('should set a value in a class immediately', () => {
       let className = 'testclass';
       let section: IConfigSection;
-      return ConfigSection.create({ name: uuid() })
+      return ConfigSection.create({ name: randomName() })
         .then(s => {
           section = s;
           let config = new ConfigWithDefaults({ section, className });
@@ -166,7 +214,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
 
     it('should set a top level value', () => {
       let section: IConfigSection;
-      return ConfigSection.create({ name: uuid() })
+      return ConfigSection.create({ name: randomName() })
         .then(s => {
           section = s;
           let config = new ConfigWithDefaults({ section });
@@ -181,7 +229,7 @@ describe('jupyter.services - ConfigWithDefaults', () => {
 
     it('should fail for an invalid response', done => {
       let serverSettings = getRequestHandler(200, {});
-      ConfigSection.create({ name: uuid(), serverSettings })
+      ConfigSection.create({ name: randomName(), serverSettings })
         .then(section => {
           handleRequest(section, 201, { foo: 'bar' });
           let config = new ConfigWithDefaults({ section });

+ 22 - 17
packages/services/test/src/kernel/ikernel.spec.ts

@@ -3,7 +3,9 @@
 
 import expect = require('expect.js');
 
-import { PageConfig, uuid } from '@jupyterlab/coreutils';
+import { PageConfig } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { JSONObject, PromiseDelegate } from '@phosphor/coreutils';
 
@@ -82,7 +84,7 @@ describe('Kernel.IKernel', () => {
     it('should be emitted regardless of the sender', async () => {
       const tester = new KernelTester();
       const kernel = await tester.start();
-      const msgId = uuid();
+      const msgId = UUID.uuid4();
       const emission = testEmission(kernel.iopubMessage, {
         find: (k, msg) => msg.header.msg_id === msgId
       });
@@ -112,7 +114,7 @@ describe('Kernel.IKernel', () => {
 
     it('should be emitted for an unhandled message', async () => {
       const kernel = await tester.start();
-      const msgId = uuid();
+      const msgId = UUID.uuid4();
       const emission = testEmission(kernel.unhandledMessage, {
         find: (k, msg) => msg.header.msg_id === msgId
       });
@@ -132,7 +134,7 @@ describe('Kernel.IKernel', () => {
 
       // We'll send two messages, first an iopub message, then a shell message.
       // The unhandledMessage signal should only emit once for the shell message.
-      const msgId = uuid();
+      const msgId = UUID.uuid4();
       const emission = testEmission(kernel.unhandledMessage, {
         test: (k, msg) => {
           expect(msg.header.msg_id).to.be(msgId);
@@ -140,7 +142,7 @@ describe('Kernel.IKernel', () => {
       });
 
       // Send an iopub message.
-      tester.sendStatus(uuid(), 'idle');
+      tester.sendStatus(UUID.uuid4(), 'idle');
 
       // Send a shell message.
       let msg = KernelMessage.createShellMessage({
@@ -207,7 +209,7 @@ describe('Kernel.IKernel', () => {
 
     it('should be emitted for an unhandled message', async () => {
       const kernel = await tester.start();
-      const msgId = uuid();
+      const msgId = UUID.uuid4();
 
       const emission = testEmission(kernel.anyMessage, {
         test: (k, args) => {
@@ -342,7 +344,7 @@ describe('Kernel.IKernel', () => {
       const dead = testEmission(kernel.statusChanged, {
         find: () => kernel.status === 'dead'
       });
-      tester.sendStatus(uuid(), 'dead');
+      tester.sendStatus(UUID.uuid4(), 'dead');
       await dead;
       tester.dispose();
     });
@@ -359,10 +361,10 @@ describe('Kernel.IKernel', () => {
       });
 
       // This invalid status is not emitted.
-      tester.sendStatus(uuid(), 'invalid-status' as Kernel.Status);
+      tester.sendStatus(UUID.uuid4(), 'invalid-status' as Kernel.Status);
 
       // This valid status is emitted.
-      tester.sendStatus(uuid(), 'busy');
+      tester.sendStatus(UUID.uuid4(), 'busy');
 
       await emission;
       tester.dispose();
@@ -445,7 +447,7 @@ describe('Kernel.IKernel', () => {
       const tester = new KernelTester();
       let kernel = await tester.start();
       let done = new PromiseDelegate<void>();
-      let msgId = uuid();
+      let msgId = UUID.uuid4();
 
       tester.onMessage(msg => {
         try {
@@ -475,7 +477,7 @@ describe('Kernel.IKernel', () => {
       const tester = new KernelTester();
       let kernel = await tester.start();
       let done = new PromiseDelegate<void>();
-      let msgId = uuid();
+      let msgId = UUID.uuid4();
 
       tester.onMessage(msg => {
         try {
@@ -516,7 +518,7 @@ describe('Kernel.IKernel', () => {
       const dead = testEmission(kernel.statusChanged, {
         find: () => kernel.status === 'dead'
       });
-      tester.sendStatus(uuid(), 'dead');
+      tester.sendStatus(UUID.uuid4(), 'dead');
       await dead;
 
       let options: KernelMessage.IOptions = {
@@ -604,7 +606,7 @@ describe('Kernel.IKernel', () => {
       const dead = testEmission(kernel.statusChanged, {
         find: () => kernel.status === 'dead'
       });
-      tester.sendStatus(uuid(), 'dead');
+      tester.sendStatus(UUID.uuid4(), 'dead');
       await dead;
       await expectFailure(kernel.interrupt(), null, 'Kernel is dead');
       tester.dispose();
@@ -689,7 +691,10 @@ describe('Kernel.IKernel', () => {
     });
 
     it('should throw an error for an invalid response', async () => {
-      handleRequest(defaultKernel, 200, { id: uuid(), name: 'foo' });
+      handleRequest(defaultKernel, 200, {
+        id: UUID.uuid4(),
+        name: 'foo'
+      });
       let shutdown = defaultKernel.shutdown();
       await expectFailure(shutdown, null, 'Invalid response: 200 OK');
     });
@@ -714,7 +719,7 @@ describe('Kernel.IKernel', () => {
       const dead = testEmission(kernel.statusChanged, {
         find: () => kernel.status === 'dead'
       });
-      tester.sendStatus(uuid(), 'dead');
+      tester.sendStatus(UUID.uuid4(), 'dead');
       await dead;
       await expectFailure(kernel.shutdown(), null, 'Kernel is dead');
       tester.dispose();
@@ -760,7 +765,7 @@ describe('Kernel.IKernel', () => {
       const dead = testEmission(kernel.statusChanged, {
         find: () => kernel.status === 'dead'
       });
-      tester.sendStatus(uuid(), 'dead');
+      tester.sendStatus(UUID.uuid4(), 'dead');
       await dead;
       expectFailure(kernel.requestComplete(options), null, 'Kernel is dead');
       tester.dispose();
@@ -827,7 +832,7 @@ describe('Kernel.IKernel', () => {
       const dead = testEmission(kernel.statusChanged, {
         find: () => kernel.status === 'dead'
       });
-      tester.sendStatus(uuid(), 'dead');
+      tester.sendStatus(UUID.uuid4(), 'dead');
       await dead;
       expect(() => {
         kernel.sendInputReply({ value: 'test' });

+ 9 - 6
packages/services/test/src/kernel/kernel.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { toArray } from '@phosphor/algorithm';
 
@@ -65,7 +65,7 @@ describe('kernel', () => {
     });
 
     it('should throw an error for an invalid model', done => {
-      let data = { id: uuid(), name: 'test' };
+      let data = { id: UUID.uuid4(), name: 'test' };
       let settings = getRequestHandler(200, data);
       let promise = Kernel.listRunning(settings);
       expectFailure(promise, done, 'Invalid kernel list');
@@ -123,19 +123,22 @@ describe('kernel', () => {
     });
 
     it('should throw an error for an invalid kernel id', done => {
-      let serverSettings = getRequestHandler(201, { id: uuid() });
+      let serverSettings = getRequestHandler(201, { id: UUID.uuid4() });
       let kernelPromise = Kernel.startNew({ serverSettings });
       expectFailure(kernelPromise, done);
     });
 
     it('should throw an error for another invalid kernel id', done => {
-      let serverSettings = getRequestHandler(201, { id: uuid(), name: 1 });
+      let serverSettings = getRequestHandler(201, {
+        id: UUID.uuid4(),
+        name: 1
+      });
       let kernelPromise = Kernel.startNew({ serverSettings });
       expectFailure(kernelPromise, done);
     });
 
     it('should throw an error for an invalid response', done => {
-      let data = { id: uuid(), name: 'foo' };
+      let data = { id: UUID.uuid4(), name: 'foo' };
       let serverSettings = getRequestHandler(200, data);
       let kernelPromise = Kernel.startNew({ serverSettings });
       expectFailure(kernelPromise, done, 'Invalid response: 200 OK');
@@ -185,7 +188,7 @@ describe('kernel', () => {
     });
 
     it('should handle a 404 error', () => {
-      return Kernel.shutdown(uuid());
+      return Kernel.shutdown(UUID.uuid4());
     });
   });
 

+ 6 - 6
packages/services/test/src/session/manager.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { toArray } from '@phosphor/algorithm';
 
@@ -24,7 +24,7 @@ import { KERNELSPECS, handleRequest } from '../utils';
  * Start a new session on with a default name.
  */
 function startNew(manager: SessionManager): Promise<Session.ISession> {
-  return manager.startNew({ path: uuid() });
+  return manager.startNew({ path: UUID.uuid4() });
 }
 
 describe('session/manager', () => {
@@ -32,7 +32,7 @@ describe('session/manager', () => {
   let session: Session.ISession;
 
   before(async () => {
-    session = await Session.startNew({ path: uuid() });
+    session = await Session.startNew({ path: UUID.uuid4() });
     await session.kernel.ready;
   });
 
@@ -149,7 +149,7 @@ describe('session/manager', () => {
           called = true;
         });
         return session
-          .setPath(uuid())
+          .setPath(UUID.uuid4())
           .then(() => {
             return manager.refreshRunning();
           })
@@ -199,7 +199,7 @@ describe('session/manager', () => {
 
     describe('#startNew()', () => {
       it('should start a session', async () => {
-        let session = await manager.startNew({ path: uuid() });
+        let session = await manager.startNew({ path: UUID.uuid4() });
         await session.kernel.ready;
         expect(session.id).to.be.ok();
         return session.shutdown();
@@ -210,7 +210,7 @@ describe('session/manager', () => {
         manager.runningChanged.connect(() => {
           called = true;
         });
-        let session = await manager.startNew({ path: uuid() });
+        let session = await manager.startNew({ path: UUID.uuid4() });
         await session.kernel.ready;
         expect(called).to.be(true);
       });

+ 23 - 21
packages/services/test/src/session/session.spec.ts

@@ -3,7 +3,9 @@
 
 import expect = require('expect.js');
 
-import { PageConfig, uuid } from '@jupyterlab/coreutils';
+import { PageConfig } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { toArray } from '@phosphor/algorithm';
 
@@ -46,7 +48,7 @@ function createSessionOptions(
  * Start a new session with a unique name.
  */
 function startNew(): Promise<Session.ISession> {
-  return Session.startNew({ path: uuid() });
+  return Session.startNew({ path: UUID.uuid4() });
 }
 
 describe('session', () => {
@@ -115,7 +117,7 @@ describe('session', () => {
 
     it('should accept ajax options', done => {
       let serverSettings = makeSettings();
-      let options: Session.IOptions = { path: uuid(), serverSettings };
+      let options: Session.IOptions = { path: UUID.uuid4(), serverSettings };
       Session.startNew(options).then(s => {
         session = s;
         expect(session.id).to.ok();
@@ -206,7 +208,7 @@ describe('session', () => {
     });
 
     it('should handle a 404 status', () => {
-      return Session.shutdown(uuid());
+      return Session.shutdown(UUID.uuid4());
     });
   });
 
@@ -280,7 +282,7 @@ describe('session', () => {
         const tester = new SessionTester();
         const session = await tester.startSession();
         await session.kernel.ready;
-        const msgId = uuid();
+        const msgId = UUID.uuid4();
         const emission = testEmission(session.unhandledMessage, {
           find: (k, msg) => msg.header.msg_id === msgId
         });
@@ -300,7 +302,7 @@ describe('session', () => {
 
     context('#propertyChanged', () => {
       it('should be emitted when the session path changes', () => {
-        let newPath = uuid();
+        let newPath = UUID.uuid4();
         let called = false;
         let object = {};
         defaultSession.propertyChanged.connect((s, type) => {
@@ -412,7 +414,7 @@ describe('session', () => {
 
     context('#setPath()', () => {
       it('should set the path of the session', () => {
-        let newPath = uuid();
+        let newPath = UUID.uuid4();
         return defaultSession.setPath(newPath).then(() => {
           expect(defaultSession.path).to.be(newPath);
         });
@@ -420,30 +422,30 @@ describe('session', () => {
 
       it('should fail for improper response status', done => {
         handleRequest(defaultSession, 201, {});
-        expectFailure(defaultSession.setPath(uuid()), done);
+        expectFailure(defaultSession.setPath(UUID.uuid4()), done);
       });
 
       it('should fail for error response status', done => {
         handleRequest(defaultSession, 500, {});
-        expectFailure(defaultSession.setPath(uuid()), done, '');
+        expectFailure(defaultSession.setPath(UUID.uuid4()), done, '');
       });
 
       it('should fail for improper model', done => {
         handleRequest(defaultSession, 200, {});
-        expectFailure(defaultSession.setPath(uuid()), done);
+        expectFailure(defaultSession.setPath(UUID.uuid4()), done);
       });
 
       it('should fail if the session is disposed', async () => {
         const session = Session.connectTo(defaultSession.model);
         session.dispose();
-        let promise = session.setPath(uuid());
+        let promise = session.setPath(UUID.uuid4());
         await expectFailure(promise, null, 'Session is disposed');
       });
     });
 
     context('#setType()', () => {
       it('should set the type of the session', () => {
-        let type = uuid();
+        let type = UUID.uuid4();
         return defaultSession.setType(type).then(() => {
           expect(defaultSession.type).to.be(type);
         });
@@ -451,30 +453,30 @@ describe('session', () => {
 
       it('should fail for improper response status', done => {
         handleRequest(defaultSession, 201, {});
-        expectFailure(defaultSession.setType(uuid()), done);
+        expectFailure(defaultSession.setType(UUID.uuid4()), done);
       });
 
       it('should fail for error response status', done => {
         handleRequest(defaultSession, 500, {});
-        expectFailure(defaultSession.setType(uuid()), done, '');
+        expectFailure(defaultSession.setType(UUID.uuid4()), done, '');
       });
 
       it('should fail for improper model', done => {
         handleRequest(defaultSession, 200, {});
-        expectFailure(defaultSession.setType(uuid()), done);
+        expectFailure(defaultSession.setType(UUID.uuid4()), done);
       });
 
       it('should fail if the session is disposed', async () => {
         const session = Session.connectTo(defaultSession.model);
         session.dispose();
-        let promise = session.setPath(uuid());
+        let promise = session.setPath(UUID.uuid4());
         await expectFailure(promise, null, 'Session is disposed');
       });
     });
 
     context('#setName()', () => {
       it('should set the name of the session', () => {
-        let name = uuid();
+        let name = UUID.uuid4();
         return defaultSession.setName(name).then(() => {
           expect(defaultSession.name).to.be(name);
         });
@@ -482,23 +484,23 @@ describe('session', () => {
 
       it('should fail for improper response status', done => {
         handleRequest(defaultSession, 201, {});
-        expectFailure(defaultSession.setName(uuid()), done);
+        expectFailure(defaultSession.setName(UUID.uuid4()), done);
       });
 
       it('should fail for error response status', done => {
         handleRequest(defaultSession, 500, {});
-        expectFailure(defaultSession.setName(uuid()), done, '');
+        expectFailure(defaultSession.setName(UUID.uuid4()), done, '');
       });
 
       it('should fail for improper model', done => {
         handleRequest(defaultSession, 200, {});
-        expectFailure(defaultSession.setName(uuid()), done);
+        expectFailure(defaultSession.setName(UUID.uuid4()), done);
       });
 
       it('should fail if the session is disposed', async () => {
         const session = Session.connectTo(defaultSession.model);
         session.dispose();
-        let promise = session.setPath(uuid());
+        let promise = session.setPath(UUID.uuid4());
         await expectFailure(promise, null, 'Session is disposed');
       });
     });

+ 5 - 3
packages/services/test/src/terminal/terminal.spec.ts

@@ -3,7 +3,9 @@
 
 import expect = require('expect.js');
 
-import { PageConfig, uuid } from '@jupyterlab/coreutils';
+import { PageConfig } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { Signal } from '@phosphor/signaling';
 
@@ -54,7 +56,7 @@ describe('terminal', () => {
       });
 
       it('should reject if the session does not exist on the server', () => {
-        return TerminalSession.connectTo(uuid()).then(() => {
+        return TerminalSession.connectTo(UUID.uuid4()).then(() => {
           throw Error('should not get here');
         }, () => undefined);
       });
@@ -69,7 +71,7 @@ describe('terminal', () => {
       });
 
       it('should handle a 404 status', () => {
-        return TerminalSession.shutdown(uuid());
+        return TerminalSession.shutdown('ThisTerminalDoesNotExist');
       });
     });
 

+ 14 - 12
packages/services/test/src/utils.ts

@@ -7,7 +7,7 @@ import WebSocket from 'ws';
 
 import expect from 'expect.js';
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import {
   JSONObject,
@@ -470,7 +470,7 @@ export class KernelTester extends SocketTester {
    */
   async start(): Promise<Kernel.IKernel> {
     // Set up the kernel request response.
-    handleRequest(this, 201, { name: 'test', id: uuid() });
+    handleRequest(this, 201, { name: 'test', id: UUID.uuid4() });
 
     // Construct a new kernel.
     let serverSettings = this.serverSettings;
@@ -524,13 +524,13 @@ export class KernelTester extends SocketTester {
       if (data.header.msg_type === 'kernel_info_request') {
         // First send status busy message.
         this.parentHeader = data.header;
-        this.sendStatus(uuid(), 'busy');
+        this.sendStatus(UUID.uuid4(), 'busy');
 
         // Then send the kernel_info_reply message.
-        this.sendKernelInfoReply(uuid(), EXAMPLE_KERNEL_INFO);
+        this.sendKernelInfoReply(UUID.uuid4(), EXAMPLE_KERNEL_INFO);
 
         // Then send status idle message.
-        this.sendStatus(uuid(), 'idle');
+        this.sendStatus(UUID.uuid4(), 'idle');
         this.parentHeader = undefined;
       } else {
         let onMessage = this._onMessage;
@@ -541,8 +541,7 @@ export class KernelTester extends SocketTester {
     });
   }
 
-  readonly serverSessionId = uuid();
-
+  readonly serverSessionId = UUID.uuid4();
   private _initialStatus = 'starting';
   private _kernel: Kernel.IKernel | null = null;
   private _onMessage: (msg: KernelMessage.IMessage) => void = null;
@@ -553,11 +552,11 @@ export class KernelTester extends SocketTester {
  */
 export function createSessionModel(id?: string): Session.IModel {
   return {
-    id: id || uuid(),
-    path: uuid(),
+    id: id || UUID.uuid4(),
+    path: UUID.uuid4(),
     name: '',
     type: '',
-    kernel: { id: uuid(), name: uuid() }
+    kernel: { id: UUID.uuid4(), name: UUID.uuid4() }
   };
 }
 
@@ -579,7 +578,10 @@ export class SessionTester extends SocketTester {
   async startSession(): Promise<Session.ISession> {
     handleRequest(this, 201, createSessionModel());
     let serverSettings = this.serverSettings;
-    this._session = await Session.startNew({ path: uuid(), serverSettings });
+    this._session = await Session.startNew({
+      path: UUID.uuid4(),
+      serverSettings
+    });
     await this.ready;
     await this._session.kernel.ready;
     return this._session;
@@ -669,7 +671,7 @@ export class SessionTester extends SocketTester {
     });
   }
 
-  readonly serverSessionId = uuid();
+  readonly serverSessionId = UUID.uuid4();
   private _initialStatus = 'starting';
   private _session: Session.ISession;
   private _onMessage: (msg: KernelMessage.IMessage) => void = null;

+ 0 - 1
tests/test-apputils/package.json

@@ -17,7 +17,6 @@
   },
   "dependencies": {
     "@jupyterlab/apputils": "^0.17.0-0",
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/services": "^3.0.0-0",
     "@phosphor/algorithm": "^1.1.2",
     "@phosphor/commands": "^1.5.0",

+ 2 - 2
tests/test-apputils/src/clientsession.spec.ts

@@ -7,7 +7,7 @@ import { Session, SessionManager } from '@jupyterlab/services';
 
 import { ClientSession, IClientSession } from '@jupyterlab/apputils';
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { acceptDialog, dismissDialog } from '../../utils';
 
@@ -218,7 +218,7 @@ describe('@jupyterlab/apputils', () => {
         let other: Session.ISession;
         session.dispose();
         return manager
-          .startNew({ path: uuid() })
+          .startNew({ path: UUID.uuid4() })
           .then(o => {
             other = o;
             session = new ClientSession({

+ 1 - 1
tests/test-console/package.json

@@ -21,8 +21,8 @@
     "@jupyterlab/codeeditor": "^0.17.0-0",
     "@jupyterlab/codemirror": "^0.17.0-0",
     "@jupyterlab/console": "^0.17.0-0",
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/services": "^3.0.0-0",
+    "@phosphor/coreutils": "^1.3.0",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/signaling": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",

+ 2 - 2
tests/test-console/src/foreign.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { KernelMessage, Session } from '@jupyterlab/services';
 
@@ -88,7 +88,7 @@ describe('@jupyterlab/console', () => {
     let session: IClientSession;
 
     before(() => {
-      let path = uuid();
+      let path = UUID.uuid4();
       let sessions = [Session.startNew({ path }), Session.startNew({ path })];
       return Promise.all(sessions)
         .then(([one, two]) => {

+ 0 - 26
tests/test-coreutils/src/uuid.spec.ts

@@ -1,26 +0,0 @@
-// Copyright (c) Jupyter Development Team.
-// Distributed under the terms of the Modified BSD License.
-
-import { expect } from 'chai';
-
-import { uuid } from '@jupyterlab/coreutils';
-
-describe('@jupyterlab/coreutils', () => {
-  describe('uuid()', () => {
-    it('should generate a random 32 character hex string', () => {
-      let id0 = uuid();
-      let id1 = uuid();
-      expect(id0.length).to.equal(32);
-      expect(id1.length).to.equal(32);
-      expect(id0).to.not.equal(id1);
-    });
-
-    it('should accept a length', () => {
-      let id0 = uuid(10);
-      let id1 = uuid(10);
-      expect(id0.length).to.equal(10);
-      expect(id1.length).to.equal(10);
-      expect(id0).to.not.equal(id1);
-    });
-  });
-});

+ 1 - 1
tests/test-csvviewer/package.json

@@ -16,10 +16,10 @@
     "watch:src": "tsc -w --listEmittedFiles"
   },
   "dependencies": {
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/csvviewer": "^0.17.0-0",
     "@jupyterlab/docregistry": "^0.17.0-0",
     "@jupyterlab/services": "^3.0.0-0",
+    "@phosphor/coreutils": "^1.3.0",
     "@phosphor/widgets": "^1.6.0",
     "csv-spectrum": "~1.0.0",
     "expect.js": "~0.3.1",

+ 2 - 2
tests/test-csvviewer/src/widget.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { ServiceManager } from '@jupyterlab/services';
 
@@ -18,7 +18,7 @@ import {
 function createContext(): Context<DocumentRegistry.IModel> {
   let factory = new TextModelFactory();
   let manager = new ServiceManager();
-  let path = uuid() + '.csv';
+  let path = UUID.uuid4() + '.csv';
   return new Context({ factory, manager, path });
 }
 

+ 1 - 1
tests/test-docmanager/package.json

@@ -16,10 +16,10 @@
     "watch:src": "tsc -w --listEmittedFiles"
   },
   "dependencies": {
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/docmanager": "^0.17.0-0",
     "@jupyterlab/docregistry": "^0.17.0-0",
     "@jupyterlab/services": "^3.0.0-0",
+    "@phosphor/coreutils": "^1.3.0",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",
     "expect.js": "~0.3.1"

+ 6 - 2
tests/test-docmanager/src/savehandler.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { ServiceManager } from '@jupyterlab/services';
 
@@ -29,7 +29,11 @@ describe('docregistry/savehandler', () => {
   });
 
   beforeEach(() => {
-    context = new Context({ manager, factory, path: uuid() + '.txt' });
+    context = new Context({
+      manager,
+      factory,
+      path: UUID.uuid4() + '.txt'
+    });
     handler = new SaveHandler({ context });
     return context.initialize(true);
   });

+ 2 - 2
tests/test-docmanager/src/widgetmanager.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { ServiceManager } from '@jupyterlab/services';
 
@@ -80,7 +80,7 @@ describe('@jupyterlab/docmanager', () => {
     context = new Context({
       manager: services,
       factory: textModelFactory,
-      path: uuid()
+      path: UUID.uuid4()
     });
   });
 

+ 0 - 1
tests/test-docregistry/package.json

@@ -16,7 +16,6 @@
     "watch:src": "tsc -w --listEmittedFiles"
   },
   "dependencies": {
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/docregistry": "^0.17.0-0",
     "@jupyterlab/rendermime": "^0.17.0-0",
     "@jupyterlab/services": "^3.0.0-0",

+ 16 - 8
tests/test-docregistry/src/context.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { Contents, ServiceManager } from '@jupyterlab/services';
 
@@ -39,7 +39,11 @@ describe('docregistry/context', () => {
     let context: Context<DocumentRegistry.IModel>;
 
     beforeEach(() => {
-      context = new Context({ manager, factory, path: uuid() + '.txt' });
+      context = new Context({
+        manager,
+        factory,
+        path: UUID.uuid4() + '.txt'
+      });
     });
 
     afterEach(() => {
@@ -50,14 +54,18 @@ describe('docregistry/context', () => {
 
     describe('#constructor()', () => {
       it('should create a new context', () => {
-        context = new Context({ manager, factory, path: uuid() + '.txt' });
+        context = new Context({
+          manager,
+          factory,
+          path: UUID.uuid4() + '.txt'
+        });
         expect(context).to.be.a(Context);
       });
     });
 
     describe('#pathChanged', () => {
       it('should be emitted when the path changes', done => {
-        let newPath = uuid() + '.txt';
+        let newPath = UUID.uuid4() + '.txt';
         context.pathChanged.connect((sender, args) => {
           expect(sender).to.be(context);
           expect(args).to.be(newPath);
@@ -221,7 +229,7 @@ describe('docregistry/context', () => {
 
     describe('#saveAs()', () => {
       it('should save the document to a different path chosen by the user', () => {
-        const newPath = uuid() + '.txt';
+        const newPath = UUID.uuid4() + '.txt';
         waitForDialog().then(() => {
           let dialog = document.body.getElementsByClassName('jp-Dialog')[0];
           let input = dialog.getElementsByTagName('input')[0];
@@ -239,7 +247,7 @@ describe('docregistry/context', () => {
       });
 
       it('should bring up a conflict dialog', () => {
-        const newPath = uuid() + '.txt';
+        const newPath = UUID.uuid4() + '.txt';
         waitForDialog()
           .then(() => {
             let dialog = document.body.getElementsByClassName('jp-Dialog')[0];
@@ -269,7 +277,7 @@ describe('docregistry/context', () => {
 
       it('should keep the file if overwrite is aborted', () => {
         let oldPath = context.path;
-        let newPath = uuid() + '.txt';
+        let newPath = UUID.uuid4() + '.txt';
         waitForDialog()
           .then(() => {
             let dialog = document.body.getElementsByClassName('jp-Dialog')[0];
@@ -425,7 +433,7 @@ describe('docregistry/context', () => {
         context = new Context({
           manager,
           factory,
-          path: uuid() + '.txt',
+          path: UUID.uuid4() + '.txt',
           opener
         });
         context.addSibling(new Widget());

+ 2 - 2
tests/test-docregistry/src/registry.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { toArray } from '@phosphor/algorithm';
 
@@ -38,7 +38,7 @@ class WidgetExtension implements DocumentRegistry.WidgetExtension {
 
 function createFactory(modelName?: string) {
   return new WidgetFactory({
-    name: uuid(),
+    name: UUID.uuid4(),
     modelName: modelName || 'text',
     fileTypes: ['text', 'foobar'],
     defaultFor: ['text', 'foobar']

+ 1 - 0
tests/test-filebrowser/package.json

@@ -22,6 +22,7 @@
     "@jupyterlab/filebrowser": "^0.17.0-0",
     "@jupyterlab/services": "^3.0.0-0",
     "@phosphor/algorithm": "^1.1.2",
+    "@phosphor/coreutils": "^1.3.0",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/signaling": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",

+ 11 - 9
tests/test-filebrowser/src/model.spec.ts

@@ -3,7 +3,9 @@
 
 import expect = require('expect.js');
 
-import { StateDB, uuid, PageConfig } from '@jupyterlab/coreutils';
+import { StateDB, PageConfig } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import { DocumentManager, IDocumentManager } from '@jupyterlab/docmanager';
 
@@ -299,7 +301,7 @@ describe('filebrowser/model', () => {
 
     describe('#upload()', () => {
       it('should upload a file object', done => {
-        let fname = uuid() + '.html';
+        let fname = UUID.uuid4() + '.html';
         let file = new File(['<p>Hello world!</p>'], fname, {
           type: 'text/html'
         });
@@ -313,7 +315,7 @@ describe('filebrowser/model', () => {
       });
 
       it('should overwrite', () => {
-        let fname = uuid() + '.html';
+        let fname = UUID.uuid4() + '.html';
         let file = new File(['<p>Hello world!</p>'], fname, {
           type: 'text/html'
         });
@@ -330,7 +332,7 @@ describe('filebrowser/model', () => {
       });
 
       it('should not overwrite', () => {
-        let fname = uuid() + '.html';
+        let fname = UUID.uuid4() + '.html';
         let file = new File(['<p>Hello world!</p>'], fname, {
           type: 'text/html'
         });
@@ -347,7 +349,7 @@ describe('filebrowser/model', () => {
       });
 
       it('should emit the fileChanged signal', done => {
-        let fname = uuid() + '.html';
+        let fname = UUID.uuid4() + '.html';
         model.fileChanged.connect((sender, args) => {
           expect(sender).to.be(model);
           expect(args.type).to.be('save');
@@ -372,7 +374,7 @@ describe('filebrowser/model', () => {
         });
 
         it('should not upload large file', () => {
-          const fname = uuid() + '.html';
+          const fname = UUID.uuid4() + '.html';
           const file = new File([new ArrayBuffer(LARGE_FILE_SIZE + 1)], fname);
           return model
             .upload(file)
@@ -400,7 +402,7 @@ describe('filebrowser/model', () => {
         });
 
         it('should not upload large notebook file', () => {
-          const fname = uuid() + '.ipynb';
+          const fname = UUID.uuid4() + '.ipynb';
           const file = new File([new ArrayBuffer(LARGE_FILE_SIZE + 1)], fname);
           return model
             .upload(file)
@@ -419,7 +421,7 @@ describe('filebrowser/model', () => {
           2 * CHUNK_SIZE
         ]) {
           it(`should upload a large file of size ${size}`, async () => {
-            const fname = uuid() + '.txt';
+            const fname = UUID.uuid4() + '.txt';
             const content = 'a'.repeat(size);
             const file = new File([content], fname);
             await model.upload(file);
@@ -430,7 +432,7 @@ describe('filebrowser/model', () => {
           });
         }
         it(`should produce progress as a large file uploads`, async () => {
-          const fname = uuid() + '.txt';
+          const fname = UUID.uuid4() + '.txt';
           const file = new File([new ArrayBuffer(2 * CHUNK_SIZE)], fname);
 
           const {

+ 1 - 1
tests/test-fileeditor/package.json

@@ -17,10 +17,10 @@
   },
   "dependencies": {
     "@jupyterlab/codemirror": "^0.17.0-0",
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/docregistry": "^0.17.0-0",
     "@jupyterlab/fileeditor": "^0.17.0-0",
     "@jupyterlab/services": "^3.0.0-0",
+    "@phosphor/coreutils": "^1.3.0",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",
     "expect.js": "~0.3.1",

+ 4 - 4
tests/test-fileeditor/src/widget.spec.ts

@@ -9,7 +9,7 @@ import { Widget } from '@phosphor/widgets';
 
 import { simulate } from 'simulate-event';
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { ServiceManager } from '@jupyterlab/services';
 
@@ -73,7 +73,7 @@ describe('fileeditorcodewrapper', () => {
     let widget: FileEditorCodeWrapper;
 
     beforeEach(() => {
-      let path = uuid() + '.py';
+      let path = UUID.uuid4() + '.py';
       context = new Context({ manager, factory: modelFactory, path });
       widget = new FileEditorCodeWrapper({
         factory: options => factoryService.newDocumentEditor(options),
@@ -113,7 +113,7 @@ describe('fileeditorcodewrapper', () => {
     let widget: LogFileEditor;
 
     beforeEach(() => {
-      let path = uuid() + '.py';
+      let path = UUID.uuid4() + '.py';
       context = new Context({ manager, factory: modelFactory, path });
       widget = new LogFileEditor({
         factory: options => factoryService.newDocumentEditor(options),
@@ -153,7 +153,7 @@ describe('fileeditorcodewrapper', () => {
         context
           .initialize(true)
           .then(() => {
-            return manager.contents.rename(context.path, uuid() + '.jl');
+            return manager.contents.rename(context.path, UUID.uuid4() + '.jl');
           })
           .catch(done);
       });

+ 1 - 1
tests/test-imageviewer/package.json

@@ -16,10 +16,10 @@
     "watch:src": "tsc -w --listEmittedFiles"
   },
   "dependencies": {
-    "@jupyterlab/coreutils": "^2.0.0-0",
     "@jupyterlab/docregistry": "^0.17.0-0",
     "@jupyterlab/imageviewer": "^0.17.0-0",
     "@jupyterlab/services": "^3.0.0-0",
+    "@phosphor/coreutils": "^1.3.0",
     "@phosphor/messaging": "^1.2.2",
     "@phosphor/widgets": "^1.6.0",
     "expect.js": "~0.3.1"

+ 3 - 3
tests/test-imageviewer/src/widget.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { Contents, ServiceManager } from '@jupyterlab/services';
 
@@ -40,7 +40,7 @@ class LogImage extends ImageViewer {
  * The common image model.
  */
 const IMAGE: Partial<Contents.IModel> = {
-  path: uuid() + '.png',
+  path: UUID.uuid4() + '.png',
   type: 'file',
   mimetype: 'image/png',
   content: 'R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7',
@@ -84,7 +84,7 @@ describe('ImageViewer', () => {
     });
 
     it('should keep the title in sync with the file name', done => {
-      let newPath = ((IMAGE as any).path = uuid() + '.png');
+      let newPath = ((IMAGE as any).path = UUID.uuid4() + '.png');
       expect(widget.title.label).to.be(context.path);
       context.pathChanged.connect(() => {
         expect(widget.title.label).to.be(newPath);

+ 2 - 2
tests/test-rendermime/src/registry.spec.ts

@@ -3,7 +3,7 @@
 
 import expect = require('expect.js');
 
-import { uuid } from '@jupyterlab/coreutils';
+import { UUID } from '@phosphor/coreutils';
 
 import { Contents, Drive, ServiceManager, Session } from '@jupyterlab/services';
 
@@ -279,7 +279,7 @@ describe('rendermime/registry', () => {
         contents.addDrive(drive);
         return manager.ready
           .then(() => {
-            return manager.sessions.startNew({ path: uuid() });
+            return manager.sessions.startNew({ path: UUID.uuid4() });
           })
           .then(s => {
             session = s;

+ 6 - 4
tests/utils.ts

@@ -12,7 +12,9 @@ import { ServiceManager } from '@jupyterlab/services';
 
 import { ClientSession } from '@jupyterlab/apputils';
 
-import { nbformat, uuid } from '@jupyterlab/coreutils';
+import { nbformat } from '@jupyterlab/coreutils';
+
+import { UUID } from '@phosphor/coreutils';
 
 import {
   TextModelFactory,
@@ -65,7 +67,7 @@ export function createClientSession(
   return manager.ready.then(() => {
     return new ClientSession({
       manager,
-      path: options.path || uuid(),
+      path: options.path || UUID.uuid4(),
       name: options.name,
       type: options.type,
       kernelPreference: options.kernelPreference || {
@@ -86,7 +88,7 @@ export function createFileContext(
 ): Context<DocumentRegistry.IModel> {
   manager = manager || Private.manager;
   let factory = Private.textFactory;
-  path = path || uuid() + '.txt';
+  path = path || UUID.uuid4() + '.txt';
   return new Context({ manager, factory, path });
 }
 
@@ -100,7 +102,7 @@ export async function createNotebookContext(
   manager = manager || Private.manager;
   await manager.ready;
   const factory = Private.notebookFactory;
-  path = path || uuid() + '.ipynb';
+  path = path || UUID.uuid4() + '.ipynb';
   return new Context({
     manager,
     factory,