예제 #1
0
def test_add_and_remove_class_attribute():
    from System import TimeSpan

    for _ in range(100):
        TimeSpan.new_method = lambda self_: self_.TotalMinutes
        ts = TimeSpan.FromHours(1)
        assert ts.new_method() == 60
        del TimeSpan.new_method
        assert not hasattr(ts, "new_method")
예제 #2
0
    def testAddAndRemoveClassAttribute(self):

        from System import TimeSpan

        for i in range(100):
            TimeSpan.new_method = lambda self: self.TotalMinutes
            ts = TimeSpan.FromHours(1)
            self.assertTrue(ts.new_method() == 60)
            del TimeSpan.new_method
            self.assertFalse(hasattr(ts, "new_method"))