Commits

John Mulligan  committed bd76e4a

add unit test for really iterating on results

  • Participants
  • Parent commits bde75f8

Comments (0)

Files changed (1)

File tests/test_fslib.py

             self.assertRaises(select.error, select.select, [d2], [], [])
             self.assertRaises(OSError, fslib.fditerdir, d2)
 
+    def test_fditerdir_iter(self):
+        f1 = os.path.join(self.tdir, 'antelope')
+        f2 = os.path.join(self.tdir, 'bear')
+        f3 = os.path.join(self.tdir, 'copperhead')
+        with open(f1, 'w') as fh:
+            fh.write('foo\n')
+        with open(f2, 'w') as fh:
+            fh.write('bar\n')
+        with open(f3, 'w') as fh:
+            fh.write('baz\n')
+        with self.getdir() as dh:
+            diriter = fslib.fditerdir(dh)
+            dlist = sorted(diriter)
+            self.assertEqual(dlist, ['antelope', 'bear', 'copperhead'])
+            diriter = fslib.fditerdir(dh)
+            dset = set(diriter)
+            self.assertIn('antelope', dset)
+            self.assertIn('bear', dset)
+            self.assertIn('copperhead', dset)
+            self.assertEqual(3, len(dset))
+
     def test_fditerdir_closeearly(self):
         import select
         import gc