def test_header_dunder(self): """ Tests for __magic__ methods on GDSectionHeader """ h = GDSectionHeader("node") self.assertEqual(str(h), "[node]") self.assertEqual(repr(h), "GDSectionHeader([node])") h2 = GDSectionHeader("node") self.assertEqual(h, h2) h2["type"] = "Node2D" self.assertNotEqual(h, h2) self.assertNotEqual(h, "[node]")
def test_section_dunder(self): """ Tests for __magic__ methods on GDSection """ h = GDSectionHeader("node") s = GDSection(h, vframes=10) self.assertEqual(str(s), "[node]\nvframes = 10") self.assertEqual(repr(s), "GDSection([node]\nvframes = 10)") self.assertEqual(s["vframes"], 10) s2 = GDSection(GDSectionHeader("node"), vframes=10) self.assertEqual(s, s2) s2["vframes"] = 100 self.assertNotEqual(s, s2) self.assertNotEqual(s, "[node]\nvframes = 10") del s["vframes"] self.assertEqual(s.get("vframes"), None) del s["vframes"]
import os import unittest from pyparsing import ParseException from godot_parser import GDFile, GDObject, GDSection, GDSectionHeader, Vector2, parse HERE = os.path.dirname(__file__) TEST_CASES = [ ( "[gd_scene load_steps=5 format=2]", GDFile(GDSection(GDSectionHeader("gd_scene", load_steps=5, format=2))), ), ( "[gd_resource load_steps=5 format=2]", GDFile(GDSection(GDSectionHeader("gd_resource", load_steps=5, format=2))), ), ( '[ext_resource path="res://Sample.tscn" type="PackedScene" id=1]', GDFile( GDSection( GDSectionHeader( "ext_resource", path="res://Sample.tscn", type="PackedScene", id=1 ) ) ), ), ( """[gd_scene load_steps=5 format=2] [ext_resource path="res://Sample.tscn" type="PackedScene" id=1]""",