#273: Remove nose dependency for stacks_queues/ (#276)

This commit is contained in:
Donne Martin
2020-07-08 19:57:55 -04:00
committed by GitHub
parent 0e7ed80228
commit 139e157250
23 changed files with 290 additions and 373 deletions

View File

@@ -1,16 +1,13 @@
from nose.tools import assert_equal
from nose.tools import raises
import unittest
class TestStacks(object):
class TestStacks(unittest.TestCase):
@raises(Exception)
def test_pop_on_empty(self, num_stacks, stack_size):
print('Test: Pop on empty stack')
stacks = Stacks(num_stacks, stack_size)
stacks.pop(0)
@raises(Exception)
def test_push_on_full(self, num_stacks, stack_size):
print('Test: Push to full stack')
stacks = Stacks(num_stacks, stack_size)
@@ -27,10 +24,10 @@ class TestStacks(object):
stacks.push(2, 4)
print('Test: Pop on non-empty stack')
assert_equal(stacks.pop(0), 2)
assert_equal(stacks.pop(0), 1)
assert_equal(stacks.pop(1), 3)
assert_equal(stacks.pop(2), 4)
self.assertEqual(stacks.pop(0), 2)
self.assertEqual(stacks.pop(0), 1)
self.assertEqual(stacks.pop(1), 3)
self.assertEqual(stacks.pop(2), 4)
print('Success: test_stacks\n')
@@ -39,10 +36,12 @@ def main():
num_stacks = 3
stack_size = 100
test = TestStacks()
test.test_pop_on_empty(num_stacks, stack_size)
test.test_push_on_full(num_stacks, stack_size)
test.assertRaises(Exception, test.test_pop_on_empty, num_stacks,
stack_size)
test.assertRaises(Exception, test.test_push_on_full, num_stacks,
stack_size)
test.test_stacks(num_stacks, stack_size)
if __name__ == '__main__':
main()
main()