For a school assignment, I am tasked with implementing a FIFO Priority Queue using heapq. I am using a counter when appending which tracks when a node was pushed onto the heap. However, in the unit tests we must pass there seems to be a contradiction of sorts:
In the first test, it pushes tuples (an integer and a string) to the priority queue. The integer value is also pushed onto a temporary list. The temp list is then sorted in ascending order and the test begins to pop off our queue elements. They are looking for the two values to match. If the temp list is (1, 2, 5, 6) for example, the first element to pop off the pq should be 1. I was able to get this test to pass fairly easily.
However, test 2 tests for FIFO functionality. Essentially, elements with equal integer values should be popped off in the order added. This is where I implemented a counter to keep track of added orders and the FIFO test passed. However, the first test now fails. It seems contradictory to expect the heap to pop off elements by minimum tuple integer value instead of priority. Am I misthinking this issue? I cannot, unfortunately, post any code as my program doesn't allow us to post raw code on StackOverflow. I've been stuck trying to figure out this basic implementation for several days.