Commits

Lynn Rees committed 169daa6

- fix peek

  • Participants
  • Parent commits f114c38
  • Branches next

Comments (0)

Files changed (3)

File twoq/queuing.py

         '''swap context to default context'''
         return self.swap()
 
-    rw = unswap
+    def rw(self):
+        '''switch to read/write context'''
+        return self._uclear().unswap()
 
     def reswap(self):
         '''swap contexts to current preferred context'''
 
     def peek(self):
         '''results from read-only context'''
+        self.ro()
         out = self._wrapper(self._util)
-        return out[0] if len(out) == 1 else out
+        results = out[0] if len(out) == 1 else out
+        self.rw()
+        return results
 
     def results(self):
         '''yield outgoing things, clearing outgoing things as it iterates'''

File twoq/tests/auto/queuing.py

             self.qclass([1, 2, 3, 4, 5, 6]).__repr__(), strings,
         ))
 
-    def test_ro(self):
-        self.assertListEqual(
-            self.qclass([1, 2, 3, 4, 5, 6]).ro().peek(), [1, 2, 3, 4, 5, 6],
-        )
+    def test_peek(self):
+        initial = self.qclass(1, 2, 3, 4, 5, 6)
+        self.assertListEqual(initial.peek(), [1, 2, 3, 4, 5, 6])
+        self.assertEqual(len(initial), 6)
+        self.assertListEqual(initial.outsync().end(), [1, 2, 3, 4, 5, 6])
+        self.assertEqual(len(initial), 0)
 
     def test_extend(self):
         self.assertEqual(

File twoq/tests/man/queuing.py

             self.qclass([1, 2, 3, 4, 5, 6]).__repr__(), strings,
         ))
 
-    def test_ro(self):
-        self.assertEqual(
-            self.qclass([1, 2, 3, 4, 5, 6]).ro().peek(), [1, 2, 3, 4, 5, 6],
-        )
+    def test_peek(self):
+        initial = self.qclass(1, 2, 3, 4, 5, 6)
+        self.assertListEqual(initial.peek(), [1, 2, 3, 4, 5, 6])
+        self.assertEqual(len(initial), 6)
+        self.assertListEqual(initial.outsync().end(), [1, 2, 3, 4, 5, 6])
+        self.assertEqual(len(initial), 0)
 
     def test_extend(self):
         self.assertEqual(