Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Port test from #312 to new analysis #657

Merged
merged 1 commit into from
Feb 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/Analysis/Ast/Test/InheritanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<IPythonInstance>()
.Which.Type.Name.Should().Be("A");
}
}
}