예제 #1
0
    def test_multiplePush(self):
        tls = ThreadLocalStack()
        tls.push('value1')
        tls.push('value2')

        self.assertEqual(tls.top, 'value2')
        self.assertEqual(tls.pop(), 1)
        self.assertEqual(tls.top, 'value1')
        self.assertEqual(tls.pop(), 0)
예제 #2
0
    def test_popOnDifferentThread(self):
        tls = ThreadLocalStack()
        tls.push('value')

        def popThread():
            with self.assertRaises(AssertionError):
                tls.pop()

        thread = threading.Thread(target = popThread)
        thread.start()
        thread.join()
예제 #3
0
    def test_popOnDifferentThread(self):
        tls = ThreadLocalStack()
        tls.push('value')

        def popThread():
            with self.assertRaises(AssertionError):
                tls.pop()

        thread = threading.Thread(target=popThread)
        thread.start()
        thread.join()
예제 #4
0
    def test_multiplePush(self):
        tls = ThreadLocalStack()
        tls.push('value1')
        tls.push('value2')

        self.assertEqual(tls.top, 'value2')
        self.assertEqual(tls.pop(), 1)
        self.assertEqual(tls.top, 'value1')
        self.assertEqual(tls.pop(), 0)
예제 #5
0
 def test_popWithoutPush(self):
     tls = ThreadLocalStack()
     with self.assertRaises(AssertionError):
         tls.pop()
예제 #6
0
 def test_pop(self):
     tls = ThreadLocalStack()
     tls.push('value')
     self.assertEqual(tls.pop(), 0)
예제 #7
0
 def test_push(self):
     tls = ThreadLocalStack()
     toPush = 'value'
     tls.push(toPush)
     self.assertEqual(tls.top, toPush)
예제 #8
0
 def test_topWithoutPush(self):
     tls = ThreadLocalStack()
     with self.assertRaises(AssertionError):
         x = tls.top
예제 #9
0
 def test_pop(self):
     tls = ThreadLocalStack()
     tls.push('value')
     self.assertEqual(tls.pop(), 0)
예제 #10
0
 def test_push(self):
     tls = ThreadLocalStack()
     toPush = 'value'
     tls.push(toPush)
     self.assertEqual(tls.top, toPush)
예제 #11
0
 def test_create(self):
     tls = ThreadLocalStack()