Skip to content

Commit 1e7e366

Browse files
Fix unrelated tests.
1 parent 71735f9 commit 1e7e366

2 files changed

Lines changed: 24 additions & 26 deletions

File tree

src/client/pythonEnvironments/discovery/locators/services/windowsRegistryService.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ export class WindowsRegistryService extends CacheableLocatorService {
183183
: InterpreterType.Unknown
184184
} as PythonInterpreter;
185185
})
186-
.then((interpreter) =>
187-
interpreter
186+
.then((interpreter) => {
187+
return interpreter
188188
? this.fs
189189
.fileExists(interpreter.path)
190190
.catch(() => false)
191191
.then((exists) => (exists ? interpreter : null))
192-
: null
193-
)
192+
: null;
193+
})
194194
.catch((error) => {
195195
traceError(
196196
`Failed to retrieve interpreter details for company ${companyKey},tag: ${tagKey}, hive: ${hive}, arch: ${arch}`,

src/test/pythonEnvironments/discovery/locators/windowsRegistryService.unit.test.ts

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import { IWindowsStoreInterpreter } from '../../../../client/interpreter/locator
1010
import { IServiceContainer } from '../../../../client/ioc/types';
1111
import { WindowsRegistryService } from '../../../../client/pythonEnvironments/discovery/locators/services/windowsRegistryService';
1212
import { InterpreterType } from '../../../../client/pythonEnvironments/discovery/types';
13+
import { EXTENSION_ROOT_DIR_FOR_TESTS } from '../../../constants';
1314
import { MockRegistry, MockState } from '../../../interpreters/mocks';
1415

15-
const environmentsPath = path.join(__dirname, '..', '..', '..', 'src', 'test', 'pythonFiles', 'environments');
16+
const environmentsPath = path.join(EXTENSION_ROOT_DIR_FOR_TESTS, 'src', 'test', 'pythonFiles', 'environments');
1617

1718
// tslint:disable:max-func-body-length no-octal-literal no-invalid-this
1819

@@ -68,6 +69,7 @@ suite('Interpreters from Windows Registry (unit)', () => {
6869
serviceContainer.object,
6970
windowsStoreInterpreter.object
7071
);
72+
platformService.setup((p) => p.isWindows).returns(() => true);
7173

7274
const interpreters = await winRegistry.getInterpreters();
7375
assert.equal(interpreters.length, 0, 'Incorrect number of entries');
@@ -80,13 +82,12 @@ suite('Interpreters from Windows Registry (unit)', () => {
8082
serviceContainer.object,
8183
windowsStoreInterpreter.object
8284
);
85+
platformService.setup((p) => p.isWindows).returns(() => true);
8386

8487
const interpreters = await winRegistry.getInterpreters();
8588
assert.equal(interpreters.length, 0, 'Incorrect number of entries');
8689
});
87-
test('Must return a single entry', async function () {
88-
// https://github.com/microsoft/vscode-python/issues/12241
89-
return this.skip();
90+
test('Must return a single entry', async () => {
9091
const registryKeys = [
9192
{
9293
key: '\\Software\\Python',
@@ -149,6 +150,7 @@ suite('Interpreters from Windows Registry (unit)', () => {
149150
interpreterHelper
150151
.setup((h) => h.getInterpreterInformation(TypeMoq.It.isAny()))
151152
.returns(() => Promise.resolve({ architecture: Architecture.x86 }));
153+
platformService.setup((p) => p.isWindows).returns(() => true);
152154

153155
const interpreters = await winRegistry.getInterpreters();
154156

@@ -162,9 +164,7 @@ suite('Interpreters from Windows Registry (unit)', () => {
162164
);
163165
assert.equal(interpreters[0].version!.raw, '9.9.9-final', 'Incorrect version');
164166
});
165-
test('Must default names for PythonCore and exe', async function () {
166-
// https://github.com/microsoft/vscode-python/issues/12241
167-
return this.skip();
167+
test('Must default names for PythonCore and exe', async () => {
168168
const registryKeys = [
169169
{
170170
key: '\\Software\\Python',
@@ -199,6 +199,7 @@ suite('Interpreters from Windows Registry (unit)', () => {
199199
interpreterHelper
200200
.setup((h) => h.getInterpreterInformation(TypeMoq.It.isAny()))
201201
.returns(() => Promise.resolve({ architecture: Architecture.x86 }));
202+
platformService.setup((p) => p.isWindows).returns(() => true);
202203

203204
const interpreters = await winRegistry.getInterpreters();
204205

@@ -209,6 +210,7 @@ suite('Interpreters from Windows Registry (unit)', () => {
209210
assert.equal(interpreters[0].version!.raw, '9.9.9-final', 'Incorrect version');
210211
});
211212
test("Must ignore company 'PyLauncher'", async () => {
213+
platformService.setup((p) => p.isWindows).returns(() => true);
212214
const registryKeys = [
213215
{
214216
key: '\\Software\\Python',
@@ -243,9 +245,8 @@ suite('Interpreters from Windows Registry (unit)', () => {
243245

244246
assert.equal(interpreters.length, 0, 'Incorrect number of entries');
245247
});
246-
test('Must return a single entry and when registry contains only the InstallPath', async function () {
247-
// https://github.com/microsoft/vscode-python/issues/12241
248-
return this.skip();
248+
test('Must return a single entry and when registry contains only the InstallPath', async () => {
249+
platformService.setup((p) => p.isWindows).returns(() => true);
249250
const registryKeys = [
250251
{
251252
key: '\\Software\\Python',
@@ -289,9 +290,8 @@ suite('Interpreters from Windows Registry (unit)', () => {
289290
assert.equal(interpreters[0].version!.raw, '9.9.9-final', 'Incorrect version');
290291
assert.equal(interpreters[0].type, InterpreterType.Unknown, 'Incorrect type');
291292
});
292-
test('Must return a single entry with a type of WindowsStore', async function () {
293-
// https://github.com/microsoft/vscode-python/issues/12241
294-
return this.skip();
293+
test('Must return a single entry with a type of WindowsStore', async () => {
294+
platformService.setup((p) => p.isWindows).returns(() => true);
295295
const registryKeys = [
296296
{
297297
key: '\\Software\\Python',
@@ -343,6 +343,7 @@ suite('Interpreters from Windows Registry (unit)', () => {
343343
windowsStoreInterpreter.verifyAll();
344344
});
345345
test('Must not return any interpreters (must ignore internal windows store intrepreters)', async () => {
346+
platformService.setup((p) => p.isWindows).returns(() => true);
346347
const registryKeys = [
347348
{
348349
key: '\\Software\\Python',
@@ -388,9 +389,8 @@ suite('Interpreters from Windows Registry (unit)', () => {
388389
assert.equal(interpreters.length, 0, 'Incorrect number of entries');
389390
windowsStoreInterpreter.verifyAll();
390391
});
391-
test('Must return multiple entries', async function () {
392-
// https://github.com/microsoft/vscode-python/issues/12241
393-
return this.skip();
392+
test('Must return multiple entries', async () => {
393+
platformService.setup((p) => p.isWindows).returns(() => true);
394394
const registryKeys = [
395395
{
396396
key: '\\Software\\Python',
@@ -574,9 +574,8 @@ suite('Interpreters from Windows Registry (unit)', () => {
574574
);
575575
assert.equal(interpreters[3].version!.raw, '5.0.0', 'Incorrect version');
576576
});
577-
test('Must return multiple entries excluding the invalid registry items and duplicate paths', async function () {
578-
// https://github.com/microsoft/vscode-python/issues/12241
579-
return this.skip();
577+
test('Must return multiple entries excluding the invalid registry items and duplicate paths', async () => {
578+
platformService.setup((p) => p.isWindows).returns(() => true);
580579
const registryKeys = [
581580
{
582581
key: '\\Software\\Python',
@@ -789,9 +788,8 @@ suite('Interpreters from Windows Registry (unit)', () => {
789788
assert.equal(interpreters[3].path, path.join(environmentsPath, 'path2', 'python.exe'), 'Incorrect path');
790789
assert.equal(interpreters[3].version!.raw, '4.0.0', 'Incorrect version');
791790
});
792-
test('Must return multiple entries excluding the invalid registry items and nonexistent paths', async function () {
793-
// https://github.com/microsoft/vscode-python/issues/12241
794-
return this.skip();
791+
test('Must return multiple entries excluding the invalid registry items and nonexistent paths', async () => {
792+
platformService.setup((p) => p.isWindows).returns(() => true);
795793
const registryKeys = [
796794
{
797795
key: '\\Software\\Python',

0 commit comments

Comments
 (0)