Esempio n. 1
0
    def save(self):
        """
        Saves this stack if it has not been previously saved. If it needs to be changed the stack must first be deleted.

        """
        s = load_stack(self)
        if not load_stack(self):
            save_stack(self)
Esempio n. 2
0
    def save(self):
        """
        Saves this stack if it has not been previously saved. If it needs to be changed the stack must first be deleted.

        """
        s = load_stack(self)
        if not load_stack(self):
            save_stack(self)
Esempio n. 3
0
    def load(self):
        """
        Loads the state of a previously saved CallStack to this instance.

        """
        s = load_stack(self)
        if s:
            self.hooks = s.hooks
            self.calls = s.calls
Esempio n. 4
0
    def load(self):
        """
        Loads the state of a previously saved CallStack to this instance.

        """
        s = load_stack(self)
        if s:
            self.hooks = s.hooks
            self.calls = s.calls
Esempio n. 5
0
    def test_load_and_save_stack(self):
        cs = CallStack(self.test_load_and_save_stack)

        h1 = Hook('fake-hash2', callback2)
        h2 = Hook('fake-hash3', callback3)

        cs.add_hook(h1)
        cs.add_hook(h2)

        assert len(cs.hooks) == 2
        assert len(cs.calls) == 0
        assert cs.hooks['fake-hash2'].hash == 'fake-hash2'
        assert cs.hooks['fake-hash3'].hash == 'fake-hash3'

        delete_stack(cs)

        save_stack(cs)
        loaded = load_stack(cs)

        assert len(loaded.hooks) == 2
        assert len(loaded.calls) == 0
        assert loaded.hooks['fake-hash2'].hash == 'fake-hash2'
        assert loaded.hooks['fake-hash3'].hash == 'fake-hash3'
    def test_load_and_save_stack(self):
        cs = CallStack(self.test_load_and_save_stack)

        h1 = Hook('fake-hash2', callback2)
        h2 = Hook('fake-hash3', callback3)

        cs.add_hook(h1)
        cs.add_hook(h2)

        assert len(cs.hooks) == 2
        assert len(cs.calls) == 0
        assert cs.hooks['fake-hash2'].hash == 'fake-hash2'
        assert cs.hooks['fake-hash3'].hash == 'fake-hash3'

        delete_stack(cs)

        save_stack(cs)
        loaded = load_stack(cs)

        assert len(loaded.hooks) == 2
        assert len(loaded.calls) == 0
        assert loaded.hooks['fake-hash2'].hash == 'fake-hash2'
        assert loaded.hooks['fake-hash3'].hash == 'fake-hash3'
Esempio n. 7
0
    def test_load_and_save_stack(self):
        cs = CallStack(self.test_load_and_save_stack)

        h1 = Hook("fake-hash2", callback2)
        h2 = Hook("fake-hash3", callback3)

        cs.add_hook(h1)
        cs.add_hook(h2)

        assert len(cs.hooks) == 2
        assert len(cs.calls) == 0
        assert cs.hooks["fake-hash2"].hash == "fake-hash2"
        assert cs.hooks["fake-hash3"].hash == "fake-hash3"

        delete_stack(cs)

        save_stack(cs)
        loaded = load_stack(cs)

        assert len(loaded.hooks) == 2
        assert len(loaded.calls) == 0
        assert loaded.hooks["fake-hash2"].hash == "fake-hash2"
        assert loaded.hooks["fake-hash3"].hash == "fake-hash3"