def test_str_repr(self): variable = writer.Variable("other_name", 15) variable.value = 12 self.assertEqual(str(variable), "Variable('other_name', 15, 12)")
def test_tree_str_dict(self): variable = writer.Variable("other_name", 15) variable.value = {} self.assertEqual(variable.tree_str(), "other_name: dict = {}")
def test_tree_str_type_dict(self): variable = writer.Variable("other_name", 15) variable.value = dict self.assertEqual(variable.tree_str(), "other_name: type = <class 'dict'>")
def test_set_value_int(self): variable = writer.Variable("other_name", 15) variable.value = 42 self.assertEqual(variable.value, 42)
def test_tree_str_value_none(self): variable = writer.Variable("other_name", 15) variable.value = None self.assertEqual(variable.tree_str(), "other_name = None")
def test_set_value_string(self): variable = writer.Variable("other_name", 15) variable.value = "Hello World" self.assertEqual(variable.tree_str(), "other_name: str = 'Hello World'")
def test_init_variable(self): variable = writer.Variable("some_name", 4) self.assertEqual(variable.name, "some_name") self.assertEqual(variable.col_offset, 4) self.assertIsNone(variable.value)
def test_type_name_type_dict(self): variable = writer.Variable("other_name", 15) variable.value = dict self.assertEqual(variable.type_name, "type")
def test_type_name_value_none(self): variable = writer.Variable("other_name", 15) variable.value = None self.assertEqual(variable.type_name, "NoneType")
def test_set_value_string(self): variable = writer.Variable("other_name", 15) variable.value = "Hello World" self.assertEqual(variable.value, '"Hello World"')