Skip to content

Commit

Permalink
Fixed tests, according to strange qodana recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
m4tveevm committed Oct 7, 2024
1 parent 0e9c3a1 commit f90cd18
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
3 changes: 2 additions & 1 deletion Shunting Yard/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@


class MyTestCase(unittest.TestCase):
def setUp(self) -> None:
def __init__(self):
super().__init__()
self.sol = Solution()

def test_algo(self):
Expand Down
50 changes: 26 additions & 24 deletions algo/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,47 @@


class TestQueue(unittest.TestCase):
def setUp(self):
self.queue = Queue()
def __init__(self):
super().__init__()
self.__queue = Queue()

def test_push_and_pop(self):
self.queue.push(1)
self.queue.push(2)
self.queue.push(3)
self.assertEqual(len(self.queue), 3)
self.assertEqual(self.queue.pop(), 1)
self.assertEqual(self.queue.pop(), 2)
self.assertEqual(self.queue.pop(), 3)
self.assertIsNone(self.queue.pop())
self.__queue.push(1)
self.__queue.push(2)
self.__queue.push(3)
self.assertEqual(len(self.__queue), 3)
self.assertEqual(self.__queue.pop(), 1)
self.assertEqual(self.__queue.pop(), 2)
self.assertEqual(self.__queue.pop(), 3)
self.assertIsNone(self.__queue.pop())

def test_pop_empty(self):
self.assertIsNone(self.queue.pop())
self.assertIsNone(self.__queue.pop())

def test_len_empty(self):
self.assertEqual(len(self.queue), 0)
self.assertEqual(len(self.__queue), 0)


class TestStack(unittest.TestCase):
def setUp(self):
self.stack = Stack()
def __init__(self):
super().__init__()
self.__stack = Stack()

def test_push_and_pop(self):
self.stack.push(1)
self.stack.push(2)
self.stack.push(3)
self.assertEqual(len(self.stack), 3)
self.assertEqual(self.stack.pop(), 3)
self.assertEqual(self.stack.pop(), 2)
self.assertEqual(self.stack.pop(), 1)
self.assertIsNone(self.stack.pop())
self.__stack.push(1)
self.__stack.push(2)
self.__stack.push(3)
self.assertEqual(len(self.__stack), 3)
self.assertEqual(self.__stack.pop(), 3)
self.assertEqual(self.__stack.pop(), 2)
self.assertEqual(self.__stack.pop(), 1)
self.assertIsNone(self.__stack.pop())

def test_pop_empty(self):
self.assertIsNone(self.stack.pop())
self.assertIsNone(self.__stack.pop())

def test_len_empty(self):
self.assertEqual(len(self.stack), 0)
self.assertEqual(len(self.__stack), 0)


if __name__ == "__main__":
Expand Down

0 comments on commit f90cd18

Please sign in to comment.