示例#1
0
    def test_link_repr_chain_all(self):
        def function():
            pass

        self.assertEqual(
            repr(Link(Any(), LinkAction.stop, AcceptChain(), function)),
            '<Link "if any then LinkAction.stop" accept function()>')
示例#2
0
    def test_link_repr_chain_and_function(self):
        def function():
            pass

        self.assertEqual(
            repr(Link(Any(), chain=AcceptChain(), function=function)),
            '<Link "if any then LinkAction.defer" accept function()>')
示例#3
0
 def test_flush(self):
     # Test that we can flush the links of a chain.
     chain = Chain('test', 'just a testing chain')
     chain.append_link(Link(Any()))
     # Iterate over the links of the chain to prove there are some.
     count = sum(1 for link in chain.get_iterator())
     self.assertEqual(count, 1)
     # Flush the chain; then there will be no links.
     chain.flush()
     count = sum(1 for link in chain.get_iterator())
     self.assertEqual(count, 0)
示例#4
0
 def test_link_repr_chain(self):
     self.assertEqual(
         repr(Link(Any(), chain=AcceptChain())),
         '<Link "if any then LinkAction.defer" accept>')
示例#5
0
 def test_link_repr_function(self):
     def function():
         pass
     self.assertEqual(
         repr(Link(Any(), function=function)),
         '<Link "if any then LinkAction.defer" function()>')
示例#6
0
 def test_link_repr(self):
     self.assertEqual(
         repr(Link(Any())), '<Link "if any then LinkAction.defer">')