diff --git a/packages/pyright-internal/src/tests/typeEvaluator1.test.ts b/packages/pyright-internal/src/tests/typeEvaluator1.test.ts index 40dd606d83..7b88a390df 100644 --- a/packages/pyright-internal/src/tests/typeEvaluator1.test.ts +++ b/packages/pyright-internal/src/tests/typeEvaluator1.test.ts @@ -16,7 +16,6 @@ import { ConfigOptions } from '../common/configOptions'; import { PythonVersion } from '../common/pythonVersion'; import { Uri } from '../common/uri/uri'; import * as TestUtils from './testUtils'; -import { DiagnosticRule } from '../common/diagnosticRules'; test('Unreachable1', () => { const analysisResults = TestUtils.typeAnalyzeSampleFiles(['unreachable1.py']); @@ -24,27 +23,6 @@ test('Unreachable1', () => { TestUtils.validateResults(analysisResults, 0, 0, 2, 1, 4); }); -test('Unreachable1 reportUnreachable', () => { - const configOptions = new ConfigOptions(Uri.empty()); - configOptions.diagnosticRuleSet.reportUnreachable = 'error'; - const analysisResults = TestUtils.typeAnalyzeSampleFiles(['unreachable1.py'], configOptions); - TestUtils.validateResultsButBased(analysisResults, { - errors: [78, 89, 106, 110].map((line) => ({ code: DiagnosticRule.reportUnreachable, line })), - infos: [{ line: 95 }, { line: 98 }], - unusedCodes: [{ line: 102 }], - }); -}); - -test('Unreachable2 reportUnreachable TYPE_CHECKING', () => { - const configOptions = new ConfigOptions(Uri.empty()); - configOptions.diagnosticRuleSet.reportUnreachable = 'error'; - const analysisResults = TestUtils.typeAnalyzeSampleFiles(['unreachable2.py'], configOptions); - - TestUtils.validateResultsButBased(analysisResults, { - unreachableCodes: [{ line: 3 }, { line: 8 }], - }); -}); - test('Builtins1', () => { const analysisResults = TestUtils.typeAnalyzeSampleFiles(['builtins1.py']); diff --git a/packages/pyright-internal/src/tests/typeEvaluatorBased.test.ts b/packages/pyright-internal/src/tests/typeEvaluatorBased.test.ts new file mode 100644 index 0000000000..b0c9e61d76 --- /dev/null +++ b/packages/pyright-internal/src/tests/typeEvaluatorBased.test.ts @@ -0,0 +1,42 @@ +import { BasedConfigOptions, ConfigOptions } from '../common/configOptions'; +import { DiagnosticRule } from '../common/diagnosticRules'; +import { Uri } from '../common/uri/uri'; +import { typeAnalyzeSampleFiles, validateResultsButBased } from './testUtils'; + +test('reportUnreachable', () => { + const configOptions = new ConfigOptions(Uri.empty()); + configOptions.diagnosticRuleSet.reportUnreachable = 'error'; + const analysisResults = typeAnalyzeSampleFiles(['unreachable1.py'], configOptions); + validateResultsButBased(analysisResults, { + errors: [78, 89, 106, 110].map((line) => ({ code: DiagnosticRule.reportUnreachable, line })), + infos: [{ line: 95 }, { line: 98 }], + unusedCodes: [{ line: 102 }], + }); +}); + +test('reportUnreachable TYPE_CHECKING', () => { + const configOptions = new ConfigOptions(Uri.empty()); + configOptions.diagnosticRuleSet.reportUnreachable = 'error'; + const analysisResults = typeAnalyzeSampleFiles(['unreachable2.py'], configOptions); + + validateResultsButBased(analysisResults, { + unreachableCodes: [{ line: 3 }, { line: 8 }], + }); +}); + +test('default typeCheckingMode=all', () => { + const configOptions = new BasedConfigOptions(Uri.empty()); + const analysisResults = typeAnalyzeSampleFiles(['unreachable1.py'], configOptions); + validateResultsButBased(analysisResults, { + errors: [ + ...[78, 89, 106, 110].map((line) => ({ code: DiagnosticRule.reportUnreachable, line })), + { line: 16, code: DiagnosticRule.reportUninitializedInstanceVariable }, + { line: 19, code: DiagnosticRule.reportUnknownParameterType }, + { line: 33, code: DiagnosticRule.reportUnknownParameterType }, + { line: 94, code: DiagnosticRule.reportUnnecessaryComparison }, + { line: 102, code: DiagnosticRule.reportUnusedVariable }, + ], + infos: [{ line: 95 }, { line: 98 }], + unusedCodes: [{ line: 102 }], + }); +});