Skip to content

Commit

Permalink
Remove nosetest support (#16217)
Browse files Browse the repository at this point in the history
* Remove nosetest support

* Fix enablement tests

* Update src/client/testing/common/xUnitParser.ts

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>

Co-authored-by: Kim-Adeline Miguel <51720070+kimadeline@users.noreply.github.com>
  • Loading branch information
karthiknadig and kimadeline authored May 12, 2021
1 parent 0eb3828 commit d440420
Show file tree
Hide file tree
Showing 85 changed files with 60 additions and 6,847 deletions.
9 changes: 0 additions & 9 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,6 @@ src/test/testing/unittest/unittest.discovery.test.ts
src/test/testing/unittest/unittest.run.test.ts
src/test/testing/unittest/unittest.unit.test.ts
src/test/testing/codeLenses/testFiles.unit.test.ts
src/test/testing/nosetest/nosetest.test.ts
src/test/testing/nosetest/nosetest.disovery.test.ts
src/test/testing/nosetest/nosetest.run.test.ts
src/test/testing/rediscover.test.ts
src/test/testing/helper.ts
src/test/testing/navigation/fileNavigator.unit.test.ts
Expand Down Expand Up @@ -404,12 +401,6 @@ src/client/testing/unittest/services/argsService.ts
src/client/testing/unittest/services/discoveryService.ts
src/client/testing/codeLenses/main.ts
src/client/testing/codeLenses/testFiles.ts
src/client/testing/nosetest/main.ts
src/client/testing/nosetest/testConfigurationManager.ts
src/client/testing/nosetest/runner.ts
src/client/testing/nosetest/services/parserService.ts
src/client/testing/nosetest/services/argsService.ts
src/client/testing/nosetest/services/discoveryService.ts
src/client/testing/main.ts
src/client/testing/configurationFactory.ts
src/client/testing/navigation/serviceRegistry.ts
Expand Down
16 changes: 0 additions & 16 deletions .github/test_plan.md
Original file line number Diff line number Diff line change
Expand Up @@ -342,22 +342,6 @@ def test_failure():
- [ ] The appropriate `DiagnosticRelatedInformation` is shown for each `Diagnostic`
- [ ] The `DiagnosticRelatedInformation` reflects the traceback for the test

#### [`nose`](https://code.visualstudio.com/docs/python/unit-testing#_nose-configuration-settings)

```python
def test_passing():
assert 42 == 42

def test_failure():
assert 42 == -13
```

- [ ] `Run All Unit Tests` triggers the prompt to configure the test runner
- [ ] Nose gets installed
- [ ] Tests are discovered (as shown by code lenses on each test)
- [ ] `Run Test` works
- [ ] `Debug Test` works

#### General

- [ ] Code lenses appears
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Learn more about the rich features of the Python extension:

- [Debugging](https://code.visualstudio.com/docs/python/debugging): Debug your Python scripts, web apps, remote or multi-threaded processes

- [Testing](https://code.visualstudio.com/docs/python/unit-testing): Run and debug tests through the Test Explorer with unittest, pytest or nose
- [Testing](https://code.visualstudio.com/docs/python/unit-testing): Run and debug tests through the Test Explorer with unittest or pytest.

- [Jupyter Notebooks](https://code.visualstudio.com/docs/python/jupyter-support): Create and edit Jupyter Notebooks, add and run code cells, render plots, visualize variables through the variable explorer, visualize dataframes with the data viewer, and more

Expand Down
1 change: 0 additions & 1 deletion build/test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pylint
pycodestyle
pydocstyle
prospector ; python_version > '2.7'
nose
pytest<6 ; python_version > '2.7' # Tests currently fail against pytest 6.
rope
flask
Expand Down
1 change: 0 additions & 1 deletion news/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"editor.formatOnSave": true,
"python.testing.pytestArgs": ["."],
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false,
"python.testing.pytestEnabled": true
}
21 changes: 0 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1779,27 +1779,6 @@
"description": "Port number used for debugging of tests.",
"scope": "resource"
},
"python.testing.nosetestArgs": {
"type": "array",
"description": "Arguments passed in. Each argument is a separate item in the array.",
"default": [],
"items": {
"type": "string"
},
"scope": "resource"
},
"python.testing.nosetestsEnabled": {
"type": "boolean",
"default": false,
"description": "Enable testing using nosetests.",
"scope": "resource"
},
"python.testing.nosetestPath": {
"type": "string",
"default": "nosetests",
"description": "Path to nosetests, you can use a custom version of nosetests by modifying this setting to include the full path.",
"scope": "resource"
},
"python.testing.promptToConfigure": {
"type": "boolean",
"default": true,
Expand Down
11 changes: 2 additions & 9 deletions pythonFiles/testlauncher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,20 @@ def parse_argv():
"""Parses arguments for use with the test launcher.
Arguments are:
1. Working directory.
2. Test runner, `pytest` or `nose`
2. Test runner `pytest`
3. Rest of the arguments are passed into the test runner.
"""
cwd = sys.argv[1]
testRunner = sys.argv[2]
args = sys.argv[3:]
if testRunner == "nose":
# Nose expects the program name to be first argument in vargs
args.insert(0, sys.argv[0])

return (cwd, testRunner, args)


def run(cwd, testRunner, args):
"""Runs the test
cwd -- the current directory to be set
testRunner -- test runner to be used `pytest` or `nose`
testRunner -- test runner to be used `pytest`
args -- arguments passed into the test runner
"""

Expand All @@ -37,10 +34,6 @@ def run(cwd, testRunner, args):
import pytest

pytest.main(args)
else:
import nose

nose.run(argv=args)
sys.exit(0)
finally:
pass
Expand Down
11 changes: 0 additions & 11 deletions pythonFiles/tests/testing_tools/adapter/test___main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ def test_pytest_opts(self):
def test_unsupported_tool(self):
with self.assertRaises(SystemExit):
parse_args(["discover", "unittest"])
with self.assertRaises(SystemExit):
parse_args(["discover", "nose"])
with self.assertRaises(SystemExit):
parse_args(["discover", "???"])

Expand Down Expand Up @@ -159,15 +157,6 @@ def test_unsupported_tool(self):
_tools={"pytest": None},
_reporters=None,
)
with self.assertRaises(UnsupportedToolError):
main(
"nose",
"discover",
{"spam": "eggs"},
[],
_tools={"pytest": None},
_reporters=None,
)
with self.assertRaises(UnsupportedToolError):
main(
"???",
Expand Down
11 changes: 0 additions & 11 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -513,15 +513,12 @@ export class PythonSettings implements IPythonSettings {
this.testing = testSettings;
if (isTestExecution() && !this.testing) {
this.testing = {
nosetestArgs: [],
pytestArgs: [],
unittestArgs: [],
promptToConfigure: true,
debugPort: 3000,
nosetestsEnabled: false,
pytestEnabled: false,
unittestEnabled: false,
nosetestPath: 'nosetests',
pytestPath: 'pytest',
autoTestDiscoverOnSaveEnabled: true,
} as ITestingSettings;
Expand All @@ -534,9 +531,6 @@ export class PythonSettings implements IPythonSettings {
: {
promptToConfigure: true,
debugPort: 3000,
nosetestArgs: [],
nosetestPath: 'nosetest',
nosetestsEnabled: false,
pytestArgs: [],
pytestEnabled: false,
pytestPath: 'pytest',
Expand All @@ -545,16 +539,11 @@ export class PythonSettings implements IPythonSettings {
autoTestDiscoverOnSaveEnabled: true,
};
this.testing.pytestPath = getAbsolutePath(systemVariables.resolveAny(this.testing.pytestPath), workspaceRoot);
this.testing.nosetestPath = getAbsolutePath(
systemVariables.resolveAny(this.testing.nosetestPath),
workspaceRoot,
);
if (this.testing.cwd) {
this.testing.cwd = getAbsolutePath(systemVariables.resolveAny(this.testing.cwd), workspaceRoot);
}

// Resolve any variables found in the test arguments.
this.testing.nosetestArgs = this.testing.nosetestArgs.map((arg) => systemVariables.resolveAny(arg));
this.testing.pytestArgs = this.testing.pytestArgs.map((arg) => systemVariables.resolveAny(arg));
this.testing.unittestArgs = this.testing.unittestArgs.map((arg) => systemVariables.resolveAny(arg));

Expand Down
9 changes: 3 additions & 6 deletions src/client/common/installer/moduleInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { STANDARD_OUTPUT_CHANNEL } from '../constants';
import { IFileSystem } from '../platform/types';
import * as internalPython from '../process/internal/python';
import { ITerminalServiceFactory, TerminalCreationOptions } from '../terminal/types';
import { ExecutionInfo, IConfigurationService, IOutputChannel, ModuleNamePurpose, Product } from '../types';
import { ExecutionInfo, IConfigurationService, IOutputChannel, Product } from '../types';
import { Products } from '../utils/localize';
import { isResource } from '../utils/misc';
import { ProductNames } from './productNames';
Expand All @@ -38,7 +38,7 @@ export abstract class ModuleInstaller implements IModuleInstaller {
const name =
typeof productOrModuleName == 'string'
? productOrModuleName
: translateProductToModule(productOrModuleName, ModuleNamePurpose.install);
: translateProductToModule(productOrModuleName);
const productName = typeof productOrModuleName === 'string' ? name : ProductNames.get(productOrModuleName);
sendTelemetryEvent(EventName.PYTHON_INSTALL_PACKAGE, undefined, { installer: this.displayName, productName });
const uri = isResource(resource) ? resource : undefined;
Expand Down Expand Up @@ -152,13 +152,10 @@ export abstract class ModuleInstaller implements IModuleInstaller {
}
}

export function translateProductToModule(product: Product, purpose: ModuleNamePurpose): string {
export function translateProductToModule(product: Product): string {
switch (product) {
case Product.mypy:
return 'mypy';
case Product.nosetest: {
return purpose === ModuleNamePurpose.install ? 'nose' : 'nosetests';
}
case Product.pylama:
return 'pylama';
case Product.prospector:
Expand Down
7 changes: 3 additions & 4 deletions src/client/common/installer/productInstaller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
IOutputChannel,
IPersistentStateFactory,
ProductInstallStatus,
ModuleNamePurpose,
Product,
ProductType,
} from '../types';
Expand Down Expand Up @@ -463,7 +462,7 @@ class DataScienceInstaller extends BaseInstaller {
.getInstallationChannels(interpreter);

// Pick an installerModule based on whether the interpreter is conda or not. Default is pip.
const moduleName = translateProductToModule(product, ModuleNamePurpose.install);
const moduleName = translateProductToModule(product);
let installerModule: IModuleInstaller | undefined;
const isAvailableThroughConda = !UnsupportedChannelsForProduct.get(product)?.has(EnvironmentType.Conda);
if (interpreter.envType === EnvironmentType.Conda && isAvailableThroughConda) {
Expand Down Expand Up @@ -578,8 +577,8 @@ export class ProductInstaller implements IInstaller {
}

// eslint-disable-next-line class-methods-use-this
public translateProductToModuleName(product: Product, purpose: ModuleNamePurpose): string {
return translateProductToModule(product, purpose);
public translateProductToModuleName(product: Product): string {
return translateProductToModule(product);
}

private createInstaller(product: Product): BaseInstaller {
Expand Down
1 change: 0 additions & 1 deletion src/client/common/installer/productNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ProductNames.set(Product.bandit, 'bandit');
ProductNames.set(Product.black, 'black');
ProductNames.set(Product.flake8, 'flake8');
ProductNames.set(Product.mypy, 'mypy');
ProductNames.set(Product.nosetest, 'nosetest');
ProductNames.set(Product.pycodestyle, 'pycodestyle');
ProductNames.set(Product.pylama, 'pylama');
ProductNames.set(Product.prospector, 'prospector');
Expand Down
10 changes: 5 additions & 5 deletions src/client/common/installer/productPath.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { IFormatterHelper } from '../../formatters/types';
import { IServiceContainer } from '../../ioc/types';
import { ILinterManager } from '../../linters/types';
import { ITestingService } from '../../testing/types';
import { IConfigurationService, IInstaller, ModuleNamePurpose, Product } from '../types';
import { IConfigurationService, IInstaller, Product } from '../types';
import { IProductPathService } from './types';

@injectable()
Expand All @@ -25,7 +25,7 @@ export abstract class BaseProductPathsService implements IProductPathService {
public isExecutableAModule(product: Product, resource?: Uri): boolean {
let moduleName: string | undefined;
try {
moduleName = this.productInstaller.translateProductToModuleName(product, ModuleNamePurpose.run);
moduleName = this.productInstaller.translateProductToModuleName(product);
} catch {}

// User may have customized the module name or provided the fully qualifieid path.
Expand Down Expand Up @@ -82,7 +82,7 @@ export class TestFrameworkProductPathService extends BaseProductPathsService {
const settingsPropNames = testHelper.getSettingsPropertyNames(product);
if (!settingsPropNames.pathName) {
// E.g. in the case of UnitTests we don't allow customizing the paths.
return this.productInstaller.translateProductToModuleName(product, ModuleNamePurpose.run);
return this.productInstaller.translateProductToModuleName(product);
}
const settings = this.configService.getSettings(resource);
return settings.testing[settingsPropNames.pathName] as string;
Expand All @@ -95,7 +95,7 @@ export class RefactoringLibraryProductPathService extends BaseProductPathsServic
super(serviceContainer);
}
public getExecutableNameFromSettings(product: Product, _?: Uri): string {
return this.productInstaller.translateProductToModuleName(product, ModuleNamePurpose.run);
return this.productInstaller.translateProductToModuleName(product);
}
}

Expand All @@ -105,6 +105,6 @@ export class DataScienceProductPathService extends BaseProductPathsService {
super(serviceContainer);
}
public getExecutableNameFromSettings(product: Product, _?: Uri): string {
return this.productInstaller.translateProductToModuleName(product, ModuleNamePurpose.run);
return this.productInstaller.translateProductToModuleName(product);
}
}
1 change: 0 additions & 1 deletion src/client/common/installer/productService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ export class ProductService implements IProductService {
this.ProductTypes.set(Product.pylama, ProductType.Linter);
this.ProductTypes.set(Product.pylint, ProductType.Linter);
this.ProductTypes.set(Product.ctags, ProductType.WorkspaceSymbols);
this.ProductTypes.set(Product.nosetest, ProductType.TestFramework);
this.ProductTypes.set(Product.pytest, ProductType.TestFramework);
this.ProductTypes.set(Product.unittest, ProductType.TestFramework);
this.ProductTypes.set(Product.autopep8, ProductType.Formatter);
Expand Down
8 changes: 1 addition & 7 deletions src/client/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export enum ProductType {

export enum Product {
pytest = 1,
nosetest = 2,
pylint = 3,
flake8 = 4,
pycodestyle = 5,
Expand All @@ -110,11 +109,6 @@ export enum Product {
torchProfilerImportName = 26,
}

export enum ModuleNamePurpose {
install = 1,
run = 2,
}

export const IInstaller = Symbol('IInstaller');

export interface IInstaller {
Expand All @@ -136,7 +130,7 @@ export interface IInstaller {
semVerRequirement: string,
resource?: InterpreterUri,
): Promise<ProductInstallStatus>;
translateProductToModuleName(product: Product, purpose: ModuleNamePurpose): string;
translateProductToModuleName(product: Product): string;
}

// TODO: Drop IPathUtils in favor of IFileSystemPathUtils.
Expand Down
1 change: 0 additions & 1 deletion src/client/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1668,7 +1668,6 @@ export interface IEventNamePropertyMapping {
* Values sent include:
* unittest - If this value is `true`, then unittest has been enabled by the user.
* pytest - If this value is `true`, then pytest has been enabled by the user.
* nosetest - If this value is `true`, then nose has been enabled by the user.
* @type {(never | undefined)}
* @memberof IEventNamePropertyMapping
*/
Expand Down
2 changes: 1 addition & 1 deletion src/client/telemetry/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type LintingTelemetry = IEventNamePropertyMapping[EventName.LINTING];

export type PythonInterpreterTelemetry = IEventNamePropertyMapping[EventName.PYTHON_INTERPRETER];
export type DebuggerTelemetry = IEventNamePropertyMapping[EventName.DEBUGGER];
export type TestTool = 'nosetest' | 'pytest' | 'unittest';
export type TestTool = 'pytest' | 'unittest';
export type TestRunTelemetry = IEventNamePropertyMapping[EventName.UNITTEST_RUN];
export type TestDiscoveryTelemetry = IEventNamePropertyMapping[EventName.UNITTEST_DISCOVER];
export type TestConfiguringTelemetry = IEventNamePropertyMapping[EventName.UNITTEST_CONFIGURING];
Expand Down
3 changes: 1 addition & 2 deletions src/client/testing/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { UnitTestProduct } from './types';

export const CANCELLATION_REASON = 'cancelled_user_request';

export const UNIT_TEST_PRODUCTS: UnitTestProduct[] = [Product.pytest, Product.unittest, Product.nosetest];
export const NOSETEST_PROVIDER: TestProvider = 'nosetest';
export const UNIT_TEST_PRODUCTS: UnitTestProduct[] = [Product.pytest, Product.unittest];
export const PYTEST_PROVIDER: TestProvider = 'pytest';
export const UNITTEST_PROVIDER: TestProvider = 'unittest';

Expand Down
3 changes: 1 addition & 2 deletions src/client/testing/common/debugLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ export class DebugLauncher implements ITestDebugLauncher {
case 'unittest': {
return internalScripts.visualstudio_py_testlauncher;
}
case 'pytest':
case 'nosetest': {
case 'pytest': {
return internalScripts.testlauncher;
}
default: {
Expand Down
Loading

0 comments on commit d440420

Please sign in to comment.