Blob Blame History Raw
From 563783077b5cde24d10cb7c55bba643007f3520f Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Wed, 18 Jul 2018 16:46:45 -0400
Subject: [PATCH] TST: Fix flaky listing test.

Since this reads layer names from multiple files, there's no guarantee
that they will be in order since the filesystem can iterate in any
order.

Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
 tests/test_fio_ls.py  | 4 ++--
 tests/test_listing.py | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tests/test_fio_ls.py b/tests/test_fio_ls.py
index 14d614b..399193b 100644
--- a/tests/test_fio_ls.py
+++ b/tests/test_fio_ls.py
@@ -23,7 +23,7 @@ def test_fio_ls_single_layer():
         'tests/data/'])
     assert result.exit_code == 0
     assert len(result.output.splitlines()) == 1
-    assert json.loads(result.output) == ['coutwildrnp', 'gre']
+    assert sorted(json.loads(result.output)) == ['coutwildrnp', 'gre']
 
 
 @unittest.skipIf(FIXME_WINDOWS, 
@@ -59,7 +59,7 @@ def test_fio_ls_multi_layer():
         result = CliRunner().invoke(main_group, [
             'ls', outdir])
         assert result.exit_code == 0
-        assert json.loads(result.output) == layer_names
+        assert sorted(json.loads(result.output)) == layer_names
 
     finally:
         shutil.rmtree(outdir)
diff --git a/tests/test_listing.py b/tests/test_listing.py
index c74e452..84b4064 100644
--- a/tests/test_listing.py
+++ b/tests/test_listing.py
@@ -19,12 +19,12 @@ def test_single_file():
     assert fiona.listlayers('tests/data/coutwildrnp.shp') == ['coutwildrnp']
 
 def test_directory():
-    assert fiona.listlayers('tests/data') == ['coutwildrnp', 'gre']
+    assert sorted(fiona.listlayers('tests/data')) == ['coutwildrnp', 'gre']
 
 @unittest.skipIf(FIXME_WINDOWS,
                  reason="FIXME on Windows. ValueError raised. Please look into why this test isn't working.")
 def test_directory_trailing_slash():
-    assert fiona.listlayers('tests/data/') == ['coutwildrnp', 'gre']
+    assert sorted(fiona.listlayers('tests/data/')) == ['coutwildrnp', 'gre']
 
 def test_zip_path():
     assert fiona.listlayers('zip://tests/data/coutwildrnp.zip') == ['coutwildrnp']
-- 
2.17.1