コード例 #1
0
 def test_init(self):
     re_property = Property(name="Test", default=False)
     self.assertFalse(re_property.value)
     re_property.value = True
     self.assertTrue(re_property.value)
     with self.assertRaises(TypeError):
         re_property.value = "other"
コード例 #2
0
 def test_set_bool_with_ON_and_OFF(self):
     re_property = Property(name="Test", default=False)
     re_property.value = "ON"
     self.assertTrue(re_property.value)
     re_property.value = "OFF"
     self.assertFalse(re_property.value)
     re_property.value = ""
     self.assertFalse(re_property.value)
コード例 #3
0
 def test_set_value_not_stripped(self):
     re_property = Property(name="Test", default=False)
     re_property.value = "ON         "
     self.assertTrue(re_property)
     re_property_text = Property(name="Text", default="")
     re_property_text.value = "foo              "
     compare("foo", re_property_text.value)
コード例 #4
0
    def test_hash(self):
        re_property = Property(name="Test", default=False)
        pre_hash = hash(re_property)
        re_property.value = True
        self.assertNotEqual(pre_hash, hash(re_property))

        re_property = Property(name="Test", default="")
        pre_hash = hash(re_property)
        re_property.value = "value"
        self.assertNotEqual(pre_hash, hash(re_property))
コード例 #5
0
 def __init__(self,
              article_type: str = RE_DATEN,
              re_daten_properties: ArticleProperties = None,
              text: str = "",
              author: Tuple[str, str] = ("", "")):
     self._article_type = ""
     self.article_type = article_type
     self._text = ""
     self.text = text
     self._author = ("", "")
     self.author = author
     self._properties = (Property("BAND", ""), Property("SPALTE_START", ""),
                         Property("SPALTE_END",
                                  ""), Property("VORGÄNGER", ""),
                         Property("NACHFOLGER",
                                  ""), Property("SORTIERUNG", ""),
                         Property("KORREKTURSTAND",
                                  ""), Property("KURZTEXT", ""),
                         Property("WIKIPEDIA",
                                  ""), Property("WIKISOURCE",
                                                ""), Property("GND", ""),
                         Property("KEINE_SCHÖPFUNGSHÖHE",
                                  False), Property("TODESJAHR", ""),
                         Property("GEBURTSJAHR",
                                  ""), Property("NACHTRAG", False),
                         Property("ÜBERSCHRIFT",
                                  False), Property("VERWEIS", False))
     self._init_properties(re_daten_properties)
コード例 #6
0
 def test_repr(self):
     re_property = Property(name="Test", default=False)
     compare("<Property (name: Test, value: False, type: bool)>", repr(re_property))
コード例 #7
0
 def test_set_bool_bug_non_capitalized(self):
     re_property = Property(name="Test", default=False)
     re_property.value = "on"
     self.assertTrue(re_property)
コード例 #8
0
 def test_wrong_default(self):
     with self.assertRaises(TypeError):
         re_property = Property(name="Test", default=1)
         re_property.value_to_string()
コード例 #9
0
 def test_format_bool(self):
     re_property = Property(name="Test", default=False)
     self.assertEqual(re_property.value_to_string(), "OFF")
     re_property.value = True
     self.assertEqual(re_property.value_to_string(), "ON")