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)
    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()
Exemple #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()
Exemple #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)
 def test_popWithoutPush(self):
     tls = ThreadLocalStack()
     with self.assertRaises(AssertionError):
         tls.pop()
 def test_pop(self):
     tls = ThreadLocalStack()
     tls.push('value')
     self.assertEqual(tls.pop(), 0)
 def test_push(self):
     tls = ThreadLocalStack()
     toPush = 'value'
     tls.push(toPush)
     self.assertEqual(tls.top, toPush)
Exemple #8
0
 def test_topWithoutPush(self):
     tls = ThreadLocalStack()
     with self.assertRaises(AssertionError):
         x = tls.top
Exemple #9
0
 def test_pop(self):
     tls = ThreadLocalStack()
     tls.push('value')
     self.assertEqual(tls.pop(), 0)
Exemple #10
0
 def test_push(self):
     tls = ThreadLocalStack()
     toPush = 'value'
     tls.push(toPush)
     self.assertEqual(tls.top, toPush)
Exemple #11
0
 def test_create(self):
     tls = ThreadLocalStack()