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()
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()
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)
def test_topWithoutPush(self): tls = ThreadLocalStack() with self.assertRaises(AssertionError): x = tls.top
def test_create(self): tls = ThreadLocalStack()