From ecaf88c68be4d25fd9a6af61fd7dcd745c93a6e0 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Mon, 25 Feb 2019 14:12:14 -0800 Subject: [PATCH] Port test from #312 to new analysis --- src/Analysis/Ast/Test/InheritanceTests.cs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Analysis/Ast/Test/InheritanceTests.cs b/src/Analysis/Ast/Test/InheritanceTests.cs index 79df8a128..669b4f680 100644 --- a/src/Analysis/Ast/Test/InheritanceTests.cs +++ b/src/Analysis/Ast/Test/InheritanceTests.cs @@ -13,9 +13,12 @@ // See the Apache Version 2.0 License for specific language governing // permissions and limitations under the License. +using System.Linq; using System.Threading.Tasks; +using FluentAssertions; using Microsoft.Python.Analysis.Tests.FluentAssertions; using Microsoft.Python.Analysis.Types; +using Microsoft.Python.Analysis.Values; using Microsoft.VisualStudio.TestTools.UnitTesting; using TestUtilities; @@ -92,5 +95,23 @@ def foo(self, x): analysis.Should().HaveVariable("y").OfType(BuiltinTypeId.Int); } + + + [TestMethod, Priority(0)] + public async Task NamedTupleSubclass() { + const string code = @" +import collections + +class A(collections.namedtuple('A', [])): + def __new__(cls): + return super(A, cls).__new__(cls) + +a = A() +"; + var analysis = await GetAnalysisAsync(code); + analysis.Should().HaveVariable("a") + .Which.Value.Should().BeAssignableTo() + .Which.Type.Name.Should().Be("A"); + } } }